From: nadir Date: Tue, 31 Jan 2006 14:46:37 +0000 (+0000) Subject: committing the version in the main trunk of the CVS tree the branch X-Git-Tag: ForV3_2_0a1With_K_G_310~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=cf9d7ae1cc0b51c4e5332f73c10bfba5bb3b7ad1;p=modules%2Fmed.git committing the version in the main trunk of the CVS tree the branch IntegrationEDF tagged ForV3_2_0bx. That is for the V3_2_0a1 of the MED module. --- diff --git a/INSTALL b/INSTALL index 06f8d05fd..54ce0531a 100644 --- a/INSTALL +++ b/INSTALL @@ -1,4 +1,4 @@ -This is the version 3.1.0 of MED +This is the version 3.2.0a1 of MED Compatible with : - KERNEL 3.1.0 - SALOMEGUI 3.1.0 diff --git a/Makefile.in b/Makefile.in index 5af0d1866..7ddc521bf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -62,6 +62,7 @@ Darcy3_3D_H_10x10x10_2.med \ elle_3D_HPr_10x10x10_2.med \ elle_3D_HPr_2x2x2_2.med \ elle_3D_HPr_4x4x4_2.med \ +test_2D.med \ Darcy3_3D_H_10x10x10.sauve \ dx200_dy1_avec_2couches.sauve \ elle_2D_QT_10x10.sauve \ diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index 477e1b309..5b55b4a9e 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -273,5 +273,5 @@ ac_cxx_typename.m4 check_pthreads.m4 check_cas.m4 \ ac_cc_warnings.m4 check_qt.m4 check_swig.m4 endif -$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=$(top_srcdir)/salome_adm/unix/config_files/%) - cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I $(top_srcdir)/salome_adm/unix/config_files +$(top_srcdir)/aclocal.m4: $(ACLOCAL_SRC:%=@KERNEL_ROOT_DIR@/salome_adm/unix/config_files/%) + cd $(top_srcdir) ; aclocal --acdir=adm_local/unix/config_files -I @KERNEL_ROOT_DIR@/salome_adm/unix/config_files diff --git a/bin/VERSION b/bin/VERSION index c89a9d5bf..c7cb4acac 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1 +1 @@ -THIS IS SALOME - MED VERSION: 3.1.0 +THIS IS SALOME - MED VERSION: 3.2.0a1 diff --git a/configure.in.base b/configure.in.base index 3e5907939..632529721 100644 --- a/configure.in.base +++ b/configure.in.base @@ -340,14 +340,6 @@ echo CHECK_MSG2QM -echo -echo --------------------------------------------- -echo Testing html generators -echo --------------------------------------------- -echo - -CHECK_HTML_GENERATORS - } else { @@ -357,6 +349,14 @@ else } fi # MED_WITH_KERNEL +echo +echo --------------------------------------------- +echo Testing html generators +echo --------------------------------------------- +echo + +CHECK_HTML_GENERATORS + echo echo --------------------------------------------- echo Summary diff --git a/doc/MEDMEM/FIELDgeneral.cxx b/doc/MEDMEM/FIELDgeneral.cxx index 1d37145ac..82771051a 100644 --- a/doc/MEDMEM/FIELDgeneral.cxx +++ b/doc/MEDMEM/FIELDgeneral.cxx @@ -67,7 +67,7 @@ int main (int argc, char ** argv) { // How many Value : int NumberOfValue = mySupport->getNumberOfElements(MED_ALL_ELEMENTS); // Value - const double * Value = myField.getValue(MED_FULL_INTERLACE); + const double * Value = myField.getValue(); for(int i=0; i 0 ) + { + cout << "Show Connectivity (Nodal) of POLYGONS:" << endl ; + const int* Connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL); + const int* ConnectivityIndex = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL); + for (int j=0; j 0 ) + { + cout << "Show Connectivity (Nodal) of POLYHEDRONS:" << endl ; + const int* Connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL); + const int* FaceIndex = myMesh.getPolyhedronFacesIndex(); + const int* Index = myMesh.getPolyhedronIndex(MED_NODAL); + for (int j=0; j 0 : + print "" + print " Show Connectivity (Nodal) of POLYGONS:" + print "" + connectivity = myMesh.getPolygonsConnectivity(MED_NODAL,MED_CELL) + index = myMesh.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL) + for j in range(nbPolygons): + print " Polygon",(j+1)," ",connectivity[ index[j]-1 : index[j+1]-1 ] + pass + pass + +nbPolyhedrons = myMesh.getNumberOfPolyhedron() +if nbPolyhedrons > 0 : + print "" + print " Show Connectivity (Nodal) of POLYHEDRONS:" + print "" + connectivity = myMesh.getPolyhedronConnectivity(MED_NODAL) + fIndex = myMesh.getPolyhedronFacesIndex() + index = myMesh.getPolyhedronIndex(MED_NODAL) + for j in range(nbPolyhedrons): + print " Polyhedra",(j+1) + iF1, iF2 = index[ j ]-1, index[ j+1 ]-1 + for f in range( iF2 - iF1 ): + iN1, iN2 = fIndex[ iF1+f ]-1, fIndex[ iF1+f+1 ]-1 + print " Face",f+1," ",connectivity[ iN1 : iN2 ] + pass + pass + pass diff --git a/idl/MED.idl b/idl/MED.idl index ca69f8680..485fa6381 100644 --- a/idl/MED.idl +++ b/idl/MED.idl @@ -920,6 +920,11 @@ Internal Corba method. */ long getOrderNumber() raises (SALOME::SALOME_Exception); + /*! + Returns if gauss points are present. + */ + boolean getGaussPresence(); + // Read & Write // ----------- @@ -973,6 +978,12 @@ Internal Corba method. raises (SALOME::SALOME_Exception); }; + interface FIELDDOUBLENO : FIELDDOUBLE { + }; + + interface FIELDDOUBLEFULL : FIELDDOUBLE { + }; + interface FIELDINT : FIELD , SALOME::MultiCommClass { /*! @@ -989,6 +1000,12 @@ Internal Corba method. raises (SALOME::SALOME_Exception); }; + interface FIELDINTNO : FIELDINT { + }; + + interface FIELDINTFULL : FIELDINT { + }; + // MED interface interface MED : SALOME::GenericObj { diff --git a/resources/MEDCatalog.xml b/resources/MEDCatalog.xml index 870d56b34..16164327e 100644 --- a/resources/MEDCatalog.xml +++ b/resources/MEDCatalog.xml @@ -16,7 +16,7 @@ Med MESH Patrick GOLDBRONN - 3.1.0 + 3.2.0 MED memory component 1 ModuleMed.png diff --git a/resources/test_2D.med b/resources/test_2D.med new file mode 100644 index 000000000..7e55f6492 Binary files /dev/null and b/resources/test_2D.med differ diff --git a/src/INTERPOLATION/MEDMEM_Interpolation.hxx b/src/INTERPOLATION/MEDMEM_Interpolation.hxx index 486d7f1f9..e8eca6c02 100644 --- a/src/INTERPOLATION/MEDMEM_Interpolation.hxx +++ b/src/INTERPOLATION/MEDMEM_Interpolation.hxx @@ -319,14 +319,14 @@ template FIELD * INTERPOLATION::interpolate(i _toField->setIterationNumber ( _fromField->getIterationNumber() ); _toField->setTime ( _fromField->getTime() ); _toField->setOrderNumber ( _fromField->getOrderNumber() ); - _toField->setValueType ( MED_EN::MED_REEL64 ); + // _toField->setValueType ( MED_EN::MED_REEL64 ); SUPPORT * mySupport(new SUPPORT(_toMesh,"support",MED_EN::MED_NODE)); _toField->setSupport(mySupport); _toField->allocValue(_toField->getNumberOfComponents(),_toField->getNumberOfValues()); - _toField->setValue( MED_EN::MED_FULL_INTERLACE,resultat.Get_Valeurs()); + _toField->setValue(resultat.Get_Valeurs()); _toWrapper->Construit_Wrapper_Champ(_toField); diff --git a/src/INTERPOLATION/MEDMEM_WrapperField.hxx b/src/INTERPOLATION/MEDMEM_WrapperField.hxx index a53751754..2e3b3d704 100644 --- a/src/INTERPOLATION/MEDMEM_WrapperField.hxx +++ b/src/INTERPOLATION/MEDMEM_WrapperField.hxx @@ -209,11 +209,11 @@ public : Wrapper_MED_Field(int nv, int nc, double * v):nbr_valeurs(nv),nbr_composantes(nc),valeurs(v) { } - Wrapper_MED_Field(const MEDMEM::FIELD * medfield) + Wrapper_MED_Field(const MEDMEM::FIELD * medfield) { nbr_valeurs=medfield->getNumberOfValues(); nbr_composantes=medfield->getNumberOfComponents(); - valeurs=const_cast(medfield->getValue(MED_EN::MED_FULL_INTERLACE)); + valeurs=const_cast(medfield->getValue()); } ~Wrapper_MED_Field(){} inline Valeur operator[](int i) diff --git a/src/MED/Med_Gen_i.cxx b/src/MED/Med_Gen_i.cxx index b585d4448..cfa3c0429 100755 --- a/src/MED/Med_Gen_i.cxx +++ b/src/MED/Med_Gen_i.cxx @@ -30,8 +30,7 @@ #include "MEDMEM_Mesh_i.hxx" #include "MEDMEM_Med_i.hxx" -#include "MEDMEM_FieldInt_i.hxx" -#include "MEDMEM_FieldDouble_i.hxx" +#include "MEDMEM_FieldTemplate_i.hxx" #include "MEDMEM_Support_i.hxx" #include "MEDMEM_Mesh.hxx" @@ -443,7 +442,7 @@ throw (SALOME::SALOME_Exception) try { ((FIELD*)myField)->read() ; - FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); + FIELDTEMPLATE_I * myFieldIntI = new FIELDTEMPLATE_I((FIELD*)myField); SALOME_MED::FIELD_ptr myFieldIOR = myFieldIntI->_this(); // if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ; endService("Med_Gen_i::readFieldInFile"); @@ -463,7 +462,7 @@ throw (SALOME::SALOME_Exception) try { ((FIELD*)myField)->read() ; - FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); + FIELDTEMPLATE_I * myFieldDoubleI = new FIELDTEMPLATE_I((FIELD*)myField); SALOME_MED::FIELD_ptr myFieldIOR = myFieldDoubleI->_this() ; // if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ; endService("Med_Gen_i::readFieldInFile"); diff --git a/src/MEDMEM/Doxyfile_med_devel.in b/src/MEDMEM/Doxyfile_med_devel.in index 79625d991..f2e643b85 100644 --- a/src/MEDMEM/Doxyfile_med_devel.in +++ b/src/MEDMEM/Doxyfile_med_devel.in @@ -4,7 +4,7 @@ # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = "Med Memory Developpers'" -PROJECT_NUMBER = 1.0.2 +PROJECT_NUMBER = 3.2.0 OUTPUT_DIRECTORY = doc_ref_devel OUTPUT_LANGUAGE = English EXTRACT_ALL = YES diff --git a/src/MEDMEM/Doxyfile_med_user.in b/src/MEDMEM/Doxyfile_med_user.in index 0f007a560..89da816ca 100644 --- a/src/MEDMEM/Doxyfile_med_user.in +++ b/src/MEDMEM/Doxyfile_med_user.in @@ -4,7 +4,7 @@ # General configuration options #--------------------------------------------------------------------------- PROJECT_NAME = "Med Memory Users'" -PROJECT_NUMBER = 1.0.2 +PROJECT_NUMBER = 3.2.0 OUTPUT_DIRECTORY = doc_ref_user OUTPUT_LANGUAGE = English EXTRACT_ALL = YES diff --git a/src/MEDMEM/MEDMEM_ArrayConvert.hxx b/src/MEDMEM/MEDMEM_ArrayConvert.hxx new file mode 100644 index 000000000..717425738 --- /dev/null +++ b/src/MEDMEM/MEDMEM_ArrayConvert.hxx @@ -0,0 +1,173 @@ +#ifndef MEDMEM_ARRAY_CONVERT_HXX +#define MEDMEM_ARRAY_CONVERT_HXX + +namespace MEDMEM { + +template +MEDMEM_Array * +ArrayConvert( + const MEDMEM_Array< T, NoInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0 + ) +{ + MEDMEM_Array * myArray; + if(values) + myArray = new MEDMEM_Array + (values, + array.getDim(), + array.getNbElem(), + array.getNbGeoType(), + array.getNbElemGeoC(), + array.getNbGaussGeo(), + true,false + ); + else + myArray= new MEDMEM_Array + (array.getDim(), + array.getNbElem(), + array.getNbGeoType(), + array.getNbElemGeoC(), + array.getNbGaussGeo() + ); + for (int i=1; i <= array.getNbElem() ; i++ ) + for (int k=1; k<= array.getNbGauss(i); k++ ) + for (int j=1; j<= array.getDim(); j++ ) + myArray->setIJK(i,j,k,array.getIJK(i,j,k)); + + return myArray; + +}; + +template +MEDMEM_Array * +ArrayConvert( + const MEDMEM_Array< T, FullInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0 + ) +{ + MEDMEM_Array * myArray; + if(values) + myArray = new MEDMEM_Array ( + values, + array.getDim(), + array.getNbElem(), + array.getNbGeoType(), + array.getNbElemGeoC(), + array.getNbGaussGeo(), + true,false + ); + else + myArray = new MEDMEM_Array ( + array.getDim(), + array.getNbElem(), + array.getNbGeoType(), + array.getNbElemGeoC(), + array.getNbGaussGeo() + ); + for (int i=1; i <= array.getNbElem() ; i++ ) + for (int k=1; k<= array.getNbGauss(i); k++ ) + for (int j=1; j<= array.getDim(); j++ ) + myArray->setIJK(i,j,k,array.getIJK(i,j,k)); + + return myArray; + +}; + +template +MEDMEM_Array * +ArrayConvert( + const MEDMEM_Array< T, FullInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0 + ) +{ + MEDMEM_Array * myArray; + if(values) + myArray=new MEDMEM_Array ( values, + array.getDim(), + array.getNbElem(), + true,false + ); + else + myArray = new MEDMEM_Array ( + array.getDim(), + array.getNbElem() + ); + for (int i=1; i <= array.getNbElem() ; i++ ) + for (int j=1; j<= array.getDim(); j++ ) + myArray->setIJ(i,j,array.getIJ(i,j)); + + return myArray; + +}; + +template +MEDMEM_Array * +ArrayConvert( + const MEDMEM_Array< T, NoInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0 + ) +{ + MEDMEM_Array * myArray; + if(values) + myArray= new MEDMEM_Array (values, + array.getDim(), + array.getNbElem(), + true,false + ); + else + myArray= new MEDMEM_Array ( + array.getDim(), + array.getNbElem() + ); + for (int i=1; i <= array.getNbElem() ; i++ ) + for (int j=1; j<= array.getDim(); j++ ) + myArray->setIJ(i,j,array.getIJ(i,j)); + + return myArray; + +}; + + + +// template +// void ArrayConvert( +// const MEDMEM_Array< T, INTERLACING_POLICY, CHECKING_POLICY > & arrayin, +// MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY> * & arrayout +// ) +// { + +// MEDMEM_Array * myArray; +// myArray= new MEDMEM_Array< T, INTERLACING_POLICY_OTHER, CHECKING_POLICY > ( +// arrayin.getDim(), +// arrayin.getNbElem(), +// arrayin.getNbGeoType(), +// arrayin.getNbElemGeoC(), +// arrayin.getNbGaussGeo() +// ); + +// for (int i=1; i <= arrayin.getNbElem() ; i++ ) +// for (int k=1; k<= arrayin.getNbGauss(i); k++ ) +// for (int j=1; j<= arrayin.getDim(); j++ ) +// myArray->setIJK(i,j,k,arrayin.getIJK(i,j,k)); + +// arrayout=myArray; + +// }; + + + + + +// template +// typename MEDMEM_ArrayInterface::Array & +// convertBis(const typename MEDMEM_ArrayInterface< +// ARRAY_ELEMENT_TYPE, +// NoInterlace, +// GAUSS_TAG, +// CHECKING_POLICY>::Array & array ) { +// std::cout << "-------- Convert 3" << std::endl; +// }; + +} //END NAMESPACE +#endif diff --git a/src/MEDMEM/MEDMEM_ArrayInterface.hxx b/src/MEDMEM/MEDMEM_ArrayInterface.hxx new file mode 100644 index 000000000..d82d6cdf6 --- /dev/null +++ b/src/MEDMEM/MEDMEM_ArrayInterface.hxx @@ -0,0 +1,86 @@ +#ifndef MEDMEM_ARRAYINTERFACE_HXX +#define MEDMEM_ARRAYINTERFACE_HXX + +#include "MEDMEM_nArray.hxx" +#include "MEDMEM_InterlacingTraits.hxx" + +// L'astuce d'une classe d'interface consiste en +// 1) La déclaration d'un type qui est celui de la classe d'implémentation +// 2) D'utiliser ce nouveau nom de type comme paramètres de toutes +// les méthodes de l'interface. +// L'inconvenient est qu'il faut justement passer en argument une instance de +// le classe d'implémentation dans toutes les méthodes et que la classe +// appelante aura aussi à faire ce travail. +// Ne surtout pas oublier inline sinon l'interface couterait cher à l'appel +// des méthodes ! +namespace MEDMEM { + +template < class ARRAY_ELEMENT_TYPE, + class INTERLACE_TAG, + class GAUSS_TAG, + class CHECKING_POLICY=IndexCheckPolicy> + //NoIndexCheckPolicy> +class MEDMEM_ArrayInterface { + +public: + + // Les type ElementType et Array sont a définir aussi dans les classes utilisatrice + // par une déclaration du type : typedef typename ArrayInterface::Array Array; + + typedef ARRAY_ELEMENT_TYPE ElementType; + typedef INTERLACE_TAG Interlacing; + typedef GAUSS_TAG GaussPresence; + typedef typename MEDMEM_InterlacingTraits::Type InterlacingPolicy; + typedef CHECKING_POLICY CheckingPolicy; + typedef MEDMEM_Array Array; + + static inline int getNbGauss(int i, const Array & array) { + return array.getNbGauss(i); + }; + + static inline ElementType * getPtr( Array & array) { + return array.getPtr(); + }; + + static inline void setPtr( ElementType * arrayptr, Array & array, + bool shallowCopy=false, + bool ownershipOfValues=false ) { + array.setPtr(arrayptr,shallowCopy,ownershipOfValues); + }; + + static inline const ElementType * getRow(int i, const Array & array ) { + return array.getRow(i); + } + + static inline void setRow(int i, const ElementType & value, const Array & array ) { + return array.setRow(i,value); + } + + static inline const ElementType * getColumn(int j, const Array & array ) { + return array.getColumn(j); + } + + static inline void setColumn(int j, const ElementType & value, const Array & array ) { + return array.setColumn(j,value); + } + + static inline const ElementType & getIJ(int i, int j, const Array & array) { + return array.getIJ(i,j); + } + + static inline const ElementType & getIJK(int i, int j, int k, const Array & array) { + return array.getIJK(i,j,k); + } + + static inline void setIJ(int i, int j, const ElementType & value, Array & array) { + array.setIJ(i,j,value); + } + + static inline void setIJK(int i, int j, int k, const ElementType & value, Array & array) { + array.setIJK(i,j,k,value); + } + +}; + +} //END NAMESPACE +#endif diff --git a/src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx b/src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx index b63df7658..0bdc2070f 100644 --- a/src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx +++ b/src/MEDMEM/MEDMEM_AsciiFieldDriver.hxx @@ -20,11 +20,13 @@ #ifndef ASCII_FIELD_DRIVER_HXX #define ASCII_FIELD_DRIVER_HXX -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Support.hxx" #include "MEDMEM_GenDriver.hxx" #include "MEDMEM_Exception.hxx" #include "MEDMEM_Unit.hxx" +#include "MEDMEM_Support.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_ArrayInterface.hxx" +#include "MEDMEM_ArrayConvert.hxx" #include #include @@ -40,8 +42,6 @@ namespace MEDMEM { - template - class FIELD; template void fill(double *a, const double *b) @@ -86,20 +86,29 @@ namespace MEDMEM { class ASCII_FIELD_DRIVER : public GENDRIVER { private: - MESH *_mesh; - SUPPORT *_support; - mutable FIELD * _ptrField; - std::string _fileName; - mutable ofstream _file; - unsigned int _code; - MED_EN::med_sort_direc _direc; - int _nbComponents; - int _spaceDimension; + MESH *_mesh; + SUPPORT *_support; + mutable FIELD *_ptrField; + std::string _fileName; + mutable ofstream _file; + unsigned int _code; + MED_EN::med_sort_direc _direc; + int _nbComponents; + int _spaceDimension; //static int _nbComponentsForCpyInfo; + public: - ASCII_FIELD_DRIVER(const string & fileName, FIELD * ptrField, + template + ASCII_FIELD_DRIVER():GENDRIVER(), + _ptrField((FIELD)MED_NULL), + _fileName("") {}; + + template + ASCII_FIELD_DRIVER(const string & fileName, FIELD * ptrField, MED_EN::med_sort_direc direction=MED_EN::ASCENDING, const char *priority=""); + + ASCII_FIELD_DRIVER(const ASCII_FIELD_DRIVER& other); void open() throw (MEDEXCEPTION); void close(); @@ -116,7 +125,6 @@ namespace MEDMEM { }; } -#include "MEDMEM_Field.hxx" namespace MEDMEM { @@ -162,38 +170,42 @@ namespace MEDMEM { } template - ASCII_FIELD_DRIVER::ASCII_FIELD_DRIVER(const string & fileName, FIELD * ptrField, - MED_EN::med_sort_direc direction,const char *priority) - :GENDRIVER(fileName,MED_EN::MED_ECRI),_ptrField(ptrField),_fileName(fileName),_direc(direction) - { - _nbComponents=_ptrField->getNumberOfComponents(); - if(_nbComponents<=0) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER : No components in FIELD"); - _support=(SUPPORT *)_ptrField->getSupport(); - _mesh=(MESH *)_support->getMesh(); - _spaceDimension=_mesh->getSpaceDimension(); - _code=3; - int i; - if(priority[0]=='\0') - for(i=_spaceDimension-1;i>=0;i--) - { - _code<<=2; - _code+=i; - } - else - { - if(_spaceDimension!=strlen(priority)) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Coordinate priority invalid with spaceDim"); + template + ASCII_FIELD_DRIVER::ASCII_FIELD_DRIVER(const string & fileName, + FIELD * ptrField, + MED_EN::med_sort_direc direction, + const char *priority) + :GENDRIVER(fileName,MED_EN::MED_ECRI),_ptrField((FIELD*)ptrField),_fileName(fileName),_direc(direction) + { + _nbComponents=_ptrField->getNumberOfComponents(); + if(_nbComponents<=0) + throw MEDEXCEPTION("ASCII_FIELD_DRIVER : No components in FIELD"); + _support=(SUPPORT *)_ptrField->getSupport(); + _mesh=(MESH *)_support->getMesh(); + _spaceDimension=_mesh->getSpaceDimension(); + _code=3; + int i; + if(priority[0]=='\0') for(i=_spaceDimension-1;i>=0;i--) { - char c=toupper(priority[i]); - if(int(c-'X')>(_spaceDimension-1)) - throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition"); _code<<=2; - _code+=c-'X'; + _code+=i; } - } - } + else + { + if(_spaceDimension!=strlen(priority)) + throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Coordinate priority invalid with spaceDim"); + for(i=_spaceDimension-1;i>=0;i--) + { + char c=toupper(priority[i]); + if(int(c-'X')>(_spaceDimension-1)) + throw MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid priority definition"); + _code<<=2; + _code+=c-'X'; + } + } + } + template ASCII_FIELD_DRIVER::ASCII_FIELD_DRIVER(const ASCII_FIELD_DRIVER& other) @@ -298,6 +310,7 @@ namespace MEDMEM { template void ASCII_FIELD_DRIVER::buildIntroduction() const { + int i; _file << setiosflags(ios::scientific); _file << "#TITLE: table " << _ptrField->getName() << " TIME: " << _ptrField->getTime() << " IT: " << _ptrField->getIterationNumber() << endl; @@ -337,79 +350,100 @@ namespace MEDMEM { } _file << endl; } +} + +#include "MEDMEM_Field.hxx" +namespace MEDMEM +{ template template void ASCII_FIELD_DRIVER::sortAndWrite() const { + typedef typename MEDMEM_ArrayInterface::Array ArrayDoubleNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayDoubleFull; + typedef typename MEDMEM_ArrayInterface::Array ArrayNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayFull; + int i,j; int numberOfValues=_ptrField->getNumberOfValues(); std::list< SDForSorting > li; const double * coord; - FIELD * barycenterField=0; + FIELD * barycenterField=0; + ArrayDoubleNo * baryArrayTmp = NULL; double * xyz[SPACEDIMENSION]; bool deallocateXyz=false; - if(_support->getEntity()==MED_EN::MED_NODE) - { - if (_support->isOnAllElements()) - { - coord=_mesh->getCoordinates(MED_EN::MED_NO_INTERLACE); - for(i=0; igetCoordinates(MED_EN::MED_FULL_INTERLACE); - const int * nodesNumber=_support->getNumber(MED_EN::MED_ALL_ELEMENTS); - for(i=0; igetBarycenter(_support); - coord=barycenterField->getValue(MED_EN::MED_NO_INTERLACE); + + if(_support->getEntity()==MED_EN::MED_NODE) { + if (_support->isOnAllElements()) { + + coord=_mesh->getCoordinates(MED_EN::MED_NO_INTERLACE); for(i=0; igetCoordinates(MED_EN::MED_FULL_INTERLACE); + const int * nodesNumber=_support->getNumber(MED_EN::MED_ALL_ELEMENTS); + for(i=0; igetValue(MED_EN::MED_FULL_INTERLACE); + } else { + + barycenterField = _mesh->getBarycenter(_support); + baryArrayTmp = ArrayConvert + ( *( static_cast(barycenterField->getArray()) ) ); + coord = baryArrayTmp->getPtr(); + for(i=0; igetInterlacingType() == MED_EN::MED_FULL_INTERLACE ) + valsToSet= _ptrField->getValue(); + else { + tmpArray = ArrayConvert + ( *( static_cast(_ptrField->getArray()) ) ); + valsToSet= tmpArray->getPtr(); + } double temp[SPACEDIMENSION]; - for(i=0;i(temp,valsToSet+i*_nbComponents,_nbComponents)); - } - if(barycenterField) - delete barycenterField; + for(i=0;i(temp,valsToSet+i*_nbComponents,_nbComponents)); + } + + if (barycenterField) delete barycenterField; + if (baryArrayTmp) delete baryArrayTmp; + if (tmpArray) delete tmpArray; + if(deallocateXyz) for(j=0;j >::iterator iter; - for(iter=li.begin();iter!=li.end();iter++) - (*iter).writeLine(_file); - _file << endl; - } - else if(_direc==MED_EN::DESCENDING) - { - typename std::list< SDForSorting >::reverse_iterator iter; - for(iter=li.rbegin();iter!=li.rend();iter++) - (*iter).writeLine(_file); - _file << endl; - } - else + if(_direc==MED_EN::ASCENDING) { + typename std::list< SDForSorting >::iterator iter; + for(iter=li.begin();iter!=li.end();iter++) + (*iter).writeLine(_file); + _file << endl; + } else if (_direc==MED_EN::DESCENDING) { + + typename std::list< SDForSorting >::reverse_iterator iter; + for(iter=li.rbegin();iter!=li.rend();iter++) + (*iter).writeLine(_file); + _file << endl; + } else MEDEXCEPTION("ASCII_FIELD_DRIVER : Invalid sort direction"); } + //{ //_nbComponentsForCpyInfo=_nbComponents; //_ptrField->fillFromAnalytic ::copyInfo3> (); diff --git a/src/MEDMEM/MEDMEM_Connectivity.cxx b/src/MEDMEM/MEDMEM_Connectivity.cxx index 20a85aede..031b3535e 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.cxx +++ b/src/MEDMEM/MEDMEM_Connectivity.cxx @@ -1928,8 +1928,14 @@ int **CONNECTIVITY::getNodesPerFaceOfPolyhedron(int polyhedronId, int& nbOfFaces int CONNECTIVITY::getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const { + SCRUTE(_entity); + SCRUTE(Entity); if (_entity==Entity) - return _numberOfTypes+getNumberOfPolyType(); + { + SCRUTE(_numberOfTypes); + SCRUTE(getNumberOfPolyType()); + return _numberOfTypes+getNumberOfPolyType(); + } else if (_constituent!=NULL) return _constituent->getNumberOfTypesWithPoly(Entity); else diff --git a/src/MEDMEM/MEDMEM_DriverFactory.hxx b/src/MEDMEM/MEDMEM_DriverFactory.hxx index ef7ad141e..90e524d74 100644 --- a/src/MEDMEM/MEDMEM_DriverFactory.hxx +++ b/src/MEDMEM/MEDMEM_DriverFactory.hxx @@ -24,12 +24,13 @@ #include "MEDMEM_GenDriver.hxx" #include "MEDMEM_define.hxx" +#include "MEDMEM_FieldForward.hxx" + #include namespace MEDMEM { class MESH; - template class FIELD; class MED; class GENDRIVER; @@ -50,10 +51,11 @@ namespace MEDMEM { const std::string & fileName, MESH *mesh,const string & driverName, MED_EN::med_mode_acces access); - template + + template GENDRIVER * buildDriverForField(driverTypes driverType, const std::string & fileName, - FIELD *fielde, + FIELD *fielde, MED_EN::med_mode_acces access); GENDRIVER * buildDriverForMed(driverTypes driverType, const std::string & fileName, @@ -65,18 +67,18 @@ namespace MEDMEM { GENDRIVER * buildMeshDriverFromFile(const string & fileName, MESH * ptrMesh, MED_EN::med_mode_acces access); - template + template GENDRIVER * buildFieldDriverFromFile(const string & fileName, - FIELD * ptrField, + FIELD * ptrField, MED_EN::med_mode_acces access); GENDRIVER * buildConcreteMedDriverForMesh(const std::string & fileName, MESH *mesh, const string & driverName, MED_EN::med_mode_acces access, MED_EN::medFileVersion version); - template + template GENDRIVER * buildConcreteMedDriverForField(const std::string & fileName, - FIELD *fielde, + FIELD *fielde, MED_EN::med_mode_acces access, MED_EN::medFileVersion version); } @@ -89,10 +91,10 @@ namespace MEDMEM { #include "MEDMEM_AsciiFieldDriver.hxx" namespace MEDMEM { - template + template GENDRIVER * DRIVERFACTORY::buildDriverForField(driverTypes driverType, const std::string & fileName, - FIELD *field, + FIELD *field, MED_EN::med_mode_acces access) { GENDRIVER *ret; @@ -173,9 +175,9 @@ namespace MEDMEM { return ret; } - template + template GENDRIVER * DRIVERFACTORY::buildFieldDriverFromFile(const string & fileName, - FIELD * ptrField, + FIELD * ptrField, MED_EN::med_mode_acces access) { MED_EN::medFileVersion version; @@ -221,9 +223,9 @@ namespace MEDMEM { } } - template + template GENDRIVER * DRIVERFACTORY::buildConcreteMedDriverForField(const std::string & fileName, - FIELD *ptrField, + FIELD *ptrField, MED_EN::med_mode_acces access, MED_EN::medFileVersion version) { diff --git a/src/MEDMEM/MEDMEM_DriverTools.cxx b/src/MEDMEM/MEDMEM_DriverTools.cxx index de91a8665..e3b468a64 100644 --- a/src/MEDMEM/MEDMEM_DriverTools.cxx +++ b/src/MEDMEM/MEDMEM_DriverTools.cxx @@ -22,6 +22,7 @@ #include "MEDMEM_Exception.hxx" #include "MEDMEM_Mesh.hxx" #include "MEDMEM_Group.hxx" +#include "MEDMEM_Field.hxx" #include #include diff --git a/src/MEDMEM/MEDMEM_DriverTools.hxx b/src/MEDMEM/MEDMEM_DriverTools.hxx index 8d3c5ff00..84a0e4178 100644 --- a/src/MEDMEM/MEDMEM_DriverTools.hxx +++ b/src/MEDMEM/MEDMEM_DriverTools.hxx @@ -20,10 +20,10 @@ #ifndef DRIVERTOOLS_HXX #define DRIVERTOOLS_HXX - #include "MEDMEM_define.hxx" #include "MEDMEM_Exception.hxx" -#include "MEDMEM_Field.hxx" +#include "MEDMEM_FieldForward.hxx" +#include "MEDMEM_ArrayInterface.hxx" #include #include #include @@ -38,6 +38,7 @@ class CONNECTIVITY; class COORDINATE; class GROUP; class FAMILY; +class FIELD_; struct _noeud { mutable int number; @@ -202,7 +203,7 @@ std::list > _field< T >::getField(std::vector<_groupe> if ( !grp || grp->empty() ) return res; } - FIELD< T > * f = 0; + FIELD< T, NoInterlace > * f = 0; int i_comp_tot = 0, nb_fields = 0; std::set supp_id_set; // loop on subs of this field @@ -225,12 +226,12 @@ std::list > _field< T >::getField(std::vector<_groupe> { supp_id_set.clear(); ++nb_fields; - f = new FIELD< T >; + f = new FIELD< T, NoInterlace >(); f->setNumberOfComponents( sub_data->nbComponents() ); f->setComponentsNames( & sub_data->_comp_names[ 0 ] ); f->setNumberOfValues ( nb_val ); f->setName( _name ); - f->setValueType( _type ); + // f->setValueType( _type ); vector str( sub_data->nbComponents() ); f->setComponentsDescriptions( &str[0] ); f->setMEDComponentsUnits( &str[0] ); @@ -238,9 +239,10 @@ std::list > _field< T >::getField(std::vector<_groupe> MESSAGE(" MAKE " << nb_fields << "-th field <" << _name << "> on group_id " << _group_id ); } // set values - MEDARRAY< T > * medarray = - new MEDARRAY< T >( sub_data->nbComponents(), nb_val, MED_EN::MED_NO_INTERLACE ); - f->setValue( medarray ); + MEDMEM_Array< T, NoInterlaceNoGaussPolicy > * medarray = + new MEDMEM_Array < T, NoInterlaceNoGaussPolicy >( sub_data->nbComponents(), + nb_val ); + f->setArray( medarray ); // loop on components of a sub for ( int i_comp = 0; i_comp < sub_data->nbComponents(); ++i_comp ) { diff --git a/src/MEDMEM/MEDMEM_Exception.hxx b/src/MEDMEM/MEDMEM_Exception.hxx index fa791b179..de705c3a8 100644 --- a/src/MEDMEM/MEDMEM_Exception.hxx +++ b/src/MEDMEM/MEDMEM_Exception.hxx @@ -31,7 +31,7 @@ using namespace std; #ifndef LOCALIZED -#define LOCALIZED(message) message , __FILE__ , __LINE__ +#define LOCALIZED(message) static_cast (message) , __FILE__ , __LINE__ #endif #define MED_EXCEPTION MEDEXCEPTION diff --git a/src/MEDMEM/MEDMEM_Family.cxx b/src/MEDMEM/MEDMEM_Family.cxx index 8efe4e292..5c55b1167 100644 --- a/src/MEDMEM/MEDMEM_Family.cxx +++ b/src/MEDMEM/MEDMEM_Family.cxx @@ -36,9 +36,7 @@ using namespace MED_EN; #define MED_TAILLE_DESC 200 #define MED_TAILLE_LNOM 80 -FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0), - _attributeIdentifier((int*)NULL),_attributeValue((int*)NULL), _attributeDescription((string*)NULL), - _numberOfGroup(0), _groupName((string*)NULL) +FAMILY::FAMILY():_identifier(0), _numberOfAttribute(0), _numberOfGroup(0) { MESSAGE("FAMILY::FAMILY()"); }; @@ -58,20 +56,27 @@ FAMILY::FAMILY(MESH* Mesh, int Identifier, string Name, int NumberOfAttribute, MESSAGE("FAMILY(int Identifier, string Name, int NumberOfAttribute,int *AttributeIdentifier,int *AttributeValue,string AttributeDescription,int NumberOfGroup,string GroupName, int ** Number) : "< 0) + { + _attributeIdentifier.set(_numberOfAttribute,AttributeIdentifier); + _attributeValue.set(_numberOfAttribute,AttributeValue); + + _attributeDescription.set(_numberOfAttribute); + for (int i=0;iaddReference(); } +FIELD_& FIELD_::operator=(const FIELD_ &m) { + + if ( this == &m) return *this; + + _isRead = m._isRead ; + _name = m._name; + _description = m._description; + _support = m._support; //Cf Opérateur de recopie du Support? + _numberOfComponents = m._numberOfComponents; + _numberOfValues = m._numberOfValues; + + if (m._componentsTypes != NULL) { + _componentsTypes = new int[m._numberOfComponents] ; + memcpy(_componentsTypes,m._componentsTypes,sizeof(int)*m._numberOfComponents); + } else + _componentsTypes = (int *) NULL; + + _componentsNames = new string[m._numberOfComponents]; + for (int i=0; i + + //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor ! + + return *this; +} + FIELD_::FIELD_(const FIELD_ &m) { _isRead = m._isRead ; @@ -72,7 +119,9 @@ FIELD_::FIELD_(const FIELD_ &m) _numberOfComponents = m._numberOfComponents; _numberOfValues = m._numberOfValues; copyGlobalInfo(m); - _valueType = m._valueType; + //_valueType = m._valueType; + // _valueType et _interlacingType doivent uniquement être recopiés + // par l'opérateur de recopie de FIELD //_drivers = m._drivers ; // PG : Well, same driver, what about m destructor ! } @@ -204,6 +253,10 @@ void FIELD_::_checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool che string diagnosis; // check-up, fill diagnosis if some incompatibility is found. + + // Ne pas vérifier l'entrelacement + // Le compilo s'en occupe Rmq from EF + if(m._support != n._support) { if(!(*m._support==*n._support)) @@ -211,6 +264,8 @@ void FIELD_::_checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool che } else if(m._numberOfComponents != n._numberOfComponents) diagnosis+="They don't have the same number of components!"; + else if (m._valueType != n._valueType) + diagnosis+="They don't have the same type!"; else if(m._numberOfValues != n._numberOfValues) diagnosis+="They don't have the same number of values!"; else @@ -254,12 +309,18 @@ void FIELD_::_deepCheckFieldCompatibility(const FIELD_& m, const FIELD_& n , boo { string diagnosis; - // check-up, fill diagnosis if some incompatibility is found. + // check-up, fill diagnosis if some incompatibility is found. + + // Ne pas vérifier l'entrelacement + // Le compilo s'en occupe Rmq from EF + if(m._support != n._support) { if(!(m._support->deepCompare(*n._support))) diagnosis+="They don't have the same support!"; } + else if (m._valueType != n._valueType) + diagnosis+="They don't have the same type!"; else if(m._numberOfComponents != n._numberOfComponents) diagnosis+="They don't have the same number of components!"; else if(m._numberOfValues != n._numberOfValues) diff --git a/src/MEDMEM/MEDMEM_Field.hxx b/src/MEDMEM/MEDMEM_Field.hxx index 4c80219a1..d3c0f1148 100644 --- a/src/MEDMEM/MEDMEM_Field.hxx +++ b/src/MEDMEM/MEDMEM_Field.hxx @@ -35,8 +35,10 @@ #include "MEDMEM_define.hxx" #include "MEDMEM_Support.hxx" #include "MEDMEM_Unit.hxx" -#include "MEDMEM_Array.hxx" +#include "MEDMEM_nArray.hxx" #include "MEDMEM_GenDriver.hxx" +#include "MEDMEM_ArrayInterface.hxx" +#include "MEDMEM_FieldForward.hxx" /*! @@ -49,10 +51,22 @@ namespace MEDMEM { - template class FIELD; - -class FIELD_ // GENERIC POINTER TO a template class FIELD -{ + template < typename T > struct SET_VALUE_TYPE { + static const MED_EN::med_type_champ _valueType = MED_EN::MED_UNDEFINED_TYPE;}; + template < > struct SET_VALUE_TYPE { + static const MED_EN::med_type_champ _valueType = MED_EN::MED_REEL64; }; + template < > struct SET_VALUE_TYPE { + static const MED_EN::med_type_champ _valueType = MED_EN::MED_INT32; }; + + template < typename T > struct SET_INTERLACING_TYPE { + static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_UNDEFINED_INTERLACE; }; + template < > struct SET_INTERLACING_TYPE{ + static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_FULL_INTERLACE; }; + template < > struct SET_INTERLACING_TYPE { + static const MED_EN::medModeSwitch _interlacingType = MED_EN::MED_NO_INTERLACE; }; + +class FIELD_ // GENERIC POINTER TO a template class FIELD +{ // ùpihjpmoçhmpç_hmù protected: bool _isRead ; @@ -133,16 +147,40 @@ protected: \endif */ string * _MEDComponentsUnits; + /*! + \if developper + Iteration number of the field. + \endif + */ int _iterationNumber ; + /*! + \if developper + Time of the field. + \endif + */ double _time; + /*! + \if developper + Order number of the field. + \endif + */ int _orderNumber ; - - // _valueType should be a static const. Here is an initialization exemple - // template < classType T > struct SET_VALUE_TYPE { static const med_type_champ _valueType = 0; } - // template < > struct SET_VALUE_TYPE { static const med_type_champ _valueType = MED_EN::MED_REEL64; } - // template < > struct SET_VALUE_TYPE { static const med_type_champ _valueType = MED_EN::MED_INT32; } - // static const med_type_champ _valueType = SET_VALUE_TYPE ::_valueType; + /*! + \if developper + At the initialization step of the field using the constructors; this attribute, + the value type (integer or real) , is set automatically. There is a get method + but not a set method for this attribute. + \endif + */ MED_EN::med_type_champ _valueType ; + /*! + \if developper + At the initialization step of the field using the constructors; this attribute, + the interlacing type (full interlace or no interlace field value storage), is set + automatically. There is a get method but not a set method for this attribute. + \endif + */ + MED_EN::medModeSwitch _interlacingType; vector _drivers; // Storage of the drivers currently in use static void _checkFieldCompatibility(const FIELD_& m, const FIELD_& n, bool checkUnit=true) throw (MEDEXCEPTION); @@ -179,9 +217,7 @@ public: */ virtual ~FIELD_(); -// virtual void setIterationNumber (int IterationNumber); -// virtual void setOrderNumber (int OrderNumber); -// virtual void setFieldName (string& fieldName); + FIELD_& operator=(const FIELD_ &m); virtual void rmDriver(int index=0); virtual int addDriver(driverTypes driverType, @@ -237,8 +273,9 @@ public: inline void setOrderNumber(int OrderNumber); inline int getOrderNumber() const; - inline void setValueType (const MED_EN::med_type_champ ValueType) ; inline MED_EN::med_type_champ getValueType () const; + inline MED_EN::medModeSwitch getInterlacingType() const; + virtual inline bool getGaussPresence() const throw (MEDEXCEPTION); protected: void copyGlobalInfo(const FIELD_& m); }; @@ -543,15 +580,25 @@ inline MED_EN::med_type_champ FIELD_::getValueType () const { return _valueType ; } + /*! - Set the FIELD med value type (MED_INT32 or MED_REEL64). + Get the FIELD med interlacing type (MED_FULL_INTERLACE or MED_NO_INTERLACE). */ -inline void FIELD_::setValueType (const MED_EN::med_type_champ ValueType) + inline MED_EN::medModeSwitch FIELD_::getInterlacingType () const { - _valueType = ValueType ; + return _interlacingType ; } -}//End namespace MEDMEM +/*! + Get the FIELD gauss presence. +*/ + inline bool FIELD_::getGaussPresence() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD_::getGaussPresence() : "; + throw MEDEXCEPTION(STRING(LOC) << " This FIELD_ doesn't rely on a FIELD" ); +} + +} //End namespace MEDMEM ///////////////////////// // END OF CLASS FIELD_ // @@ -560,7 +607,8 @@ inline void FIELD_::setValueType (const MED_EN::med_type_champ ValueType) /*! This template class contains informations related with a FIELD : - - Values of the field + - Values of the field, their type (real or integer), the storage mode (full interlace or + no interlace). */ @@ -572,37 +620,49 @@ namespace MEDMEM { template class MED_FIELD_WRONLY_DRIVER22; template class VTK_FIELD_DRIVER; -template class FIELD : public FIELD_ + template class FIELD : public FIELD_ { protected: - // ------ End of Drivers Management Part + + typedef typename MEDMEM_ArrayInterface::Array ArrayNoGauss; + typedef typename MEDMEM_ArrayInterface::Array ArrayGauss; + typedef typename MEDMEM_ArrayInterface::Array ArrayNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayFull; + typedef MEDMEM_Array_ Array; // array of value of type T - MEDARRAY *_value ; + Array *_value ; static T _scalarForPow; static T pow(T x); private: - void _operation(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode, char* Op); + void _operation(const FIELD& m,const FIELD& n, char* Op); void _operationInitialize(const FIELD& m,const FIELD& n, char* Op); - void _add_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode); - void _sub_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode); - void _mul_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode); - void _div_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode) throw (MEDEXCEPTION); + void _add_in_place(const FIELD& m,const FIELD& n); + void _sub_in_place(const FIELD& m,const FIELD& n); + void _mul_in_place(const FIELD& m,const FIELD& n); + void _div_in_place(const FIELD& m,const FIELD& n) throw (MEDEXCEPTION); //setValueType() ; - FIELD & operator=(const FIELD &m); // A FAIRE public: FIELD(); FIELD(const FIELD &m); - FIELD(const SUPPORT * Support, const int NumberOfComponents, const MED_EN::medModeSwitch Mode=MED_EN::MED_FULL_INTERLACE) throw (MEDEXCEPTION) ; // Ajout NB Constructeur FIELD avec allocation de memoire de tous ses attribut + FIELD(const SUPPORT * Support, const int NumberOfComponents) throw (MEDEXCEPTION) ; + FIELD( driverTypes driverType, + const string & fileName, const string & fieldDriverName, + const int iterationNumber=-1, const int orderNumber=-1) + throw (MEDEXCEPTION); FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName="", const string & fieldName="", const int iterationNumber = -1, const int orderNumber = -1) throw (MEDEXCEPTION); ~FIELD(); + FIELD & operator=(const FIELD &m); + const FIELD operator+(const FIELD& m) const; const FIELD operator-(const FIELD& m) const; const FIELD operator*(const FIELD& m) const; @@ -626,10 +686,10 @@ public: template void applyFunc(); void applyPow(T scalar); static FIELD* scalarProduct(const FIELD& m, const FIELD& n, bool deepCheck=false); - double normL2(int component, const FIELD * p_field_volume=NULL) const; - double normL2(const FIELD * p_field_volume=NULL) const; - double normL1(int component, const FIELD * p_field_volume=NULL) const; - double normL1(const FIELD * p_field_volume=NULL) const; + double normL2(int component, const FIELD * p_field_volume=NULL) const; + double normL2(const FIELD * p_field_volume=NULL) const; + double normL1(int component, const FIELD * p_field_volume=NULL) const; + double normL1(const FIELD * p_field_volume=NULL) const; FIELD* extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION); friend class MED_FIELD_RDONLY_DRIVER21; @@ -661,18 +721,23 @@ public: inline void writeAppend(int index=0, const string & driverName = ""); inline void writeAppend(const GENDRIVER &); - inline void setValue(MEDARRAY *Value); + inline MEDMEM_Array_ * getArray() const throw (MEDEXCEPTION); + inline ArrayGauss * getArrayGauss() const throw (MEDEXCEPTION); + inline ArrayNoGauss * getArrayNoGauss() const throw (MEDEXCEPTION); + inline bool getGaussPresence() const throw (MEDEXCEPTION); - inline MEDARRAY* getvalue() const; - inline int getValueLength(MED_EN::medModeSwitch Mode) const; - inline const T* getValue(MED_EN::medModeSwitch Mode) const; - inline const T* getValueI(MED_EN::medModeSwitch Mode,int i) const; - inline T getValueIJ(int i,int j) const; - bool getValueOnElement(int eltIdInSup,T* retValues) const; + inline int getValueLength() const throw (MEDEXCEPTION); + inline const T* getValue() const throw (MEDEXCEPTION); + inline const T* getRow(int i) const throw (MEDEXCEPTION); + inline const T* getColumn(int j) const throw (MEDEXCEPTION); + inline T getValueIJ(int i,int j) const throw (MEDEXCEPTION); + bool getValueOnElement(int eltIdInSup,T* retValues) const throw (MEDEXCEPTION); - inline void setValue(MED_EN::medModeSwitch mode, T* value); - inline void setValueI(MED_EN::medModeSwitch mode, int i, T* value); - inline void setValueIJ(int i, int j, T value); + inline void setArray(MEDMEM_Array_ *value) throw (MEDEXCEPTION); + inline void setValue( T* value) throw (MEDEXCEPTION); + inline void setRow( int i, T* value) throw (MEDEXCEPTION); + inline void setColumn( int i, T* value) throw (MEDEXCEPTION); + inline void setValueIJ(int i, int j, T value) throw (MEDEXCEPTION); /*! This fonction feeds the FIELD private attributs _value with the @@ -680,8 +745,7 @@ public: initialised via the constructor FIELD(const SUPPORT * , const int ) with Support as SUPPORT argument, 1 has the number of components, and Support has be a SUPPORT on 3D cells. This initialisation could be done by the empty - constructor followed by a setSupport and setNumberOfComponents call but it has - be followed by a setValueType(MED_REEL64) call. + constructor followed by a setSupport and setNumberOfComponents call. */ void getVolume() const throw (MEDEXCEPTION) ; /*! @@ -690,8 +754,7 @@ public: has to be initialised via the constructor FIELD(const SUPPORT * , const int ) with 1 has the number of components, and _support has be a SUPPORT on 2D cells or 3D faces. This initialisation could be done by the - empty constructor followed by a setSupport and setNumberOfComponents call but - it has be followed by a setValueType(MED_REEL64) call. + empty constructor followed by a setSupport and setNumberOfComponents call. */ void getArea() const throw (MEDEXCEPTION) ; /*! @@ -700,8 +763,7 @@ public: to be initialised via the constructor FIELD(const SUPPORT * , const int ) with 1 has the number of components, and _support has be a SUPPORT on 3D edges or 2D faces. This initialisation could be done by the - empty constructor followed by a setSupport and setNumberOfComponents call but - it has be followed by a setValueType(MED_REEL64) call. + empty constructor followed by a setSupport and setNumberOfComponents call. */ void getLength() const throw (MEDEXCEPTION) ; /*! @@ -711,7 +773,7 @@ public: const int ) with the space dimension has the number of components, and _support has be a SUPPORT on 3D or 2D faces. This initialisation could be done by the empty constructor followed by a setSupport and setNumberOfComponents - call but it has be followed by a setValueType(MED_REEL64) call. + call. */ void getNormal() const throw (MEDEXCEPTION) ; /*! @@ -721,12 +783,12 @@ public: FIELD(const SUPPORT * ,const int ) with the space dimension has the number of components, and _support has be a SUPPORT on 3D cells or 2D faces. This initialisation could be done by the empty constructor followed by a - setSupport and setNumberOfComponents call but it has be followed by a - setValueType(MED_REEL64) call. + setSupport and setNumberOfComponents call. */ void getBarycenter() const throw (MEDEXCEPTION) ; - template - void fillFromAnalytic(); + + typedef void (*myFuncType)(const double *,T*); + void fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION); }; } @@ -734,7 +796,7 @@ public: namespace MEDMEM { -template T FIELD::_scalarForPow=1; +template T FIELD::_scalarForPow=1; // -------------------- // Implemented Methods @@ -743,63 +805,88 @@ template T FIELD::_scalarForPow=1; /*! Constructor with no parameter, most of the attribut members are set to NULL. */ -template FIELD::FIELD(): - _value((MEDARRAY*)NULL) +template +FIELD::FIELD():FIELD_() { MESSAGE("Constructeur FIELD sans parametre"); + + //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE); + FIELD_::_valueType=SET_VALUE_TYPE::_valueType; + + //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE); + FIELD_::_interlacingType=SET_INTERLACING_TYPE::_interlacingType; + + _value = ( ArrayNoGauss * ) NULL; } /*! Constructor with parameters such that all attrribut are set but the _value attribut is allocated but not set. */ -template FIELD::FIELD(const SUPPORT * Support, - const int NumberOfComponents, const MED_EN::medModeSwitch Mode) throw (MEDEXCEPTION) : - FIELD_(Support, NumberOfComponents) +template +FIELD::FIELD(const SUPPORT * Support, + const int NumberOfComponents) throw (MEDEXCEPTION) : + FIELD_(Support, NumberOfComponents),_value() { - BEGIN_OF("FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents, const medModeSwitch Mode)"); + BEGIN_OF("FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents)"); SCRUTE(this); + //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE) + FIELD_::_valueType=SET_VALUE_TYPE::_valueType; + + //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE) + FIELD_::_interlacingType=SET_INTERLACING_TYPE::_interlacingType; + try { + // becarefull about the numbre of gauss point _numberOfValues = Support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); } catch (MEDEXCEPTION &ex) { MESSAGE("No value defined ! ("<*)NULL ; } MESSAGE("FIELD : constructeur : "<< _numberOfValues <<" et "<< NumberOfComponents); if (0<_numberOfValues) { - _value = new MEDARRAY(_numberOfComponents,_numberOfValues,Mode); + _value = new ArrayNoGauss (_numberOfComponents,_numberOfValues); _isRead = true ; - } else - _value = (MEDARRAY*)NULL ; + } - END_OF("FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents, const medModeSwitch Mode)"); + END_OF("FIELD::FIELD(const SUPPORT * Support, const int NumberOfComponents)"); } /*! \if developper \endif */ -template void FIELD::init () +template void FIELD::init () { } /*! Copy constructor. */ -template FIELD::FIELD(const FIELD & m): +template FIELD::FIELD(const FIELD & m): FIELD_((FIELD_) m) { MESSAGE("Constructeur FIELD de recopie"); + + // RECOPIE PROFOND Rmq from EF if (m._value != NULL) { - // copie only default ! - _value = new MEDARRAY(* m._value,false); + if ( m.getGaussPresence() ) + _value = new ArrayGauss( *(dynamic_cast< ArrayGauss * > (m._value) ) ,false); + else + _value = new ArrayNoGauss( *(dynamic_cast< ArrayNoGauss * > (m._value)) ,false); } else - _value = (MEDARRAY *) NULL; - //_drivers = m._drivers; + _value = (ArrayNoGauss *) NULL; + + _valueType = m._valueType; + _interlacingType = m._interlacingType; + //drivers = m._drivers; } /*! @@ -807,12 +894,20 @@ template FIELD::FIELD(const FIELD & m): Not implemented. \endif */ -template FIELD & FIELD::operator=(const FIELD &m) +template +FIELD & FIELD::operator=(const FIELD &m) { MESSAGE("Appel de FIELD::operator=") ; - // operator= on FIELD_ - // ignore driver + if ( this == &m) return *this; + // copy values array + FIELD_::operator=(m); // Driver are ignored & ?copie su pointeur de Support? + + _value = m._value; //PROBLEME RECOPIE DES POINTEURS PAS COHERENT AVEC LE + //CONSTRUCTEUR PAR RECOPIE + //CF :Commentaire dans MEDMEM_Array + _valueType = m._valueType; + _interlacingType = m._interlacingType; } /*! @@ -835,24 +930,17 @@ template FIELD & FIELD::operator=(const FIELD &m) no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ -template -const FIELD FIELD::operator+(const FIELD & m) const +template +const FIELD FIELD::operator+(const FIELD & m) const { BEGIN_OF("FIELD::operator+(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=this->getvalue()->getMode(); - // Creation of the result - memory is allocated by FIELD constructor - FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); + FIELD result(this->getSupport(),this->getNumberOfComponents()); //result._operation(*this,m,mode,"+"); // perform Atribute's initialization & addition result._operationInitialize(*this,m,"+"); // perform Atribute's initialization - result._add_in_place(*this,m,mode); // perform addition + result._add_in_place(*this,m); // perform addition END_OF("FIELD::operator+(const FIELD & m)"); return result; @@ -862,24 +950,20 @@ const FIELD FIELD::operator+(const FIELD & m) const * Operations are directly performed in the first field's array. * This operation is authorized only for compatible fields that have the same support. */ -template -FIELD& FIELD::operator+=(const FIELD & m) +template +FIELD& FIELD::operator+=(const FIELD & m) { BEGIN_OF("FIELD::operator+=(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - // We choose to keep *this mode, even if it may cost a re-calculation for m - MED_EN::medModeSwitch mode=this->getvalue()->getMode(); - const T* value1=m.getValue(mode); // get pointers to the values we are adding + const T* value1=m.getValue(); // get pointers to the values we are adding // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array const T* endV=value+size; // pointer to the end of value for(;value!=endV; value1++,value++) *value += *value1; - // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore - this->getvalue()->clearOtherMode(); END_OF("FIELD::operator+=(const FIELD & m)"); return *this; } @@ -890,23 +974,17 @@ FIELD& FIELD::operator+=(const FIELD & m) * Data members are checked for compatibility and initialized. * The user is in charge of memory deallocation. */ -template -FIELD* FIELD::add(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::add(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::add(const FIELD & m, const FIELD& n)"); FIELD_::_checkFieldCompatibility(m, n); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"+"); // perform Atribute's initialization - result->_add_in_place(m,n,mode); // perform addition + result->_add_in_place(m,n); // perform addition END_OF("FIELD::add(const FIELD & m, const FIELD& n)"); return result; @@ -914,23 +992,17 @@ FIELD* FIELD::add(const FIELD& m, const FIELD& n) /*! Same as add method except that field check is deeper. */ -template -FIELD* FIELD::addDeep(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::addDeep(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::addDeep(const FIELD & m, const FIELD& n)"); FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"+"); // perform Atribute's initialization - result->_add_in_place(m,n,mode); // perform addition + result->_add_in_place(m,n); // perform addition END_OF("FIELD::addDeep(const FIELD & m, const FIELD& n)"); return result; @@ -956,36 +1028,29 @@ FIELD* FIELD::addDeep(const FIELD& m, const FIELD& n) no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ -template -const FIELD FIELD::operator-(const FIELD & m) const +template +const FIELD FIELD::operator-(const FIELD & m) const { BEGIN_OF("FIELD::operator-(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - MED_EN::medModeSwitch mode; - if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=this->getvalue()->getMode(); - // Creation of the result - memory is allocated by FIELD constructor - FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); + FIELD result(this->getSupport(),this->getNumberOfComponents()); //result._operation(*this,m,mode,"-"); // perform Atribute's initialization & substraction result._operationInitialize(*this,m,"-"); // perform Atribute's initialization - result._sub_in_place(*this,m,mode); // perform substracion + result._sub_in_place(*this,m); // perform substracion END_OF("FIELD::operator-(const FIELD & m)"); return result; } -template -const FIELD FIELD::operator-() const +template +const FIELD FIELD::operator-() const { BEGIN_OF("FIELD::operator-()"); - MED_EN::medModeSwitch mode=this->getvalue()->getMode(); // Creation of the result - memory is allocated by FIELD constructor - FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); + FIELD result(this->getSupport(),this->getNumberOfComponents()); // Atribute's initialization result.setName("- "+getName()); result.setComponentsNames(getComponentsNames()); @@ -996,11 +1061,10 @@ const FIELD FIELD::operator-() const result.setIterationNumber(getIterationNumber()); result.setTime(getTime()); result.setOrderNumber(getOrderNumber()); - result.setValueType(getValueType()); - const T* value1=getValue(mode); + const T* value1=getValue(); // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (result.getValue(mode)); + T * value=const_cast (result.getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array const T* endV=value+size; // pointer to the end of value @@ -1014,25 +1078,22 @@ const FIELD FIELD::operator-() const * Operations are directly performed in the first field's array. * This operation is authorized only for compatible fields that have the same support. */ -template -FIELD& FIELD::operator-=(const FIELD & m) +template +FIELD& FIELD::operator-=(const FIELD & m) { BEGIN_OF("FIELD::operator-=(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m); // may throw exception - // We choose to keep *this mode, even if it may cost a re-calculation for m - MED_EN::medModeSwitch mode=this->getvalue()->getMode(); - const T* value1=m.getValue(mode); // get pointers to the values we are adding + const T* value1=m.getValue(); // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array const T* endV=value+size; // pointer to the end of value for(;value!=endV; value1++,value++) *value -= *value1; - // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore - this->getvalue()->clearOtherMode(); + END_OF("FIELD::operator-=(const FIELD & m)"); return *this; } @@ -1043,23 +1104,17 @@ FIELD& FIELD::operator-=(const FIELD & m) * Data members are checked for compatibility and initialized. * The user is in charge of memory deallocation. */ -template -FIELD* FIELD::sub(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::sub(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::sub(const FIELD & m, const FIELD& n)"); FIELD_::_checkFieldCompatibility(m, n); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"-"); // perform Atribute's initialization - result->_sub_in_place(m,n,mode); // perform substraction + result->_sub_in_place(m,n); // perform substraction END_OF("FIELD::sub(const FIELD & m, const FIELD& n)"); return result; @@ -1067,23 +1122,17 @@ FIELD* FIELD::sub(const FIELD& m, const FIELD& n) /*! Same as sub method except that field check is deeper. */ -template -FIELD* FIELD::subDeep(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::subDeep(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::subDeep(const FIELD & m, const FIELD& n)"); FIELD_::_deepCheckFieldCompatibility(m, n); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"-"); // perform Atribute's initialization - result->_sub_in_place(m,n,mode); // perform substraction + result->_sub_in_place(m,n); // perform substraction END_OF("FIELD::subDeep(const FIELD & m, const FIELD& n)"); return result; @@ -1109,24 +1158,17 @@ FIELD* FIELD::subDeep(const FIELD& m, const FIELD& n) no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ -template -const FIELD FIELD::operator*(const FIELD & m) const +template +const FIELD FIELD::operator*(const FIELD & m) const { BEGIN_OF("FIELD::operator*(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=this->getvalue()->getMode(); - // Creation of the result - memory is allocated by FIELD constructor - FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); + FIELD result(this->getSupport(),this->getNumberOfComponents()); //result._operation(*this,m,mode,"*"); // perform Atribute's initialization & multiplication result._operationInitialize(*this,m,"*"); // perform Atribute's initialization - result._mul_in_place(*this,m,mode); // perform multiplication + result._mul_in_place(*this,m); // perform multiplication END_OF("FIELD::operator*(const FIELD & m)"); return result; @@ -1136,25 +1178,22 @@ const FIELD FIELD::operator*(const FIELD & m) const * Operations are directly performed in the first field's array. * This operation is authorized only for compatible fields that have the same support. */ -template -FIELD& FIELD::operator*=(const FIELD & m) +template +FIELD& FIELD::operator*=(const FIELD & m) { BEGIN_OF("FIELD::operator*=(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - // We choose to keep *this mode, even if it may cost a re-calculation for m - MED_EN::medModeSwitch mode=this->getvalue()->getMode(); - const T* value1=m.getValue(mode); // get pointers to the values we are adding + const T* value1=m.getValue(); // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array const T* endV=value+size; // pointer to the end of value for(;value!=endV; value1++,value++) *value *= *value1; - // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore - this->getvalue()->clearOtherMode(); + END_OF("FIELD::operator*=(const FIELD & m)"); return *this; } @@ -1165,23 +1204,17 @@ FIELD& FIELD::operator*=(const FIELD & m) * Data members are checked for compatibility and initialized. * The user is in charge of memory deallocation. */ -template -FIELD* FIELD::mul(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::mul(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::mul(const FIELD & m, const FIELD& n)"); FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"*"); // perform Atribute's initialization - result->_mul_in_place(m,n,mode); // perform multiplication + result->_mul_in_place(m,n); // perform multiplication END_OF("FIELD::mul(const FIELD & m, const FIELD& n)"); return result; @@ -1189,23 +1222,17 @@ FIELD* FIELD::mul(const FIELD& m, const FIELD& n) /*! Same as mul method except that field check is deeper. */ -template -FIELD* FIELD::mulDeep(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::mulDeep(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::mulDeep(const FIELD & m, const FIELD& n)"); FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"*"); // perform Atribute's initialization - result->_mul_in_place(m,n,mode); // perform multiplication + result->_mul_in_place(m,n); // perform multiplication END_OF("FIELD::mulDeep(const FIELD & m, const FIELD& n)"); return result; @@ -1231,24 +1258,17 @@ FIELD* FIELD::mulDeep(const FIELD& m, const FIELD& n) no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ -template -const FIELD FIELD::operator/(const FIELD & m) const +template +const FIELD FIELD::operator/(const FIELD & m) const { BEGIN_OF("FIELD::operator/(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(this->getvalue()->getMode()==m.getvalue()->getMode() || this->getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=this->getvalue()->getMode(); - // Creation of the result - memory is allocated by FIELD constructor - FIELD result(this->getSupport(),this->getNumberOfComponents(),mode); + FIELD result(this->getSupport(),this->getNumberOfComponents()); //result._operation(*this,m,mode,"/"); // perform Atribute's initialization & division result._operationInitialize(*this,m,"/"); // perform Atribute's initialization - result._div_in_place(*this,m,mode); // perform division + result._div_in_place(*this,m); // perform division END_OF("FIELD::operator/(const FIELD & m)"); return result; @@ -1259,25 +1279,22 @@ const FIELD FIELD::operator/(const FIELD & m) const * Operations are directly performed in the first field's array. * This operation is authorized only for compatible fields that have the same support. */ -template -FIELD& FIELD::operator/=(const FIELD & m) +template +FIELD& FIELD::operator/=(const FIELD & m) { BEGIN_OF("FIELD::operator/=(const FIELD & m)"); FIELD_::_checkFieldCompatibility(*this, m, false); // may throw exception - // We choose to keep *this mode, even if it may cost a re-calculation for m - MED_EN::medModeSwitch mode=this->getvalue()->getMode(); - const T* value1=m.getValue(mode); // get pointers to the values we are adding + const T* value1=m.getValue(); // get pointers to the values we are adding // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array const T* endV=value+size; // pointer to the end of value for(;value!=endV; value1++,value++) *value /= *value1; - // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore - this->getvalue()->clearOtherMode(); + END_OF("FIELD::operator/=(const FIELD & m)"); return *this; } @@ -1288,23 +1305,17 @@ FIELD& FIELD::operator/=(const FIELD & m) * Data members are checked for compatibility and initialized. * The user is in charge of memory deallocation. */ -template -FIELD* FIELD::div(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::div(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::div(const FIELD & m, const FIELD& n)"); FIELD_::_checkFieldCompatibility(m, n, false); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"/"); // perform Atribute's initialization - result->_div_in_place(m,n,mode); // perform division + result->_div_in_place(m,n); // perform division END_OF("FIELD::div(const FIELD & m, const FIELD& n)"); return result; @@ -1312,23 +1323,17 @@ FIELD* FIELD::div(const FIELD& m, const FIELD& n) /*! Same as div method except that field check is deeper. */ -template -FIELD* FIELD::divDeep(const FIELD& m, const FIELD& n) +template +FIELD* FIELD::divDeep(const FIELD& m, const FIELD& n) { BEGIN_OF("FIELD::divDeep(const FIELD & m, const FIELD& n)"); FIELD_::_deepCheckFieldCompatibility(m, n, false); // may throw exception - // Select mode : avoid if possible any calculation of other mode for fields m or *this - MED_EN::medModeSwitch mode; - if(m.getvalue()->getMode()==n.getvalue()->getMode() || n.getvalue()->isOtherCalculated()) - mode=m.getvalue()->getMode(); - else - mode=n.getvalue()->getMode(); - // Creation of a new field - FIELD* result = new FIELD(m.getSupport(),m.getNumberOfComponents(),mode); + FIELD* result = new FIELD(m.getSupport(), + m.getNumberOfComponents()); result->_operationInitialize(m,n,"/"); // perform Atribute's initialization - result->_div_in_place(m,n,mode); // perform division + result->_div_in_place(m,n); // perform division END_OF("FIELD::divDeep(const FIELD & m, const FIELD& n)"); return result; @@ -1341,10 +1346,10 @@ FIELD* FIELD::divDeep(const FIELD& m, const FIELD& n) and the operator. \endif */ -template -void FIELD::_operationInitialize(const FIELD& m,const FIELD& n, char* Op) +template +void FIELD::_operationInitialize(const FIELD& m,const FIELD& n, char* Op) { - MESSAGE("Appel methode interne _add" << Op); + MESSAGE("Appel methode interne " << Op); // Atribute's initialization (copy of the first field's attributes) // Other data members (_support, _numberOfValues) are initialized in the field's constr. @@ -1365,7 +1370,6 @@ void FIELD::_operationInitialize(const FIELD& m,const FIELD& n, char* Op) setIterationNumber(m.getIterationNumber()); setTime(m.getTime()); setOrderNumber(m.getOrderNumber()); - setValueType(m.getValueType()); } @@ -1377,14 +1381,14 @@ void FIELD::_operationInitialize(const FIELD& m,const FIELD& n, char* Op) it doesn't exist! \endif */ -template -void FIELD::_add_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode) +template +void FIELD::_add_in_place(const FIELD& m,const FIELD& n) { // get pointers to the values we are adding - const T* value1=m.getValue(mode); - const T* value2=n.getValue(mode); + const T* value1=m.getValue(); + const T* value2=n.getValue(); // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); SCRUTE(size); @@ -1401,14 +1405,14 @@ void FIELD::_add_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod it doesn't exist! \endif */ -template -void FIELD::_sub_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode) +template +void FIELD::_sub_in_place(const FIELD& m,const FIELD& n) { // get pointers to the values we are adding - const T* value1=m.getValue(mode); - const T* value2=n.getValue(mode); + const T* value1=m.getValue(); + const T* value2=n.getValue(); // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); SCRUTE(size); @@ -1425,14 +1429,14 @@ void FIELD::_sub_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod it doesn't exist! \endif */ -template -void FIELD::_mul_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode) +template +void FIELD::_mul_in_place(const FIELD& m,const FIELD& n) { // get pointers to the values we are adding - const T* value1=m.getValue(mode); - const T* value2=n.getValue(mode); + const T* value1=m.getValue(); + const T* value2=n.getValue(); // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); SCRUTE(size); @@ -1449,22 +1453,22 @@ void FIELD::_mul_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod it doesn't exist! \endif */ -template -void FIELD::_div_in_place(const FIELD& m,const FIELD& n, const MED_EN::medModeSwitch mode) throw (MEDEXCEPTION) +template +void FIELD::_div_in_place(const FIELD& m,const FIELD& n) throw (MEDEXCEPTION) { // get pointers to the values we are adding - const T* value1=m.getValue(mode); - const T* value2=n.getValue(mode); + const T* value1=m.getValue(); + const T* value2=n.getValue(); // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); SCRUTE(size); const T* endV1=value1+size; for(;value1!=endV1; value1++,value2++,value++){ - if ( *value2 == 0 ) { + if ( *value2 == 0 ) { // FAIRE PLUTOT UN TRY CATCH Rmq from EF string diagnosis; - diagnosis="FIELD::_div_in_place(...) : Divide by zero !"; + diagnosis="FIELD::_div_in_place(...) : Divide by zero !"; throw MEDEXCEPTION(diagnosis.c_str()); } *value=(*value1)/(*value2); @@ -1473,14 +1477,14 @@ void FIELD::_div_in_place(const FIELD& m,const FIELD& n, const MED_EN::medMod /*! Return Max Norm */ -template double FIELD::normMax() const throw (MEDEXCEPTION) +template double FIELD::normMax() const throw (MEDEXCEPTION) { - const T* value=getValue(getvalue()->getMode()); // get pointer to the values + const T* value=getValue(); // get pointer to the values const int size=getNumberOfValues()*getNumberOfComponents(); if (size <= 0) // Size of array has to be strictly positive { string diagnosis; - diagnosis="FIELD::normMax() : cannot compute the norm of "+getName()+ + diagnosis="FIELD::normMax() : cannot compute the norm of "+getName()+ " : it size is non positive!"; throw MEDEXCEPTION(diagnosis.c_str()); } @@ -1505,14 +1509,14 @@ template double FIELD::normMax() const throw (MEDEXCEPTION) /*! Return Euclidien norm */ -template double FIELD::norm2() const throw (MEDEXCEPTION) +template double FIELD::norm2() const throw (MEDEXCEPTION) { - const T* value=this->getValue(this->getvalue()->getMode()); // get const pointer to the values + const T* value=this->getValue(); // get const pointer to the values const int size=getNumberOfValues()*getNumberOfComponents(); // get size of array if (size <= 0) // Size of array has to be strictly positive { string diagnosis; - diagnosis="FIELD::norm2() : cannot compute the norm of "+getName()+ + diagnosis="FIELD::norm2() : cannot compute the norm of "+getName()+ " : it size is non positive!"; throw MEDEXCEPTION(diagnosis.c_str()); } @@ -1535,13 +1539,11 @@ template double FIELD::norm2() const throw (MEDEXCEPTION) * \code myField.applyFunc(); // apply sqare root function \endcode * \code myField.applyFunc(); // apply your own created function \endcode */ -template template -void FIELD::applyFunc() +template template +void FIELD::applyFunc() { - MED_EN::medModeSwitch mode=getvalue()->getMode(); - - // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (getValue(mode)); + // get a non const pointer to the inside array of values and perform operation + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array if (size>0) // for a negative size, there is nothing to do @@ -1549,14 +1551,12 @@ void FIELD::applyFunc() const T* lastvalue=value+size; // pointer to the end of value for(;value!=lastvalue; ++value) // apply linear transformation *value = T_function(*value); - // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore - getvalue()->clearOtherMode(); } } -template T FIELD::pow(T x) +template T FIELD::pow(T x) { - return (T)::pow(x,FIELD::_scalarForPow); + return (T)::pow(x,FIELD::_scalarForPow); } /*! Apply to each (scalar) field component the math function pow. @@ -1566,21 +1566,19 @@ template T FIELD::pow(T x) * \code myField.applyFunc(); // apply sqare root function \endcode * \code myField.applyFunc(); // apply your own created function \endcode */ -template void FIELD::applyPow(T scalar) +template void FIELD::applyPow(T scalar) { - FIELD::_scalarForPow=scalar; - applyFunc::pow>(); + FIELD::_scalarForPow=scalar; + applyFunc::pow>(); } /*! Apply to each (scalar) field component the linear function x -> ax+b. * calculation is done "in place". */ -template void FIELD::applyLin(T a, T b) +template void FIELD::applyLin(T a, T b) { - MED_EN::medModeSwitch mode=getvalue()->getMode(); - // get a non const pointer to the inside array of values and perform operation in place - T * value=const_cast (getValue(mode)); + T * value=const_cast (getValue()); const int size=getNumberOfValues()*getNumberOfComponents(); // size of array if (size>0) // for a negative size, there is nothing to do @@ -1588,8 +1586,6 @@ template void FIELD::applyLin(T a, T b) const T* lastvalue=value+size; // pointer to the end of value for(;value!=lastvalue; ++value) // apply linear transformation *value = a*(*value)+b; - // if it exists, the alternate mode needs to be cleared because it is not up-to-date anymore - getvalue()->clearOtherMode(); } } @@ -1608,7 +1604,9 @@ template void FIELD::applyLin(T a, T b) * Each value of it is the scalar product of the two argument's fields. * The user is in charge of memory deallocation. */ -template FIELD* FIELD::scalarProduct(const FIELD & m, const FIELD & n, bool deepCheck) +template +FIELD* +FIELD::scalarProduct(const FIELD & m, const FIELD & n, bool deepCheck) { if(!deepCheck) FIELD_::_checkFieldCompatibility( m, n, false); // may throw exception @@ -1616,23 +1614,25 @@ template FIELD* FIELD::scalarProduct(const FIELD & m, const FIEL FIELD_::_deepCheckFieldCompatibility(m, n, false); // we need a MED_FULL_INTERLACE representation of m & n to compute the scalar product - const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE; + // result type imply INTERLACING_TAG=FullInterlace for m & n const int numberOfElements=m.getNumberOfValues(); // strictly positive const int NumberOfComponents=m.getNumberOfComponents(); // strictly positive - // Creation & init of a the result field on the same suppot, with one component - FIELD* result = new FIELD(m.getSupport(),1,mode); + // Creation & init of a the result field on the same support, with one component + // You have to be careful about the interlacing mode, because in the computation step, + // it seems to assume the the interlacing mode is the FullInterlacing + + FIELD* result = new FIELD(m.getSupport(),1); result->setName( "scalarProduct ( " + m.getName() + " , " + n.getName() + " )" ); result->setIterationNumber(m.getIterationNumber()); result->setTime(m.getTime()); result->setOrderNumber(m.getOrderNumber()); - result->setValueType(m.getValueType()); - const T* value1=m.getValue(mode); // get const pointer to the values - const T* value2=n.getValue(mode); // get const pointer to the values + const T* value1=m.getValue(); // get const pointer to the values + const T* value2=n.getValue(); // get const pointer to the values // get a non const pointer to the inside array of values and perform operation - T * value=const_cast (result->getValue(mode)); + T * value=const_cast (result->getValue()); const T* lastvalue=value+numberOfElements; // pointing just after last value of result for ( ; value!=lastvalue ; ++value ) // loop on all elements @@ -1649,19 +1649,32 @@ template FIELD* FIELD::scalarProduct(const FIELD & m, const FIEL * Cannot be applied to a field with a support on nodes. * If the optional p_field_volume argument is furnished, the volume is not re-calculated. */ -template double FIELD::normL2(int component, const FIELD * p_field_volume) const +template +double FIELD::normL2(int component, + const FIELD * p_field_volume) const { _checkNormCompatibility(p_field_volume); // may throw exception if ( component<1 || component>getNumberOfComponents() ) throw MEDEXCEPTION(STRING("FIELD::normL2() : The component argument should be between 1 and the number of components")); - const FIELD * p_field_size=p_field_volume; + const FIELD * p_field_size=p_field_volume; if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] + p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); - const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values + const double* vol=p_field_size->getValue(); + // Il n'est vraiment pas optimal de mixer des champs dans des modes d'entrelacement + // different juste pour le calcul + + const T * value = NULL; + ArrayNo * myArray = NULL; + if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) + value = getValue(); + else { + myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) )); + value = myArray->getPtr(); + } + const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column double integrale=0.0; @@ -1674,6 +1687,7 @@ template double FIELD::normL2(int component, const FIELD * if(!p_field_volume) // if the user didn't supply the volume delete p_field_size; // delete temporary volume field + if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray; if( totVol <= 0) throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); @@ -1684,17 +1698,26 @@ template double FIELD::normL2(int component, const FIELD * * Cannot be applied to a field with a support on nodes. * If the optional p_field_volume argument is furnished, the volume is not re-calculated. */ -template double FIELD::normL2(const FIELD * p_field_volume) const +template +double FIELD::normL2(const FIELD * p_field_volume) const { _checkNormCompatibility(p_field_volume); // may throw exception - const FIELD * p_field_size=p_field_volume; + const FIELD * p_field_size=p_field_volume; if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] + p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); + const double* vol=p_field_size->getValue(); const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol - const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values + + const T * value = NULL; + ArrayNo * myArray = NULL; + if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) + value = getValue(); + else { + myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) )); + value = myArray->getPtr(); + } double totVol=0.0; const double* p_vol=vol; @@ -1708,6 +1731,7 @@ template double FIELD::normL2(const FIELD * p_field_volume) if(!p_field_volume) // if the user didn't supply the volume delete p_field_size; // delete temporary volume field + if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray; if( totVol <= 0) throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); @@ -1718,19 +1742,29 @@ template double FIELD::normL2(const FIELD * p_field_volume) * Cannot be applied to a field with a support on nodes. * If the optional p_field_volume argument is furnished, the volume is not re-calculated. */ -template double FIELD::normL1(int component, const FIELD * p_field_volume) const +template +double FIELD::normL1(int component, + const FIELD * p_field_volume) const { _checkNormCompatibility(p_field_volume); // may throw exception if ( component<1 || component>getNumberOfComponents() ) - throw MEDEXCEPTION(STRING("FIELD::normL2() : The component argument should be between 1 and the number of components")); + throw MEDEXCEPTION(STRING("FIELD::normL2() : The component argument should be between 1 and the number of components")); - const FIELD * p_field_size=p_field_volume; + const FIELD * p_field_size=p_field_volume; if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] + p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); - const T* value=getValueI( MED_EN::MED_NO_INTERLACE, component); // get pointer to the component's values + const double* vol=p_field_size->getValue(); + const T * value = NULL; + ArrayNo * myArray = NULL; + if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) + value = getColumn(component); + else { + myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) )); + value = myArray->getColumn(component); + } + const T* lastvalue=value+getNumberOfValues(); // pointing just after the end of column double integrale=0.0; @@ -1743,6 +1777,7 @@ template double FIELD::normL1(int component, const FIELD * if(!p_field_volume) // if the user didn't supply the volume delete p_field_size; // delete temporary volume field + if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray; if( totVol <= 0) throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); @@ -1753,17 +1788,26 @@ template double FIELD::normL1(int component, const FIELD * * Cannot be applied to a field with a support on nodes. * If the optional p_field_volume argument is furnished, the volume is not re-calculated. */ -template double FIELD::normL1(const FIELD * p_field_volume) const +template +double FIELD::normL1(const FIELD * p_field_volume) const { _checkNormCompatibility(p_field_volume); // may throw exception - const FIELD * p_field_size=p_field_volume; + const FIELD * p_field_size=p_field_volume; if(!p_field_volume) // if the user don't supply the volume - p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] + p_field_size=_getFieldSize(); // we calculate the volume [PROVISOIRE, en attendant l'implémentation dans mesh] // get pointer to the element's volumes. MED_FULL_INTERLACE is the default mode for p_field_size - const double* vol=p_field_size->getValue(MED_EN::MED_FULL_INTERLACE); + const double* vol=p_field_size->getValue(); const double* lastvol=vol+getNumberOfValues(); // pointing just after the end of vol - const T* value=getValue( MED_EN::MED_NO_INTERLACE); // get pointer to the field's values + + const T * value = NULL; + ArrayNo * myArray = NULL; + if ( getInterlacingType() == MED_EN::MED_NO_INTERLACE ) + value = getValue(); + else { + myArray = ArrayConvert( *( dynamic_cast< ArrayFull * > ( getArrayNoGauss() ) )); + value = myArray->getPtr(); + } double totVol=0.0; const double* p_vol=vol; @@ -1777,6 +1821,7 @@ template double FIELD::normL1(const FIELD * p_field_volume) if(!p_field_volume) // if the user didn't supply the volume delete p_field_size; // delete temporary volume field + if ( getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) delete myArray; if( totVol <= 0) throw MEDEXCEPTION(STRING("cannot compute sobolev norm : volume is not positive!")); @@ -1786,16 +1831,22 @@ template double FIELD::normL1(const FIELD * p_field_volume) /*! Return a new field (to deallocate with delete) lying on subSupport that is included by * this->_support with corresponding values extracting from this->_value. */ -template FIELD* FIELD::extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION) +template +FIELD* FIELD::extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION) { if(!subSupport->belongsTo(*_support)) throw MEDEXCEPTION("FIELD::extract : subSupport not included in this->_support !"); if(_support->isOnAllElements() && subSupport->isOnAllElements()) - return new FIELD(*this); - FIELD *ret=new FIELD(subSupport,_numberOfComponents,MED_EN::MED_FULL_INTERLACE); + return new FIELD(*this); + + FIELD *ret = new FIELD(subSupport, + _numberOfComponents); + if(!ret->_value) throw MEDEXCEPTION("FIELD::extract : unvalid support detected !"); - T* valuesToSet=(T*)ret->_value->get(MED_EN::MED_FULL_INTERLACE); + + T* valuesToSet=(T*)ret->getValue(); + int nbOfEltsSub=subSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); const int *eltsSub=subSupport->getNumber(MED_EN::MED_ALL_ELEMENTS); T* tempVals=new T[_numberOfComponents]; @@ -1807,7 +1858,7 @@ template FIELD* FIELD::extract(const SUPPORT *subSupport) const valuesToSet[i*_numberOfComponents+j]=tempVals[j]; } delete [] tempVals; - ret->setValueType(_valueType); + ret->copyGlobalInfo(*this); return ret; } @@ -1820,13 +1871,13 @@ template FIELD* FIELD::extract(const SUPPORT *subSupport) const iterationNumber and the order number orderNumber does not exist in the file fieldDriverName; the constructor raises an exception. */ -template FIELD::FIELD(const SUPPORT * Support, - driverTypes driverType, - const string & fileName/*=""*/, - const string & fieldDriverName/*=""*/, - const int iterationNumber, - const int orderNumber) - throw (MEDEXCEPTION) +template +FIELD::FIELD(const SUPPORT * Support, + driverTypes driverType, + const string & fileName/*=""*/, + const string & fieldDriverName/*=""*/, + const int iterationNumber, + const int orderNumber) throw (MEDEXCEPTION) { const char * LOC = "template FIELD::FIELD(const SUPPORT * Support, driverTypes driverType, const string & fileName=\"\", const string & fieldName=\"\", const int iterationNumber=-1, const int orderNumber=-1) : "; @@ -1836,11 +1887,19 @@ template FIELD::FIELD(const SUPPORT * Support, init(); + //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE) + FIELD_::_valueType=SET_VALUE_TYPE::_valueType; + + //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE) + FIELD_::_interlacingType=SET_INTERLACING_TYPE::_interlacingType; + _support = Support; //A.G. Addings for RC if(_support) _support->addReference(); - _value = (MEDARRAY*)NULL; + _value = (MEDMEM_Array *) NULL; _iterationNumber = iterationNumber; _time = 0.0; @@ -1848,30 +1907,49 @@ template FIELD::FIELD(const SUPPORT * Support, current = addDriver(driverType,fileName,fieldDriverName,MED_EN::MED_LECT); -// switch(driverType) -// { -// case MED_DRIVER : -// { -// MED_FIELD_RDONLY_DRIVER myDriver(fileName,this); -// myDriver.setFieldName(fieldDriverName); -// current = addDriver(myDriver); -// break; -// } -// current = addDriver(driverType,fileName,fieldDriverName); -// switch(_drivers[current]->getAccessMode() ) { -// case MED_WRONLY : { -// MESSAGE("FIELD::FIELD(driverTypes driverType, .....) : driverType must have a MED_RDONLY or MED_RDWR accessMode"); -// rmDriver(current); -// break;} -// default : { -// } -// } -// default : -// { -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Driver type unknown : can't create driver!")); -// break; -// } -// } + _drivers[current]->open(); + _drivers[current]->read(); + _drivers[current]->close(); + + END_OF(LOC); +} + +/*! + This constructor, at least, allows to create a FIELD without creating any + SUPPORT then without having to load a MESH object, a support is created. It + provides the meshName related mesh but doesn't not set a mesh in the created + support. +*/ +template +FIELD::FIELD(driverTypes driverType, + const string & fileName, + const string & fieldDriverName, + const int iterationNumber, + const int orderNumber) + throw (MEDEXCEPTION) :FIELD_() +{ + int current; + const char * LOC ="FIELD::FIELD( driverTypes driverType, const string & fileName, string & fieldDriverName, int iterationNumber, int orderNumber) : "; + BEGIN_OF(LOC); + + init(); + + //INITIALISATION DE _valueType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_valueType == MED_EN::MED_UNDEFINED_TYPE) + FIELD_::_valueType=SET_VALUE_TYPE::_valueType; + + //INITIALISATION DE _interlacingType DS LE CONSTRUCTEUR DE FIELD_ + ASSERT(FIELD_::_interlacingType == MED_EN::MED_UNDEFINED_INTERLACE) + FIELD_::_interlacingType=SET_INTERLACING_TYPE::_interlacingType; + + _support = (SUPPORT *) NULL; + _value = (MEDMEM_Array *)NULL; + + _iterationNumber = iterationNumber; + _time = 0.0; + _orderNumber = orderNumber; + + current = addDriver(driverType,fileName,fieldDriverName,MED_EN::MED_LECT); _drivers[current]->open(); _drivers[current]->read(); @@ -1883,20 +1961,21 @@ template FIELD::FIELD(const SUPPORT * Support, /*! Destructor. */ -template FIELD::~FIELD() +template FIELD::~FIELD() { - BEGIN_OF(" Destructeur FIELD::~FIELD()"); + BEGIN_OF(" Destructeur FIELD::~FIELD()"); SCRUTE(this); if (_value) delete _value; - END_OF(" Destructeur FIELD::~FIELD()"); + END_OF(" Destructeur FIELD::~FIELD()"); } /*! */ -template void FIELD::allocValue(const int NumberOfComponents) +template +void FIELD::allocValue(const int NumberOfComponents) { - const char* LOC = "FIELD::allocValue(const int NumberOfComponents)" ; + const char* LOC = "FIELD::allocValue(const int NumberOfComponents)" ; BEGIN_OF(LOC); _numberOfComponents = NumberOfComponents ; @@ -1915,26 +1994,30 @@ template void FIELD::allocValue(const int NumberOfComponents) } try { + // becarefull about the number of gauss point _numberOfValues = _support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); MESSAGE(LOC <<" : "<<_numberOfValues <<" et "<< NumberOfComponents); - _value = new MEDARRAY(_numberOfComponents,_numberOfValues); + //EF : A modifier lors de l'intégration de la classe de localisation des points de gauss + _value = new ArrayNoGauss(_numberOfComponents,_numberOfValues); _isRead = true ; } catch (MEDEXCEPTION &ex) { MESSAGE("No value defined, problem with NumberOfComponents (and may be _support) size of MEDARRAY::_value !"); - _value = (MEDARRAY*)NULL ; + _value = (MEDMEM_Array *)NULL ; } SCRUTE(_value); - END_OF("void FIELD::allocValue(const int NumberOfComponents)"); + END_OF("void FIELD::allocValue(const int NumberOfComponents)"); } /*! */ -template void FIELD::allocValue(const int NumberOfComponents, const int LengthValue) +template +void FIELD::allocValue(const int NumberOfComponents, + const int LengthValue) { BEGIN_OF("void FIELD::allocValue(const int NumberOfComponents,const int LengthValue)"); @@ -1955,25 +2038,29 @@ template void FIELD::allocValue(const int NumberOfComponents, const MESSAGE("FIELD : constructeur : "<(_numberOfComponents,_numberOfValues); + + //EF : A modifier lors de l'intégration de la classe de localisation des points de gauss + _value = new ArrayNoGauss(_numberOfComponents,_numberOfValues); + _isRead = true ; SCRUTE(_value); - END_OF("void FIELD::allocValue(const int NumberOfComponents,const int LengthValue)"); + END_OF("void FIELD::allocValue(const int NumberOfComponents,const int LengthValue)"); } /*! */ -template void FIELD::deallocValue() +template +void FIELD::deallocValue() { - BEGIN_OF("void FIELD::deallocValue()"); + BEGIN_OF("void FIELD::deallocValue()"); _numberOfValues = 0 ; _numberOfComponents = 0 ; if (_value != NULL) delete _value; - END_OF("void FIELD::deallocValue()"); + END_OF("void FIELD::deallocValue()"); } // ----------------- @@ -1985,10 +2072,11 @@ template void FIELD::deallocValue() read or write methods. */ -template int FIELD::addDriver(driverTypes driverType, - const string & fileName/*="Default File Name.med"*/, - const string & driverName/*="Default Field Name"*/, - MED_EN::med_mode_acces access) +template +int FIELD::addDriver(driverTypes driverType, + const string & fileName/*="Default File Name.med"*/, + const string & driverName/*="Default Field Name"*/, + MED_EN::med_mode_acces access) { //jfa tmp (as last argument has no default value):const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\",MED_EN::med_mode_acces access) : "; const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName,const string & driverName,MED_EN::med_mode_acces access) :";//jfa tmp @@ -2017,9 +2105,10 @@ template int FIELD::addDriver(driverTypes driverType, Duplicate the given driver and return its index reference to path to read or write methods. */ -template inline int FIELD::addDriver (GENDRIVER & driver ) +template +inline int FIELD::addDriver (GENDRIVER & driver ) { - const char * LOC = "FIELD::addDriver(GENDRIVER &) : "; + const char * LOC = "FIELD::addDriver(GENDRIVER &) : "; int current; BEGIN_OF(LOC); @@ -2043,9 +2132,10 @@ template inline int FIELD::addDriver (GENDRIVER & driver ) /*! Remove the driver referenced by its index. */ -template void FIELD::rmDriver (int index/*=0*/) +template +void FIELD::rmDriver (int index/*=0*/) { - const char * LOC = "FIELD::rmDriver (int index=0): "; + const char * LOC = "FIELD::rmDriver (int index=0): "; BEGIN_OF(LOC); if ( _drivers[index] ) { @@ -2066,9 +2156,9 @@ template void FIELD::rmDriver (int index/*=0*/) /*! Read FIELD in the file specified in the driver given by its index. */ -template inline void FIELD::read(int index/*=0*/) +template inline void FIELD::read(int index/*=0*/) { - const char * LOC = "FIELD::read(int index=0) : "; + const char * LOC = "FIELD::read(int index=0) : "; BEGIN_OF(LOC); if ( _drivers[index] ) { @@ -2088,9 +2178,9 @@ template inline void FIELD::read(int index/*=0*/) /*! Write FIELD in the file specified in the driver given by its index. */ -template inline void FIELD::write(int index/*=0*/, const string & driverName /*= ""*/) +template inline void FIELD::write(int index/*=0*/, const string & driverName /*= ""*/) { - const char * LOC = "FIELD::write(int index=0, const string & driverName = \"\") : "; + const char * LOC = "FIELD::write(int index=0, const string & driverName = \"\") : "; BEGIN_OF(LOC); if( _drivers[index] ) { @@ -2112,9 +2202,9 @@ template inline void FIELD::write(int index/*=0*/, const string & d Write FIELD in the file specified in the driver given by its index. Use this method for ASCII drivers (e.g. VTK_DRIVER) */ -template inline void FIELD::writeAppend(int index/*=0*/, const string & driverName /*= ""*/) +template inline void FIELD::writeAppend(int index/*=0*/, const string & driverName /*= ""*/) { - const char * LOC = "FIELD::write(int index=0, const string & driverName = \"\") : "; + const char * LOC = "FIELD::write(int index=0, const string & driverName = \"\") : "; BEGIN_OF(LOC); if( _drivers[index] ) { @@ -2138,9 +2228,9 @@ template inline void FIELD::writeAppend(int index/*=0*/, const stri Use by MED object. */ -template inline void FIELD::write(const GENDRIVER & genDriver) +template inline void FIELD::write(const GENDRIVER & genDriver) { - const char * LOC = " FIELD::write(const GENDRIVER &) : "; + const char * LOC = " FIELD::write(const GENDRIVER &) : "; BEGIN_OF(LOC); for (unsigned int index=0; index < _drivers.size(); index++ ) @@ -2160,9 +2250,9 @@ template inline void FIELD::write(const GENDRIVER & genDriver) Use by MED object. Use this method for ASCII drivers (e.g. VTK_DRIVER). */ -template inline void FIELD::writeAppend(const GENDRIVER & genDriver) +template inline void FIELD::writeAppend(const GENDRIVER & genDriver) { - const char * LOC = " FIELD::write(const GENDRIVER &) : "; + const char * LOC = " FIELD::write(const GENDRIVER &) : "; BEGIN_OF(LOC); for (unsigned int index=0; index < _drivers.size(); index++ ) @@ -2182,9 +2272,9 @@ template inline void FIELD::writeAppend(const GENDRIVER & genDriver Use by MED object. */ -template inline void FIELD::read(const GENDRIVER & genDriver) +template inline void FIELD::read(const GENDRIVER & genDriver) { - const char * LOC = " FIELD::read(const GENDRIVER &) : "; + const char * LOC = " FIELD::read(const GENDRIVER &) : "; BEGIN_OF(LOC); for (unsigned int index=0; index < _drivers.size(); index++ ) @@ -2202,8 +2292,12 @@ template inline void FIELD::read(const GENDRIVER & genDriver) Fills in already allocated retValues array the values related to eltIdInSup. If the element does not exist in this->_support false is returned, true otherwise. */ -template bool FIELD::getValueOnElement(int eltIdInSup,T* retValues) const +template +bool FIELD::getValueOnElement(int eltIdInSup,T* retValues) + const throw (MEDEXCEPTION) { +// retValues = getRow(eltIdInSup); + if(eltIdInSup<1) return false; if(_support->isOnAllElements()) @@ -2211,7 +2305,7 @@ template bool FIELD::getValueOnElement(int eltIdInSup,T* retValues) int nbOfEltsThis=_support->getMesh()->getNumberOfElements(_support->getEntity(),MED_EN::MED_ALL_ELEMENTS); if(eltIdInSup>nbOfEltsThis) return false; - const T* valsThis=getValue(MED_EN::MED_FULL_INTERLACE); + const T* valsThis=getValue(); for(int j=0;j<_numberOfComponents;j++) retValues[j]=valsThis[(eltIdInSup-1)*_numberOfComponents+j]; return true; @@ -2229,7 +2323,7 @@ template bool FIELD::getValueOnElement(int eltIdInSup,T* retValues) iThis++; if(!found) return false; - const T* valsThis=getValue(MED_EN::MED_FULL_INTERLACE); + const T* valsThis=getValue(); for(int j=0;j<_numberOfComponents;j++) retValues[j]=valsThis[iThis*_numberOfComponents+j]; return true; @@ -2241,7 +2335,9 @@ template bool FIELD::getValueOnElement(int eltIdInSup,T* retValues) Destroy the MEDARRAY in FIELD and put the new one without copy. \endif */ -template inline void FIELD::setValue(MEDARRAY *Value) +template +inline void FIELD::setArray(MEDMEM_Array_ * Value) + throw (MEDEXCEPTION) { if (NULL != _value) delete _value ; _value=Value ; @@ -2249,49 +2345,149 @@ template inline void FIELD::setValue(MEDARRAY *Value) /*! \if developper - Return a reference to the MEDARRAY in FIELD. + Return a reference to the MEDARRAY in FIELD. \endif */ -template inline MEDARRAY* FIELD::getvalue() const +template +inline MEDMEM_Array_ * FIELD::getArray() const throw (MEDEXCEPTION) { + const char * LOC = "MEDMEM_Array_ * FIELD::getArray() : "; + BEGIN_OF(LOC); + END_OF(LOC); return _value ; } +template inline +typename MEDMEM_ArrayInterface::Array * +FIELD::getArrayGauss() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getArrayGauss() : "; + BEGIN_OF(LOC); + + if ( getGaussPresence() ) + return dynamic_cast (_value); + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< + "The field has no Gauss Point")); + + END_OF(LOC); + +} + +template inline +typename MEDMEM_ArrayInterface::Array * +FIELD::getArrayNoGauss() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getArrayNoGauss() : "; + BEGIN_OF(LOC); + + if ( ! getGaussPresence() ) + return dynamic_cast < ArrayNoGauss * > (_value); + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< + "The field has Gauss Point")); + + END_OF(LOC); +} + + +template inline bool +FIELD::getGaussPresence() const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getGaussPresence() const :"; + BEGIN_OF(LOC); + + if (_value != NULL) + return _value->getGaussPresence(); + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Can't call getGaussPresence on a null _value")); + + END_OF(LOC); +} /*! Return the actual length of the reference to values array returned by getValue. */ -template inline int FIELD::getValueLength(MED_EN::medModeSwitch Mode) const{ +template +inline int FIELD::getValueLength() const + throw (MEDEXCEPTION) +{ + // be carefull about number of gauss point return _numberOfComponents*_numberOfValues; } /*! Return a reference to values array to read them. */ -template inline const T* FIELD::getValue(MED_EN::medModeSwitch Mode) const +template +inline const T* FIELD::getValue() const throw (MEDEXCEPTION) { - return _value->get(Mode) ; + const char * LOC ="FIELD::getValue() : "; + BEGIN_OF(LOC); + if ( getGaussPresence() ) + return dynamic_cast(_value)->getPtr() ; + else + return dynamic_cast(_value)->getPtr() ; +} +/*! + Return a reference to i^{th} row + of FIELD values array. + If a faster accessor is intended you may use getArray() once, + then MEDMEM_Array accessors. + Be careful if field support is not on all elements you might + have to use support->getValIndFromGlobalNumber(i). +*/ +template inline +const T* +FIELD::getRow(int i) const throw (MEDEXCEPTION) +{ + const char * LOC = "FIELD::getRow(int i) : "; + BEGIN_OF(LOC); + + int valIndex=-1; + if (_support) + valIndex = _support->getValIndFromGlobalNumber(i); + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" )); + + if ( getGaussPresence() ) + return dynamic_cast(_value)->getRow(valIndex) ; + else + return dynamic_cast(_value)->getRow(valIndex) ; + END_OF(LOC); } /*! - Return a reference to i^{th} row or column - component - (depend on Mode value) + Return a reference to j^{th} column of FIELD values array. */ -template inline const T* FIELD::getValueI(MED_EN::medModeSwitch Mode,int i) const +template inline const T* +FIELD::getColumn(int j) const throw (MEDEXCEPTION) { - if ( Mode == MED_EN::MED_FULL_INTERLACE ) - { - return _value->getRow(i) ; - } - ASSERT ( Mode == MED_EN::MED_NO_INTERLACE); - return _value->getColumn(i); + const char * LOC ="FIELD::getColumn(int j) : "; + BEGIN_OF(LOC); + if ( getGaussPresence() ) + return dynamic_cast(_value)->getColumn(j) ; + else + return dynamic_cast(_value)->getColumn(j) ; } /*! Return the value of i^{th} element and j^{th} component. */ -template inline T FIELD::getValueIJ(int i,int j) const +template inline T FIELD::getValueIJ(int i,int j) const throw (MEDEXCEPTION) { - return _value->getIJ(i,j) ; + const char * LOC = "getValueIJ(..)"; + BEGIN_OF(LOC); + int valIndex=-1; + if (_support) + valIndex = _support->getValIndFromGlobalNumber(i); + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" )); + + if ( getGaussPresence() ) + return dynamic_cast(_value)->getIJ(valIndex,j) ; + else + return dynamic_cast(_value)->getIJ(valIndex,j) ; } /*! @@ -2299,31 +2495,64 @@ template inline T FIELD::getValueIJ(int i,int j) const Array must have right size. If not results are unpredicable. */ -template inline void FIELD::setValue(MED_EN::medModeSwitch mode, T* value) +template inline void FIELD::setValue( T* value) throw (MEDEXCEPTION) { - _value->set(mode,value); + if ( getGaussPresence() ) + return dynamic_cast(_value)->setPtr(value) ; + else + return dynamic_cast(_value)->setPtr(value) ; } /*! - Update values array in FIELD with the given ones according to specified mode. + Update values array in the j^{th} row of FIELD values array with the given ones and + according to specified mode. */ -template inline void FIELD::setValueI(MED_EN::medModeSwitch mode, int i, T* value) +template +inline void FIELD::setRow( int i, T* value) throw (MEDEXCEPTION) { - // PROVISOIRE : - if (MED_EN::MED_FULL_INTERLACE == mode) - _value->setI(i,value); - else if (MED_EN::MED_NO_INTERLACE == mode) - _value->setJ(i,value); + const char * LOC = "FIELD::setRow(int i, T* value) : "; + int valIndex=i; +// JE (NB) NE SUIS PAS SUR DE CA ???? + if (_support) + valIndex = _support->getValIndFromGlobalNumber(i); + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" )); + + if ( getGaussPresence() ) + return dynamic_cast(_value)->setRow(valIndex, value) ; else - throw MEDEXCEPTION(LOCALIZED("FIELD::setValueI : bad medModeSwitch")) ; + return dynamic_cast(_value)->setRow(valIndex, value) ; +} + +/*! + Update values array in the j^{th} column of FIELD values array with the given ones and + according to specified mode. +*/ +template +inline void FIELD::setColumn( int i, T* value) throw (MEDEXCEPTION) +{ + if ( getGaussPresence() ) + return dynamic_cast(_value)->setColumn(i, value) ; + else + return dynamic_cast(_value)->setColumn(i, value) ; } /*! Set the value of i^{th} element and j^{th} component with the given one. */ -template inline void FIELD::setValueIJ(int i, int j, T value) +template inline void FIELD::setValueIJ(int i, int j, T value) throw (MEDEXCEPTION) { - _value->setIJ(i,j,value); + const char * LOC = "FIELD::setValueIJ(int i, int j, T value) : "; + int valIndex=-1; + if (_support) + valIndex = _support->getValIndFromGlobalNumber(i); + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Support not define |" )); + + if ( getGaussPresence() ) + return dynamic_cast(_value)->setIJ(valIndex,j,value) ; + else + return dynamic_cast(_value)->setIJ(valIndex,j,value) ; } /* @@ -2333,7 +2562,8 @@ template inline void FIELD::setValueIJ(int i, int j, T value) /*! Fill values array with volume values. */ -template void FIELD::getVolume() const throw (MEDEXCEPTION) +template +void FIELD::getVolume() const throw (MEDEXCEPTION) { const char * LOC = "FIELD::getVolume() const : "; BEGIN_OF(LOC); @@ -2351,7 +2581,8 @@ template void FIELD::getVolume() const throw (MEDEXCEPTION) /*! Fill values array with area values. */ -template void FIELD::getArea() const throw (MEDEXCEPTION) +template +void FIELD::getArea() const throw (MEDEXCEPTION) { const char * LOC = "FIELD::getArea() const : "; BEGIN_OF(LOC); @@ -2369,7 +2600,8 @@ template void FIELD::getArea() const throw (MEDEXCEPTION) /*! Fill values array with length values. */ -template void FIELD::getLength() const throw (MEDEXCEPTION) +template +void FIELD::getLength() const throw (MEDEXCEPTION) { const char * LOC = "FIELD::getLength() const : "; BEGIN_OF(LOC); @@ -2387,7 +2619,8 @@ template void FIELD::getLength() const throw (MEDEXCEPTION) /*! Fill values array with normal values. */ -template void FIELD::getNormal() const throw (MEDEXCEPTION) +template +void FIELD::getNormal() const throw (MEDEXCEPTION) { const char * LOC = "FIELD::getNormal() const : "; BEGIN_OF(LOC); @@ -2410,7 +2643,8 @@ template void FIELD::getNormal() const throw (MEDEXCEPTION) /*! Fill values array with barycenter values. */ -template void FIELD::getBarycenter() const throw (MEDEXCEPTION) +template +void FIELD::getBarycenter() const throw (MEDEXCEPTION) { const char * LOC = "FIELD::getBarycenter() const : "; BEGIN_OF(LOC); @@ -2435,15 +2669,21 @@ template void FIELD::getBarycenter() const throw (MEDEXCEPTION) WARNING : "this" must have allocated its array by setting this->_support and this->_numberOfComponents properly. Typically you should use it on a field built with constructor FIELD::FIELD(SUPPORT *,int nbOfComponents) */ -template -template -void FIELD::fillFromAnalytic() +template +void FIELD::fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION) { + const char * LOC = "void FIELD::fillFromAnalytic(myFuncType f) : "; int i,j; + if (_support == (SUPPORT *) NULL) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"No Support defined.")); + MESH * mesh = _support->getMesh(); int spaceDim = mesh->getSpaceDimension(); const double * coord; - FIELD * barycenterField=0; + + const double * bary; + FIELD * barycenterField=0; + double ** xyz=new double* [spaceDim]; bool deallocateXyz=false; if(_support->getEntity()==MED_EN::MED_NODE) @@ -2471,17 +2711,17 @@ void FIELD::fillFromAnalytic() else { barycenterField = mesh->getBarycenter(_support); - coord=barycenterField->getValue(MED_EN::MED_NO_INTERLACE); + bary=barycenterField->getValue(); for(i=0; i FIELD * +FieldConvert(const FIELD & field ) +{ + typedef typename MEDMEM_ArrayInterface::Array ArrayFullNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayFullGa; + + FIELD * myField = new FIELD(); + FIELD_ * myField_ = myField; + FIELD_ * field_ = &(const_cast< FIELD &> (field)); + *myField_ = *field_; // Opérateur d'affectation de FIELD_ OK + // *((FIELD_ *) myField) = (FIELD_ ) field; //Contructeur par recopie de FIELD_ Pourquoi? + + if ( field.getGaussPresence() ) { + ArrayFullGa * myArray = ArrayConvert( *(field.getArrayGauss()) ); + myField->setArray(myArray); + return myField; + } else { + ArrayFullNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) ); + myField->setArray(myArray); + return myField; + } +} + +template FIELD * +FieldConvert(const FIELD & field ) +{ + typedef typename MEDMEM_ArrayInterface::Array ArrayNoNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayNoGa; + + + FIELD * myField = new FIELD(); + FIELD_ * myField_ = myField; + FIELD_ * field_ = &(const_cast< FIELD &> (field)); + *myField_ = *field_; // Opérateur d'affectation de FIELD_ OK + // *((FIELD_*) myField) = (FIELD_) field; //Contructeur par recopie de FIELD_ Pourquoi? + + if ( field.getGaussPresence() ) { + ArrayNoGa * myArray = ArrayConvert( *(field.getArrayGauss()) ); + myField->setArray(myArray); + return myField; + } else { + ArrayNoNo * myArray = ArrayConvert( *(field.getArrayNoGauss()) ); + myField->setArray(myArray); + return myField; + } + +} + +} +#endif diff --git a/src/MEDMEM/MEDMEM_FieldForward.hxx b/src/MEDMEM/MEDMEM_FieldForward.hxx new file mode 100644 index 000000000..60a56adc3 --- /dev/null +++ b/src/MEDMEM/MEDMEM_FieldForward.hxx @@ -0,0 +1,10 @@ +#ifndef FIELD_FORWARD +#define FIELD_FORWARD + +#include "MEDMEM_Tags.hxx" + +namespace MEDMEM { + template class FIELD; + +} +#endif diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx index c3166d62c..21ccb6abb 100644 --- a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx +++ b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx @@ -35,6 +35,8 @@ #include "MEDMEM_define.hxx" #include "MEDMEM_DriverTools.hxx" +class MEDMEM::FIELD_; + #include #include #ifdef WNT @@ -470,7 +472,7 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields // (2) 0 1 // (3) FX FY FZ FZ FX FY FLX // (4) 0 0 0 0 0 0 0 - // (5) créé par muc pri + // (5) cré©  par muc pri // (6) // (7) 2 @@ -773,7 +775,7 @@ bool GIBI_MESH_RDONLY_DRIVER::readFile (_intermediateMED* medi, bool readFields GIBI_MESH_DRIVER::GIBI_MESH_DRIVER(): GENDRIVER(), - _ptrMesh(( MESH *)MED_NULL), + _ptrMesh(( MESH *) NULL), // A VOIR _medIdt(MED_INVALID), _meshName("") { @@ -1032,6 +1034,7 @@ string GIBI_MESH_RDONLY_DRIVER::getName() const void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION) { const char * LOC = "_GIBI_RDONLY_DRIVER::read() : " ; + BEGIN_OF(LOC); if (_status!=MED_OPENED) throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "The _idt of file " << _fileName << " is : " @@ -1053,7 +1056,7 @@ void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION) { INFOS( ex.what() ); } - + END_OF(LOC); } //======================================================================= @@ -2368,17 +2371,23 @@ GENDRIVER * GIBI_MED_WRONLY_DRIVER::copy ( void ) const //purpose : //======================================================================= -template< class T > - static void writeDataSection (fstream& file, - FIELD_* field, - int id1, - int id2) +template< class T, class INTERLACING_TAG> +static void writeDataSection (fstream& file, + FIELD * field, + int id1, + int id2) throw (MEDEXCEPTION) { - FIELD* f = dynamic_cast*>( field ); - if (!f) return; - MEDARRAY* array = f->getvalue(); - int ld = array->getLeadingValue(); + const char * LOC="writeDataSection (.....) :"; + BEGIN_OF(LOC); + + int ld = field->getNumberOfComponents(); + +// FIELD* f = dynamic_cast*>( field ); +// if (!f) return; +// MEDARRAY* array = f->getvalue(); +// int ld = array->getLeadingValue(); //SCRUTE( array->getLengthValue() ); + for ( int iComp = 0; iComp < ld; ++iComp ) { file << setw(8) << 1 // nb scalar values by element @@ -2390,10 +2399,11 @@ template< class T > while ( id < id2 ) { for ( int i = 0; id < id2 && i < 3; ++i ) - file << setw(22) << array->getIJ( id++, iComp + 1); + file << setw(22) << field->getValueIJ( id++, iComp + 1); file << endl; } } + END_OF(LOC); } //======================================================================= @@ -2429,7 +2439,7 @@ void GIBI_MED_WRONLY_DRIVER::write( void ) const throw (MEDEXCEPTION) for ( ; fIt != dtit.end(); fIt++ ) { FIELD_ * f = _med->getField( names[ iField ], fIt->dt, fIt->it ); - if ( !dynamic_cast< FIELD* >( f )) + if ( f->getValueType() != MED_EN::MED_INT32 ) { MESSAGE("GIBI_MED_WRONLY_DRIVER::write( FIELD< int > ) not implemented"); continue; @@ -2541,7 +2551,15 @@ void GIBI_MED_WRONLY_DRIVER::write( void ) const throw (MEDEXCEPTION) // Data section int id2 = id1 + idsize->second; - writeDataSection( gibi, f, id1, id2 ); + + if (f->getGaussPresence() ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " GibiDriver don't support Field with Gauss point" )); + + if ( f->getInterlacingType() == MED_NO_INTERLACE ) + writeDataSection( gibi, dynamic_cast*>(f), id1, id2 ); + else + writeDataSection( gibi, dynamic_cast< FIELD * >(f), id1, id2 ); + id1 = id2; } } // loop on fields diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx index f86a57ecb..4e603f099 100644 --- a/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx +++ b/src/MEDMEM/MEDMEM_GibiMeshDriver.hxx @@ -33,6 +33,8 @@ #include "MEDMEM_Exception.hxx" #include "MEDMEM_Utilities.hxx" +#include "MEDMEM_FieldForward.hxx" + ///// #include #include @@ -49,7 +51,7 @@ namespace MEDMEM { class MED; class MESH; -class FIELD_; + //class FIELD_; class FAMILY; class GROUP; class SUPPORT; diff --git a/src/MEDMEM/MEDMEM_Group.cxx b/src/MEDMEM/MEDMEM_Group.cxx index 7a4e0b27f..f88b48ad0 100644 --- a/src/MEDMEM/MEDMEM_Group.cxx +++ b/src/MEDMEM/MEDMEM_Group.cxx @@ -30,7 +30,7 @@ using namespace std; using namespace MEDMEM; using namespace MED_EN; -GROUP::GROUP():_numberOfFamilies(0),_family() +GROUP::GROUP():SUPPORT(),_numberOfFamilies(0),_family() { MESSAGE("GROUP()"); }; @@ -43,6 +43,8 @@ GROUP::~GROUP() GROUP & GROUP::operator=(const GROUP &group) { MESSAGE("GROUP::operator="); + if ( &group == this ) return *this; + SUPPORT::operator=(group); _numberOfFamilies = group._numberOfFamilies ; _family = group._family ; return *this; @@ -95,10 +97,11 @@ GROUP::GROUP(const string & name, const list & families) throw (MEDEXCE throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "building of a GROUP object from several FAMILY, and one of them is on all entities" )) ; _numberOfGeometricType = myFamily->getNumberOfTypes() ; - _geometricType = new medGeometryElement[_numberOfGeometricType]; - //_geometricTypeNumber = new int[_numberOfGeometricType] ; - _numberOfGaussPoint = new int[_numberOfGeometricType] ; - _numberOfElements = new int[_numberOfGeometricType] ; + + _geometricType.set(_numberOfGeometricType); + _numberOfGaussPoint.set(_numberOfGeometricType) ; + _numberOfElements.set(_numberOfGeometricType) ; + const medGeometryElement * geometricType = myFamily->getTypes() ; //int * geometricTypeNumber = myFamily->getGeometricTypeNumber() ; const int * numberOfGaussPoint = myFamily->getNumberOfGaussPoint() ; @@ -164,7 +167,7 @@ GROUP::GROUP(const string & name, const list & families) throw (MEDEXCE GROUP::GROUP(const GROUP & m):SUPPORT(m) { _numberOfFamilies = m._numberOfFamilies; - _family = m._family; + _family = m._family; //Copie profonde dans FAMILY Rmq from EF }; // void GROUP::init(const list & families) diff --git a/src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx b/src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx new file mode 100644 index 000000000..6cc6ec122 --- /dev/null +++ b/src/MEDMEM/MEDMEM_IndexCheckingPolicy.hxx @@ -0,0 +1,42 @@ +#ifndef MEDMEM_INDEX_CHECKING_POLICY_HXX +#define MEDMEM_INDEX_CHECKING_POLICY_HXX + +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_STRING.hxx" + +namespace MEDMEM { + +class IndexCheckPolicy { +public : + inline void checkMoreThanZero(const std::string & classname, int index) const { + if (index <= 0) + throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index << " is less or equal to zero")); + } + inline void checkLessOrEqualThan(const std::string & classname, int max, int index) const { + if (index > max) + throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index << " is more than " << max )); + } + + inline void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const { + if (index < min || index > max ) + throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", index : " << index + << " not in rang [" << min << "," << max <<"]")); + } + + inline void checkEquality(const std::string & classname, int a, int b) const { + if ( a == b ) + throw MEDEXCEPTION(LOCALIZED(STRING("In ") << classname << ", Value shouldn't be : " << a )); + } + +}; + +class NoIndexCheckPolicy { +public : + inline void checkMoreThanZero(const string &classname, int index) const {} + inline void checkLessOrEqualThan(const std::string & classname, int max, int index) const {} + inline void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const {} + inline void checkEquality(const std::string & classname, int a, int b) const {} +}; + +}// END NAMESPACE +#endif diff --git a/src/MEDMEM/MEDMEM_InterlacingPolicy.hxx b/src/MEDMEM/MEDMEM_InterlacingPolicy.hxx new file mode 100644 index 000000000..10f22f208 --- /dev/null +++ b/src/MEDMEM/MEDMEM_InterlacingPolicy.hxx @@ -0,0 +1,335 @@ +#ifndef MEDMEM_INTERLACING_HXX +#define MEDMEM_INTERLACING_HXX + +#include +#include "MEDMEM_Utilities.hxx" + +#include "MEDMEM_PointerOf.hxx" +#include "MEDMEM_define.hxx" + +namespace MEDMEM { + +class InterlacingPolicy { +protected: + ~InterlacingPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique +public : + InterlacingPolicy(void) : _dim(0), _nbelem(0), + _arraySize(0), + _interlacing(MED_EN::MED_UNDEFINED_INTERLACE), + _gaussPresence(false) {} + + InterlacingPolicy(int nbelem, int dim, int arraySize=0, int interlacing=MED_EN::MED_UNDEFINED_INTERLACE) : + _dim(dim), + _nbelem(nbelem), + _arraySize(arraySize), + _interlacing(interlacing), + _gaussPresence(false) {} + + // Constructeur par recopie + InterlacingPolicy(const InterlacingPolicy & intpol, + bool shallowcopy = true) :_dim(intpol._dim), + _nbelem(intpol._nbelem), + _arraySize(intpol._arraySize), + _interlacing(intpol._interlacing), + _gaussPresence(intpol._gaussPresence) {} + + InterlacingPolicy & operator=(const InterlacingPolicy & intpol) { + if ( this == &intpol ) return *this; + BEGIN_OF("InterlacingPolicy operator ="); + + _dim = intpol._dim; + _nbelem = intpol._nbelem; //ne prend pas en compte les points de Gauss + _arraySize = intpol._arraySize; + _interlacing = intpol._interlacing; + _gaussPresence = intpol._gaussPresence; + + return *this; + } + + inline int getDim() const { return _dim; } + inline int getNbElem() const { return _nbelem; } + inline int getArraySize() const { return _arraySize; } + inline MED_EN::medModeSwitch getInterlacingType() const {return _interlacing;} + inline bool getGaussPresence() const { return _gaussPresence;} + virtual int getNbGauss(int i) const = 0; + + int _dim; + int _nbelem; + int _arraySize; + MED_EN::medModeSwitch _interlacing; + bool _gaussPresence; +}; + + +class FullInterlaceNoGaussPolicy : public InterlacingPolicy { + +protected: + ~FullInterlaceNoGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique + +public : + FullInterlaceNoGaussPolicy() : InterlacingPolicy() {} + FullInterlaceNoGaussPolicy(int nbelem, int dim) : + InterlacingPolicy(nbelem, dim, dim*nbelem,MED_EN::MED_FULL_INTERLACE) {} + + FullInterlaceNoGaussPolicy(const FullInterlaceNoGaussPolicy & policy, + bool shallowcopie=true) + : InterlacingPolicy(policy) {}; + + inline int getIndex(int i,int j) const { + return (i-1)*_dim + j-1; + } + + inline int getIndex(int i,int j,int k) const { + return (i-1)*_dim + j-1; + } + + inline int getNbGauss(int i) const { return 1; } + +}; + +class NoInterlaceNoGaussPolicy : public InterlacingPolicy { + +protected: + ~NoInterlaceNoGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique + +public : + + NoInterlaceNoGaussPolicy():InterlacingPolicy() {} + NoInterlaceNoGaussPolicy(int nbelem, int dim) : + InterlacingPolicy(nbelem, dim, dim*nbelem,MED_EN::MED_NO_INTERLACE) {} + + NoInterlaceNoGaussPolicy(const NoInterlaceNoGaussPolicy & policy, + bool shallowcopie=true) + : InterlacingPolicy(policy) {} + + inline int getIndex(int i,int j) const { + return (j-1)*_nbelem + i-1; + } + + inline int getIndex(int i,int j,int k) const { + return (j-1)*_nbelem + i-1; + } + + inline int getNbGauss(int i) const { return 1; } + +}; + +class FullInterlaceGaussPolicy : public InterlacingPolicy { +protected: + ~FullInterlaceGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique +public : + + PointerOf _G; + PointerOf _S; + int _nbtypegeo; + PointerOf _nbelegeoc; + PointerOf _nbgaussgeo; + + FullInterlaceGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1) { + InterlacingPolicy::_gaussPresence=true; + } + FullInterlaceGaussPolicy(int nbelem, int dim, int nbtypegeo, + const int * const nbelgeoc, const int * const nbgaussgeo) + : InterlacingPolicy(nbelem, dim, -1, MED_EN::MED_FULL_INTERLACE),_nbtypegeo(nbtypegeo) { + + InterlacingPolicy::_gaussPresence=true; + + _nbelegeoc.set(_nbtypegeo+1,nbelgeoc); + _nbgaussgeo.set(_nbtypegeo+1,nbgaussgeo); + _G.set(nbelem+1); + // _G[0] = 1; + _S.set(nbelem+1); + _S[0] = -1; + int cumul = 0; + int elemno = 0; + + // Construction of _G + for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { + for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { + _G[ elemno ] = cumul + i*nbgaussgeo[ntyp]*dim + 1; + elemno++; + _S[ elemno ] = nbgaussgeo[ntyp]; + }; + cumul += (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) * nbgaussgeo[ntyp] * dim; +#ifdef ARRAY_DEBUG + std::cout << "Valeur de cumul " << cumul << std::endl; +#endif + }; + + _G[ elemno ] = cumul+1; + _arraySize = _G[ elemno ] -1 ; + +#ifdef ARRAY_DEBUG + for (int i =0; i< nbelem+1; i++ ) + std::cout << "Valeur de _G["<_G.set(policy._G); + this->_S.set(policy._S); + } else { + this->_G.set(_nbelem+1,policy._G); + this->_S.set(_nbelem+1,policy._S); + } + // Tableaux toujours recopiés par recopie profonde + this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); + this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); + } + + FullInterlaceGaussPolicy & operator=(const FullInterlaceGaussPolicy & policy) { + BEGIN_OF("FullInterlaceGaussPolicy operator ="); + + if ( this == &policy) return *this; + + //Seuls les tableaux de grande taille sont recopiés superficiellement + InterlacingPolicy::operator=(policy); + this->_G.set(policy._G); + this->_S.set(policy._S); + + // Tableaux toujours recopiés par recopie profonde + this->_nbtypegeo=policy._nbtypegeo; + this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); + this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); + + return *this; + } + + inline int getIndex(int i,int j ) const { + return _G[i-1]-1 + (j-1)*_dim ; + } + + inline int getIndex(int i,int j, int k ) const { + //std::cout << "Index : " << _G[i-1]-1 + _dim *(k-1) + (j-1) << std::endl; + return _G[i-1]-1 + (k-1)*_dim + (j-1); + } + + inline int getNbGauss(int i) const { return _S[i]; } + + inline int getNbGeoType() const {return _nbtypegeo;} + + inline const int * const getNbElemGeoC() const {return _nbelegeoc;} + + inline const int * const getNbGaussGeo() const {return _nbgaussgeo;} + + +}; + +class NoInterlaceGaussPolicy : public InterlacingPolicy { + +protected: + ~NoInterlaceGaussPolicy() {} //pour éviter qu'un utilisateur cast la class array en politique + +public : + + PointerOf _G; + PointerOf _S; + int _nbtypegeo; + PointerOf _nbelegeoc; + PointerOf _nbgaussgeo; + // _cumul is used in getIndex() to access directly to the first value + // of a given dimension. + int _cumul; + + NoInterlaceGaussPolicy():InterlacingPolicy(),_nbtypegeo(-1),_cumul(0) { + InterlacingPolicy::_gaussPresence=true; + } + + NoInterlaceGaussPolicy(int nbelem, int dim, int nbtypegeo, + const int * const nbelgeoc, const int * const nbgaussgeo) + : InterlacingPolicy(nbelem, dim, -1, MED_EN::MED_NO_INTERLACE),_nbtypegeo(nbtypegeo) { + + InterlacingPolicy::_gaussPresence=true; + + _nbelegeoc.set(_nbtypegeo+1,nbelgeoc); + _nbgaussgeo.set(_nbtypegeo+1,nbgaussgeo); + _G.set(nbelem+1); + //_G[0] = 1; + _S.set(nbelem+1); + _S[0] = -1; + int elemno = 0; + + _cumul = 0; + for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { + for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { + _G[ elemno ] = _cumul + i*nbgaussgeo[ntyp] + 1; + elemno++; + _S[ elemno ] = nbgaussgeo[ntyp]; + }; + _cumul += (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) * nbgaussgeo[ntyp]; +#ifdef ARRAY_DEBUG + std::cout << "Valeur de _cumul " << _cumul << std::endl; +#endif + }; + + _G[ elemno ] = _cumul+1; + _arraySize = ( _G[ elemno ] -1 ) * dim ; + +#ifdef ARRAY_DEBUG + for (int i =0; i< nbelem+1; i++ ) + std::cout << "Valeur de _G["<_G.set(policy._G); + this->_S.set(policy._S); + } else { + this->_G.set(_nbelem+1,policy._G); + this->_S.set(_nbelem+1,policy._S); + } + // Tableaux toujours recopiés par recopie profonde + this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); + this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); + } + + NoInterlaceGaussPolicy & operator=(const NoInterlaceGaussPolicy & policy) { + if ( this == &policy) return *this; + + BEGIN_OF("NoInterlaceGaussPolicy operator ="); + InterlacingPolicy::operator=(policy); + this->_G.set(policy._G); + this->_S.set(policy._S); + + this->_cumul = policy._cumul; + + // Tableaux toujours recopiés par recopie profonde + this->_nbtypegeo=policy._nbtypegeo; + this->_nbelegeoc.set(_nbtypegeo+1,policy._nbelegeoc); + this->_nbgaussgeo.set(_nbtypegeo+1,policy._nbgaussgeo); + + return *this; + } + + inline int getIndex(int i,int j ) const { + return _G[i-1]-1 + (j-1)*_cumul ; + } + + inline int getIndex(int i,int j, int k ) const { + return _G[i-1]-1 + (j-1)*_cumul + (k-1) ; + } + + inline int getNbGauss(int i) const { return _S[i]; } + + inline int getNbGeoType() const {return _nbtypegeo;} + + inline const int * const getNbElemGeoC() const {return _nbelegeoc;} + + inline const int * const getNbGaussGeo() const {return _nbgaussgeo;} + +}; + +} //END NAMESPACE + +#endif diff --git a/src/MEDMEM/MEDMEM_InterlacingTraits.hxx b/src/MEDMEM/MEDMEM_InterlacingTraits.hxx new file mode 100644 index 000000000..88f5d0f86 --- /dev/null +++ b/src/MEDMEM/MEDMEM_InterlacingTraits.hxx @@ -0,0 +1,42 @@ +#ifndef MEDMEM_INTERLACING_TRAITS_HXX +#define MEDMEM_INTERLACING_TRAITS_HXX + +#include "MEDMEM_Tags.hxx" + +namespace MEDMEM { + +struct __ERROR_INTERLACING_GAUSS_TRAITS_POLICY_INSTANCIATED_WITH_INCORRECT_TYPE {}; + +template < class INTERLACE_TAG, class GAUSS_TAG> +struct MEDMEM_InterlacingTraits +{ + typedef __ERROR_INTERLACING_GAUSS_TRAITS_POLICY_INSTANCIATED_WITH_INCORRECT_TYPE Type; +}; + +template <> +struct MEDMEM_InterlacingTraits< FullInterlace, Gauss > +{ + typedef FullInterlaceGaussPolicy Type; +}; + +template <> +struct MEDMEM_InterlacingTraits< FullInterlace, NoGauss > +{ + typedef FullInterlaceNoGaussPolicy Type; +}; + +template <> +struct MEDMEM_InterlacingTraits< NoInterlace, Gauss > +{ + typedef NoInterlaceGaussPolicy Type; +}; + +template <> +struct MEDMEM_InterlacingTraits< NoInterlace, NoGauss > +{ + typedef NoInterlaceNoGaussPolicy Type; +}; + +} // END NAMESPACE + +#endif diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx index e922d272e..3373f9c91 100644 --- a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx +++ b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx @@ -29,14 +29,14 @@ #include "MEDMEM_STRING.hxx" #include "MEDMEM_Exception.hxx" -#include "MEDMEM_Unit.hxx" -#include "MEDMEM_Array.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Mesh.hxx" +// #include "MEDMEM_Unit.hxx" +// #include "MEDMEM_Array.hxx" +// #include "MEDMEM_Support.hxx" +// #include "MEDMEM_Mesh.hxx" #include "MEDMEM_Compatibility21_22.hxx" +#include "MEDMEM_FieldForward.hxx" namespace MEDMEM { -template class FIELD; template class MED_FIELD_RDWR_DRIVER; template class MED_FIELD_RDONLY_DRIVER; template class MED_FIELD_WRONLY_DRIVER; @@ -44,10 +44,17 @@ template class MED_FIELD_WRONLY_DRIVER; template class MED_FIELD_DRIVER : public GENDRIVER { protected: + // Developement plus propre : + // - Il faudrait soit utiliser le type FIELD_ et ajouter à cette classe + // les accesseurs de FIELD<> utilisés dans les drivers + // - Ou bien avoir des drivers à deux paramètres template (le top) + // - Remarquez l'affreux cast dans le second constructeur : + // _ptrField( (FIELD *) ptrField ) + // Cela cast toujours le ptrField en FullInterlace + // Cela ne pose cependant pas de pb de fonctionement aux drivers FIELD * _ptrField; string _fieldName; int _fieldNum; - void search_field() ; public : @@ -59,13 +66,14 @@ public : /*! Constructor. */ - MED_FIELD_DRIVER():_ptrField((FIELD *) NULL), + MED_FIELD_DRIVER():_ptrField((FIELD *) MED_NULL), _fieldName(""),_fieldNum(MED_INVALID) {} /*! Constructor. */ - MED_FIELD_DRIVER(const string & fileName, FIELD * ptrField, + template + MED_FIELD_DRIVER(const string & fileName, FIELD * ptrField, MED_EN::med_mode_acces accessMode) : GENDRIVER(fileName,accessMode), _ptrField((FIELD *) ptrField), @@ -134,8 +142,11 @@ public : /*! Constructor. */ - IMED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD * ptrField): - MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY) { + template + IMED_FIELD_RDONLY_DRIVER(const string & fileName, + FIELD * ptrField): + MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY) + { BEGIN_OF("IMED_FIELD_RDONLY_DRIVER::IMED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); END_OF("IMED_FIELD_RDONLY_DRIVER::IMED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); } @@ -181,7 +192,9 @@ public : /*! Constructor. */ - IMED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD * ptrField): + template + IMED_FIELD_WRONLY_DRIVER(const string & fileName, + FIELD * ptrField): MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_WRONLY) { BEGIN_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); @@ -215,7 +228,9 @@ public : */ -template class IMED_FIELD_RDWR_DRIVER : public virtual IMED_FIELD_RDONLY_DRIVER, public virtual IMED_FIELD_WRONLY_DRIVER { +template class IMED_FIELD_RDWR_DRIVER : public virtual IMED_FIELD_RDONLY_DRIVER, + public virtual IMED_FIELD_WRONLY_DRIVER +{ public : @@ -227,8 +242,12 @@ public : /*! Constructor. */ - IMED_FIELD_RDWR_DRIVER(const string & fileName, FIELD * ptrField): - IMED_FIELD_RDONLY_DRIVER(fileName,ptrField),IMED_FIELD_WRONLY_DRIVER(fileName,ptrField),MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDWR) + template + IMED_FIELD_RDWR_DRIVER(const string & fileName, + FIELD * ptrField): + IMED_FIELD_RDONLY_DRIVER(fileName,ptrField), + IMED_FIELD_WRONLY_DRIVER(fileName,ptrField), + MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDWR) { BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD * ptrField)"); //_accessMode = MED_RDWR ; @@ -239,7 +258,11 @@ public : Copy constructor. */ IMED_FIELD_RDWR_DRIVER(const IMED_FIELD_RDWR_DRIVER & fieldDriver): - IMED_FIELD_RDONLY_DRIVER(fieldDriver),IMED_FIELD_WRONLY_DRIVER(fieldDriver),MED_FIELD_DRIVER(fieldDriver) {} + IMED_FIELD_RDONLY_DRIVER(fieldDriver), + IMED_FIELD_WRONLY_DRIVER(fieldDriver), + MED_FIELD_DRIVER(fieldDriver) + { + } /*! Destructor. @@ -258,7 +281,10 @@ template class MED_FIELD_RDONLY_DRIVER : public virtual IMED_FIELD_RDO public : MED_FIELD_RDONLY_DRIVER(); - MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD * ptrField); + + template + MED_FIELD_RDONLY_DRIVER(const string & fileName, + FIELD * ptrField); MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver):IMED_FIELD_RDONLY_DRIVER(fieldDriver) { _concreteFieldDrv = fieldDriver._concreteFieldDrv->copy(); } virtual ~MED_FIELD_RDONLY_DRIVER() { if (_concreteFieldDrv) delete _concreteFieldDrv; } @@ -277,7 +303,10 @@ protected: template class MED_FIELD_WRONLY_DRIVER : public virtual IMED_FIELD_WRONLY_DRIVER { public : MED_FIELD_WRONLY_DRIVER(); - MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD * ptrField); + + template + MED_FIELD_WRONLY_DRIVER(const string & fileName, + FIELD * ptrField); MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver):IMED_FIELD_WRONLY_DRIVER(fieldDriver) { _concreteFieldDrv = fieldDriver._concreteFieldDrv->copy(); } virtual ~MED_FIELD_WRONLY_DRIVER() { if (_concreteFieldDrv) delete _concreteFieldDrv;} @@ -299,7 +328,9 @@ public: /*! Constructor. */ - MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD * ptrField); + template + MED_FIELD_RDWR_DRIVER(const string & fileName, + FIELD * ptrField); MED_FIELD_RDWR_DRIVER(const MED_FIELD_RDWR_DRIVER & fieldDriver): IMED_FIELD_RDWR_DRIVER(fieldDriver) @@ -352,7 +383,11 @@ template MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER() { _concreteFieldDrv=new MED_FIELD_RDONLY_DRIVER21(); } -template MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, FIELD * ptrField) +template template < class INTERLACING_TAG > +MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, + FIELD * ptrField): + MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY), + IMED_FIELD_RDONLY_DRIVER(fileName,ptrField) { BEGIN_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); @@ -375,13 +410,17 @@ template MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER() { _concreteFieldDrv=new MED_FIELD_WRONLY_DRIVER21(); } -template MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, FIELD * ptrField) - { - BEGIN_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); +template template < class INTERLACING_TAG > +MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, + FIELD * ptrField): + MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY), + IMED_FIELD_WRONLY_DRIVER( fileName, ptrField) +{ + BEGIN_OF("MED_FIELD_WRONLY_DRIVER::MED_FIELD_WRONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); - _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_ECRI); + _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_ECRI); - END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); + END_OF("MED_FIELD_RDONLY_DRIVER::MED_FIELD_RDONLY_DRIVER(const string & fileName, const FIELD * ptrField)"); } /*--------------------- RDWR PART -------------------------------*/ @@ -392,13 +431,17 @@ template MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER() { _concreteFieldDrv=new MED_FIELD_RDWR_DRIVER21(); } -template MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, FIELD * ptrField) - { - BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD * ptrField)"); +template template < class INTERLACING_TAG > +MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, + FIELD * ptrField): + MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY), + IMED_FIELD_RDWR_DRIVER(fileName,ptrField) +{ + BEGIN_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD * ptrField)"); - _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_REMP); + _concreteFieldDrv = DRIVERFACTORY::buildFieldDriverFromFile(fileName,ptrField,MED_EN::MED_REMP); - END_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD * ptrField)"); + END_OF("MED_FIELD_RDWR_DRIVER::MED_FIELD_RDWR_DRIVER(const string & fileName, const FIELD * ptrField)"); } diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx index 04d7797e6..e3d706437 100644 --- a/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx +++ b/src/MEDMEM/MEDMEM_MedFieldDriver21.hxx @@ -24,20 +24,20 @@ #include "MEDMEM_define.hxx" -#include "MEDMEM_GenDriver.hxx" +#include "MEDMEM_DriversDef.hxx" #include "MEDMEM_Utilities.hxx" #include "MEDMEM_MedFieldDriver.hxx" #include "MEDMEM_STRING.hxx" #include "MEDMEM_Exception.hxx" #include "MEDMEM_Unit.hxx" -#include "MEDMEM_Array.hxx" + +#include "MEDMEM_ArrayInterface.hxx" +#include "MEDMEM_ArrayConvert.hxx" + #include "MEDMEM_Support.hxx" #include "MEDMEM_Mesh.hxx" namespace MEDMEM { -template class FIELD; - -// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt... /*! @@ -52,13 +52,20 @@ template class MED_FIELD_DRIVER21 : public virtual MED_FIELD_DRIVER protected: med_2_1::med_idt _medIdt; - void search_field() ; -public : + bool createFieldSupport(med_2_1::med_idt id, + string & fieldName, + med_2_1::med_int ndt, + med_2_1::med_int od, + SUPPORT & support, + string & meshName) const throw (MEDEXCEPTION); + + void getMeshGeometricType(med_2_1::med_idt id, + string & meshName, + MED_EN::medEntityMesh entite, + vector & geoType, + vector &nbOfElOfType) const; - // all MED cell type ?? Classe de Définition ?? - // static const medGeometryElement all_cell_type[MED_NBR_GEOMETRIE_MAILLE]; - - // static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]; +public : /*! Constructor. @@ -68,7 +75,9 @@ public : /*! Constructor. */ - MED_FIELD_DRIVER21(const string & fileName, FIELD * ptrField, + template + MED_FIELD_DRIVER21(const string & fileName, + FIELD * ptrField, MED_EN::med_mode_acces accessMode) : MED_FIELD_DRIVER(fileName,ptrField,accessMode),_medIdt(MED_INVALID) { @@ -126,7 +135,7 @@ public : //H5close(); // If we call H5close() all the files are closed. MED_FIELD_DRIVER::_status = MED_CLOSED; MED_FIELD_DRIVER21::_medIdt = MED_INVALID; - MESSAGE(" MED_FIELD_DRIVER21::close() : MEDfermer : MED_FIELD_DRIVER::_medIdt= " << _medIdt ); + MESSAGE(" MED_FIELD_DRIVER21::close() : MEDfermer : MED_FIELD_DRIVER21::_medIdt= " << _medIdt ); MESSAGE(" MED_FIELD_DRIVER21::close() : MEDfermer : err = " << err ); } END_OF("MED_FIELD_DRIVER21::close()"); @@ -156,13 +165,15 @@ public : /*! Constructor. */ - MED_FIELD_RDONLY_DRIVER21(const string & fileName, FIELD * ptrField): - IMED_FIELD_RDONLY_DRIVER(fileName,ptrField), + template + MED_FIELD_RDONLY_DRIVER21(const string & fileName, + FIELD * ptrField): + MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY), MED_FIELD_DRIVER21(fileName,ptrField,MED_EN::MED_RDONLY), - MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY) + IMED_FIELD_RDONLY_DRIVER(fileName,ptrField) { - BEGIN_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); - END_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); + BEGIN_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); + END_OF("MED_FIELD_RDONLY_DRIVER21::MED_FIELD_RDONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); } /*! @@ -215,13 +226,15 @@ public : /*! Constructor. */ - MED_FIELD_WRONLY_DRIVER21(const string & fileName, FIELD * ptrField): + template + MED_FIELD_WRONLY_DRIVER21(const string & fileName, + FIELD * ptrField): IMED_FIELD_WRONLY_DRIVER(fileName,ptrField), MED_FIELD_DRIVER21(fileName,ptrField,MED_EN::MED_WRONLY), MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_WRONLY) { - BEGIN_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); - END_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); + BEGIN_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); + END_OF("MED_FIELD_WRONLY_DRIVER21::MED_FIELD_WRONLY_DRIVER21(const string & fileName, const FIELD * ptrField)"); } /*! @@ -273,7 +286,9 @@ public : /*! Constructor. */ - MED_FIELD_RDWR_DRIVER21(const string & fileName, FIELD * ptrField): + template + MED_FIELD_RDWR_DRIVER21(const string & fileName, + FIELD * ptrField): MED_FIELD_WRONLY_DRIVER21(fileName,ptrField), MED_FIELD_RDONLY_DRIVER21(fileName,ptrField), IMED_FIELD_RDONLY_DRIVER(fileName,ptrField), @@ -319,49 +334,198 @@ private: /*--------------------- DRIVER PART -------------------------------*/ -// template void MED_FIELD_DRIVER::search_field() { -// const char * LOC = "template class MED_FIELD_DRIVER::search_field() :"; - -// // we search the field number !!!! -// if (_status==MED_OPENED) -// if (_fieldNum==MED_INVALID) { -// int err ; -// int numberOfFields = 0; //MED_INVALID -// // char fieldName[MED_TAILLE_NOM+1] = ""; -// char fieldName[MED_TAILLE_NOM+1] ; -// int numberOfComponents = 0; -// char * componentName = (char *) MED_NULL; -// char * unitName = (char *) MED_NULL; -// med_2_1::med_type_champ type ; -// numberOfFields = med_2_1::MEDnChamp(_medIdt,0) ; -// if ( numberOfFields <= 0 ) -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !")); -// for (int i=1;i<=numberOfFields;i++) { - -// numberOfComponents = med_2_1::MEDnChamp(_medIdt,i) ; -// if ( numberOfComponents <= 0 ) -// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) -// << "Be careful there is no compound for field n°" -// << i << "in file |"<<_fileName<<"| !")); - -// componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ; -// unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ; - -// err = med_2_1::MEDchampInfo(_medIdt, i, fieldName, &type, componentName, -// unitName, numberOfComponents) ; - -// delete[] componentName ; -// delete[] unitName ; -// MESSAGE("Champ "< bool +MED_FIELD_DRIVER21::createFieldSupport(med_2_1::med_idt id, + string & fieldName, + med_2_1::med_int ndt, + med_2_1::med_int od, + SUPPORT & support, + string & meshName) const throw (MEDEXCEPTION) +{ + + //EF : Gérer le meshName pour le driver 2.2 + const char * LOC="MED_FIELD_DRIVER::search_field(...)"; + + map > CellAndNodeEntities; + map >::iterator currentEntity; + CellAndNodeEntities[MED_EN::MED_CELL] = MED_EN::meshEntities[MED_EN::MED_CELL]; + CellAndNodeEntities[MED_EN::MED_NODE] = MED_EN::meshEntities[MED_EN::MED_NODE]; + list< MED_EN::medGeometryElement >::const_iterator currentGeometry; + + //med_2_1::med_entite_maillage + MED_EN::medEntityMesh entity; + bool alreadyFoundAnEntity=false, alreadyFoundPdtIt = false, anyGauss=false; + int numberOfElements = 0; + int numberOfGeometricType = 0; + //med_2_1::med_geometrie_element.. + MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE]; + int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE]; + int numberOfGaussPoint[MED_NBR_GEOMETRIE_MAILLE]; + + med_2_1::med_int ngauss=0, numdt=-1, numo=-1, nbPdtIt=0; //nmaa=0 + char dtunit[MED_TAILLE_PNOM21+1], maa[MED_TAILLE_NOM+1]; + med_2_1::med_float dt=-1.0; + //med_2_1::med_booleen local; + med_2_1::med_err ret=1; + + for (currentEntity = CellAndNodeEntities.begin(); + currentEntity != CellAndNodeEntities.end(); currentEntity++) { + for (currentGeometry = (*currentEntity).second.begin(); + currentGeometry != (*currentEntity).second.end(); currentGeometry++) { + + if ( (numberOfElements = med_2_1::MEDnVal(id, const_cast ( fieldName.c_str() ), + (med_2_1::med_entite_maillage) (*currentEntity).first, + (med_2_1::med_geometrie_element) *currentGeometry, + ndt, od)) <= 0 ) + continue; + + if ( alreadyFoundAnEntity ) { + if (entity != (*currentEntity).first ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName + << "| with (ndt,or) = (" << ndt << "," + << od << ") must not be defined on nodes and cells" )); + + } else { entity=(*currentEntity).first; alreadyFoundAnEntity = true; }; + + nbPdtIt = med_2_1::MEDnPasdetemps(id, const_cast ( fieldName.c_str() ), + (med_2_1::med_entite_maillage) (*currentEntity).first, + (med_2_1::med_geometrie_element) *currentGeometry ); + if ( nbPdtIt < 0 ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" + << ndt << "," << od << ") should be defined for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" )); + + ret = 0; alreadyFoundPdtIt = false; ngauss =0; + for ( med_2_1::med_int j=1; j <= nbPdtIt; j++ ) { + + // Search how many (,,) has + ret = med_2_1::MEDpasdetempsInfo(id, const_cast ( fieldName.c_str() ), + (med_2_1::med_entite_maillage) (*currentEntity).first, + (med_2_1::med_geometrie_element) *currentGeometry, + j,maa,&ngauss,&numdt,dtunit,&dt,&numo); + + // ret = med_2_2::MEDpasdetempsInfo(id, const_cast ( fieldName.c_str() ), + // (med_2_1::med_entite_maillage) (*currentEntity).first, + // (med_2_1::med_geometrie_element) *currentGeometry, + // j, &ngauss, &numdt, &numo, &dtunit, &dt, &maa, &local, &nmaa) + + if ( ndt == numdt && numo == od ) { + alreadyFoundPdtIt = true; + if ( ! meshName.empty() ) + if ( meshName != maa ) { + + // if ( nmaa > 1 ) + { + //EF : Gérer le meshName pour le driver 2.2 + // MESSAGE(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" << ndt << "," + // << ot << ") is defined on " << nmaa << " meshes, using mesh |" + // << maa << "|"); + // } + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" + << ndt << "," << od << ") for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" + << "is defined on mesh |" << maa << "| not on mesh |" << meshName )); + } + } + break; + } + } + + if ( !alreadyFoundPdtIt ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" + << ndt << "," << od << ") should be defined for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" )); + + if ( (ret != 0) || (ngauss < 1 ) ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Error in MEDpasdetempsInfo for Field |" << fieldName + << "| with (ndt,or) = (" + << ndt << "," << od << ") for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" )); ; + + //totalNumberOfElements+=numberOfElements; + numberOfElementsOfType[numberOfGeometricType] = numberOfElements/ngauss; + numberOfGaussPoint[numberOfGeometricType] = ngauss; + anyGauss = (anyGauss || (ngauss-1) ); + geometricType[numberOfGeometricType]= *currentGeometry; + numberOfGeometricType++; + + } // End Second For + + } // End Premier For + + if ( alreadyFoundAnEntity) { + support.setName(fieldName+"Support"); + support.setMeshName(string(maa)); // Vérifier que les différents noms de maillages lus soient identiques + support.setEntity(entity); + // REM : Signification précédente erronée pour un champ qui ne repose pas sur toutes les entités géométriques + // du maillage mais dont le SUPPORT a été crée à partir des informations d'un maillage, comme + // celà fût la plupart du temps. + support.setNumberOfGeometricType(numberOfGeometricType); + support.setGeometricType(geometricType); // Utile uniquement si setAll == false + support.setNumberOfElements(numberOfElementsOfType); //setNumberOfElements effectue une copie + support.setAll(true); + if (anyGauss) + support.setNumberOfGaussPoint(numberOfGaussPoint); + + return alreadyFoundAnEntity; + } else + return false; +} + +template void +MED_FIELD_DRIVER21::getMeshGeometricType(med_2_1::med_idt id, + string & meshName, + MED_EN::medEntityMesh entity, + vector & geoType, + vector &nbOfElOfType) const +{ + const char LOC[] = "MED_FIELD_DRIVER::getMeshGeometricType(...)"; + + int numberOfGeometricType=0; + MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE]; + int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE]; + med_2_1::med_int numberOfElements=0; + med_2_1::med_table quoi; + if (entity == MED_EN::MED_CELL) quoi=med_2_1::MED_CONN; + else + if (entity == MED_EN::MED_NODE) quoi=med_2_1::MED_COOR; + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Support Creation from Mesh |" << meshName + << "| on entity " << MED_EN::entNames[entity] + << "| is impossible, must be on MED_NODE or MED_CELL" )); + + list::const_iterator currentGeometry; + bool alreadyFoundAnEntity = false; + + for (currentGeometry = (MED_EN::meshEntities[entity]).begin(); + currentGeometry != (MED_EN::meshEntities[entity]).end(); currentGeometry++) { + + + if ( (numberOfElements = + med_2_1::MEDnEntMaa(id, + const_cast (meshName.c_str()), + quoi, + (med_2_1::med_entite_maillage) entity, + (med_2_1::med_geometrie_element) *currentGeometry, + med_2_1::MED_NOD) ) <= 0) + continue; + + alreadyFoundAnEntity = true; + numberOfElementsOfType[numberOfGeometricType] = numberOfElements; + geometricType[numberOfGeometricType] = *currentGeometry; + numberOfGeometricType++; + + } + geoType = vector(geometricType,geometricType+numberOfGeometricType); + nbOfElOfType = vector (numberOfElementsOfType,numberOfElementsOfType+numberOfGeometricType); + +} + /*--------------------- RDONLY PART -------------------------------*/ template GENDRIVER * MED_FIELD_RDONLY_DRIVER21::copy(void) const @@ -375,37 +539,71 @@ template void MED_FIELD_RDONLY_DRIVER21::read(void) const char * LOC = " MED_FIELD_RDONLY_DRIVER21::read() " ; BEGIN_OF(LOC); - if (MED_FIELD_DRIVER::_ptrField->_name=="") - MED_FIELD_DRIVER::_ptrField->_name = MED_FIELD_DRIVER::_fieldName ; - else - MED_FIELD_DRIVER::_fieldName = MED_FIELD_DRIVER::_ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!! - - MESSAGE("###### "<::_fieldName<<" fieldName : "<::_ptrField->_name); - - string MeshName = MED_FIELD_DRIVER::_ptrField->getSupport()->getMesh()->getName() ; - - if (MED_FIELD_DRIVER::_status==MED_OPENED) + typedef typename MEDMEM_ArrayInterface::Array ArrayNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayFull; + + if ( ( MED_FIELD_DRIVER::_fieldName.empty() ) && + ( MED_FIELD_DRIVER::_ptrField->_name.empty() ) ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) + <<" neither is set in driver nor in object FIELD.")) ; + + // If _fieldName is not set in driver, try to use _ptrfield->_fieldName + if ( ( MED_FIELD_DRIVER::_fieldName.empty() ) && + ( !MED_FIELD_DRIVER::_ptrField->_name.empty() ) ) + MED_FIELD_DRIVER::_fieldName=MED_FIELD_DRIVER::_ptrField->_name; + + if ( MED_FIELD_DRIVER::_fieldName.size() > MED_TAILLE_NOM ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) + <<" size in object driver FIELD is > MED_TAILLE_NOM .")); + + + MESSAGE("###### "<::_fieldName << + " fieldName : "<::_fieldName); + + + if (MED_FIELD_DRIVER::_status!=MED_OPENED) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": Method open must be called before method read.")) ; + +// EF : +// Si un support a été donnée au champ, pour des raisons de compatibilité avec +// les versions précédentes, ce support sera utilisé pour +// - Obtenir le nom du maillage sur lequel on veut lire le champ +// (eventuellement on pourrait l'utiliser pour selectionner un champ qui +// repose sur plusieurs maillages cf HOMARD-ASTER) +// - vérifier le type d'entité (MED_NOEUD xor MED_MAILLE xor MED_FACE xor MED_ARETE ) sur lequel +// il faut lire le champ qui est également retouvé. +// - Si le support défini une liste d'entité ( différente de MED_ALL_ELEMENTS), celle-ci est ignorée +// à la lecture et écrasé par les listes de profils lus s'il en existe + +// Si aucun support n'a été donné au champ : +// - A la lecture : Un support est crée et le type d'entité unique est lu +// (cf decision gt MED qu'un champ repose sur une entité unique ?), +// l'ensemble des types géométriques est lu, +// l'ensemble des profils par type géométrique est lu +// Le nom du maillage associé est lu mais le pointeur SUPPORT-MESH non initialisé + + char * fieldName = new char[MED_TAILLE_NOM+1] ; + + int err ; + int numberOfComponents = 0; + char * componentName = (char *) MED_NULL; + char * unitName = (char *) MED_NULL; + med_2_1::med_type_champ type ; + med_2_1::med_idt id = MED_FIELD_DRIVER21::_medIdt; + + // we search for the field med number of + // Having found variables , + // , , and attribute <_fieldNum> are set. + if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) { - - // search_field() ; - - char * fieldName ; - fieldName = new char[MED_TAILLE_NOM+1] ; - int err ; - int numberOfComponents = 0; - char * componentName = (char *) MED_NULL; - char * unitName = (char *) MED_NULL; - med_2_1::med_type_champ type ; - - // we search the field number !!!! - if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) { - int numberOfFields = 0; //MED_INVALID - numberOfFields = med_2_1::MEDnChamp(MED_FIELD_DRIVER21::_medIdt,0) ; - if ( numberOfFields <= 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !")); - for (int i=1;i<=numberOfFields;i++) { - - numberOfComponents = med_2_1::MEDnChamp(MED_FIELD_DRIVER21::_medIdt,i) ; + int numberOfFields = 0; //MED_INVALID + numberOfFields = med_2_1::MEDnChamp(id,0) ; + if ( numberOfFields <= 0 ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !")); + + for (int i=1;i<=numberOfFields;i++) + { + numberOfComponents = med_2_1::MEDnChamp(id,i) ; if ( numberOfComponents <= 0 ) // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) // << "Be careful there is no compound for field n°" @@ -415,159 +613,251 @@ template void MED_FIELD_RDONLY_DRIVER21::read(void) componentName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ; unitName = new char[numberOfComponents*MED_TAILLE_PNOM21+1] ; - err = med_2_1::MEDchampInfo(MED_FIELD_DRIVER21::_medIdt, i, fieldName, &type, componentName, - unitName, numberOfComponents) ; - + err = med_2_1::MEDchampInfo(id, i, fieldName, &type, componentName, + unitName, numberOfComponents) ; + MESSAGE("Champ "<::_fieldName.c_str()<<"#"); - if ( !strcmp(fieldName,MED_FIELD_DRIVER::_fieldName.c_str()) ) { - MESSAGE("FOUND FIELD "<< fieldName <<" : "<::_fieldNum = i ; - break ; - } + if ( !strcmp(fieldName,MED_FIELD_DRIVER::_fieldName.c_str()) ) + { + MESSAGE("FOUND FIELD "<< fieldName <<" : "<::_fieldNum = i ; + break ; + } // not found : release memory and search next field ! delete[] componentName ; delete[] unitName ; } - } + } - delete[] fieldName ; - - if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<::_fieldName << " not found in file " << MED_FIELD_DRIVER::_fileName ) ); - MESSAGE ("FieldNum : "<::_fieldNum); - - // int err ; - // int NumberOfComponents = med_2_1::MEDnChamp(MED_FIELD_DRIVER21::_medIdt,MED_FIELD_DRIVER::_fieldNum) ; - if (numberOfComponents < 1) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component")) ; // use iostring ! - // test type to check if it is rigth !!!??? - MED_FIELD_DRIVER::_ptrField->_numberOfComponents = numberOfComponents ; - MED_FIELD_DRIVER::_ptrField->_componentsTypes = new int[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_componentsNames = new string[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_componentsDescriptions = new string[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ; - for (int i=0; i::_ptrField->_componentsTypes[i] = 1 ; - - // PG : what about space !!! - MED_FIELD_DRIVER::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ; - SCRUTE(MED_FIELD_DRIVER::_ptrField->_componentsNames[i]); - MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ; - SCRUTE(MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i]); - } - delete[] componentName; - delete[] unitName; - - // read values for each geometric type in _support - int NumberOfTypes = MED_FIELD_DRIVER::_ptrField->_support->getNumberOfTypes() ; - const MED_EN::medGeometryElement *Types = MED_FIELD_DRIVER::_ptrField->_support->getTypes() ; - T ** myValues = new T*[NumberOfTypes] ; - int * NumberOfValues = new int[NumberOfTypes] ; - int TotalNumberOfValues = 0 ; - MESSAGE ("NumberOfTypes :"<< NumberOfTypes); - MED_FIELD_DRIVER::_ptrField->_numberOfValues=0 ; - for (int i=0; i::_ptrField->_support->getEntity()); - NumberOfValues[i] = - MEDnVal(MED_FIELD_DRIVER21::_medIdt, - const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), - (med_2_1::med_entite_maillage)MED_FIELD_DRIVER::_ptrField->_support->getEntity(), - (med_2_1::med_geometrie_element)Types[i], - MED_FIELD_DRIVER::_ptrField->_iterationNumber, - MED_FIELD_DRIVER::_ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss - // test if NumberOfValues is the same in _support !!! TODO that !! - // we suppose it is - // we could allocate array - myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ; - TotalNumberOfValues+=NumberOfValues[i] ;// diviser par le nombre de point de gauss - char * ProfilName = new char[MED_TAILLE_NOM+1]; - MESSAGE ("NumberOfValues :"<< NumberOfValues[i]); - MESSAGE ("NumberOfComponents :"<< numberOfComponents); - MESSAGE ("MESH_NAME :"<< MeshName.c_str()); - MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER::_fieldName.c_str()); - MESSAGE ("MED_ENTITE :"<< (med_2_1::med_entite_maillage) MED_FIELD_DRIVER::_ptrField->_support->getEntity()); - MESSAGE("MED_GEOM :"<<(med_2_1::med_geometrie_element)Types[i]); - MESSAGE("Iteration :"<::_ptrField->getIterationNumber()); - MESSAGE("Order :"<::_ptrField->getOrderNumber()); - MED_FIELD_DRIVER::_ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! - med_2_1::med_err ret; + delete[] fieldName ; + + if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) + throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<::_fieldName << " not found in file " << MED_FIELD_DRIVER::_fileName ) ); + + MESSAGE ("FieldNum : "<::_fieldNum); + + if (numberOfComponents < 1) + { + delete[] componentName; delete[] unitName; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component found for field " + << MED_FIELD_DRIVER::_fieldName)) ; + } + + // Pourquoi _ptrField est toujour null et non MED_FIELD_DRIVER::_ptrField + switch ( (med_2_1::med_type_champ) MED_FIELD_DRIVER::_ptrField->_valueType ) { + case med_2_1::MED_INT : + case med_2_1::MED_INT32 : + case med_2_1::MED_INT64 : + if ( type == ( med_2_1::MED_REEL64 ) ) { + delete[] componentName; delete[] unitName; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field Type in file (" << type + <<") differs from FIELD object type (" << + MED_FIELD_DRIVER::_ptrField->_valueType << ")" )) ; + } + break; + default: + break; + } + + + string meshName=""; + bool haveSupport = false; + if ( MED_FIELD_DRIVER::_ptrField->getSupport() ) { + // Verif sur la taille du meshName + meshName = MED_FIELD_DRIVER::_ptrField->getSupport()->getMesh()->getName() ; + haveSupport = true; + } + + // Cherche le type d'entité, le nombre d'entité par type géométrique sur le type d'entité + // (MED_MAILLE ou MED_NOEUD uniquement car MEDMEMOIRE ne gère pas la connectivité descendante). + // et crée le support correspondant. + SUPPORT * mySupport = new SUPPORT(); + bool found = createFieldSupport(id,MED_FIELD_DRIVER::_fieldName, + MED_FIELD_DRIVER::_ptrField->_iterationNumber, + MED_FIELD_DRIVER::_ptrField->_orderNumber, + *mySupport, meshName) ; + if ( !found ) { + delete mySupport; delete[] componentName; delete[] unitName; + MED_FIELD_DRIVER::_fieldNum = MED_INVALID ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Can't find any entity for field |" + << MED_FIELD_DRIVER::_fieldName + << "| with (it,or) = (" + << MED_FIELD_DRIVER::_ptrField->_iterationNumber << "," + << MED_FIELD_DRIVER::_ptrField->_orderNumber << "), on mesh " + << meshName << "|" )); + } + + if (! haveSupport) + meshName = mySupport->getMeshName(); + else { + if ( mySupport->getEntity() != MED_FIELD_DRIVER::_ptrField->getSupport()->getEntity() ) { + MED_EN::medEntityMesh ent = mySupport->getEntity(); + delete mySupport; delete[] componentName; delete[] unitName; + MED_FIELD_DRIVER::_fieldNum = MED_INVALID ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Given entity |" + << MED_EN::entNames[MED_FIELD_DRIVER::_ptrField-> + getSupport()->getEntity()] + << "| for field |" + << MED_FIELD_DRIVER::_fieldName + << "| with (it,or) = (" + << MED_FIELD_DRIVER::_ptrField->_iterationNumber << "," + << MED_FIELD_DRIVER::_ptrField->_orderNumber << "), on mesh " + << meshName << "| differs from found entity |" + << MED_EN::entNames[ent] << "|." + )); + } + mySupport->setName( MED_FIELD_DRIVER::_ptrField->getSupport()->getName() ); + mySupport->setMesh( MED_FIELD_DRIVER::_ptrField->getSupport()->getMesh() ); + mySupport->setDescription(MED_FIELD_DRIVER::_ptrField->getSupport()->getDescription()); + } + + // Test si le Support du Champ repose ou non sur toutes les entités géométriques du maillage. + // Pour tester les profils aussi ? + vector< MED_EN::medGeometryElement > meshGeoType; + vector< int > meshNbOfElOfType; + getMeshGeometricType(id,meshName,mySupport->getEntity(),meshGeoType,meshNbOfElOfType); + vector < MED_EN::medGeometryElement > v1( mySupport->getTypes(), + mySupport->getTypes()+mySupport->getNumberOfTypes() ); + vector < int > v2(mySupport->getNumberOfElements(), + mySupport->getNumberOfElements()+mySupport->getNumberOfTypes() ); + if ( ( meshGeoType != v1 ) || meshNbOfElOfType != v2 ) { + mySupport->setAll(false); + } + + //??support->setNumber(MEDSKYLINEARRAY * Number); + //??support->setNumber(const int * index, const int* value, bool shallowCopy=false); + + // If an error occurs while reading the field, these allocated FIELD member will be deleted + MED_FIELD_DRIVER::_ptrField->_name = MED_FIELD_DRIVER::_fieldName; + MED_FIELD_DRIVER::_ptrField->_numberOfComponents = numberOfComponents ; + MED_FIELD_DRIVER::_ptrField->_componentsTypes = new int[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_componentsNames = new string[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_componentsDescriptions = new string[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ; + + for (int i=0; i::_ptrField->_componentsTypes[i] = 1 ; + MED_FIELD_DRIVER::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ; + SCRUTE(MED_FIELD_DRIVER::_ptrField->_componentsNames[i]); + MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM21,MED_TAILLE_PNOM21) ; + SCRUTE(MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i]); + } + + delete[] componentName; + delete[] unitName; + + // read values for each geometric type in _support + int NumberOfTypes = mySupport->getNumberOfTypes() ; + const MED_EN::medGeometryElement *Types = mySupport->getTypes() ; + T ** myValues = new T*[NumberOfTypes] ; + int * NumberOfValues = new int[NumberOfTypes] ; + int TotalNumberOfValues = 0 ; // Profils a gerer en 2.2 Rmq from EF + MESSAGE ("NumberOfTypes :"<< NumberOfTypes); + MED_FIELD_DRIVER::_ptrField->_numberOfValues=0 ; + + for (int i=0; igetEntity()); + +// NumberOfValues[i] = +// MEDnVal(MED_FIELD_DRIVER21::_medIdt, +// const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), +// (med_2_1::med_entite_maillage)MED_FIELD_DRIVER::_ptrField->_support->getEntity(), +// (med_2_1::med_geometrie_element)Types[i], +// MED_FIELD_DRIVER::_ptrField->_iterationNumber, +// MED_FIELD_DRIVER::_ptrField->_orderNumber) ; + + NumberOfValues[i] = mySupport->getNumberOfElements(Types[i]) + * mySupport->getNumberOfGaussPoint(Types[i]); + + myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ; + TotalNumberOfValues+=NumberOfValues[i] ; + char * ProfilName = new char[MED_TAILLE_NOM+1]; + MESSAGE ("NumberOfValues :"<< NumberOfValues[i]); + MESSAGE ("NumberOfComponents :"<< numberOfComponents); + MESSAGE ("MESH_NAME :"<< meshName.c_str()); + MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER::_fieldName.c_str()); + MESSAGE ("MED_ENTITE :"<< (med_2_1::med_entite_maillage) mySupport->getEntity()); + MESSAGE("MED_GEOM :"<<(med_2_1::med_geometrie_element)Types[i]); + MESSAGE("Iteration :"<::_ptrField->getIterationNumber()); + MESSAGE("Order :"<::_ptrField->getOrderNumber()); + MED_FIELD_DRIVER::_ptrField->_numberOfValues+=mySupport->getNumberOfElements(Types[i]); // Ne doit pas prendre en compte les points de Gauss + + med_2_1::med_err ret; #if defined(IRIX64) || defined(OSF1) || defined(VPP5000) - int lgth2=NumberOfValues[i]*numberOfComponents; - if(_ptrField->getValueType()==MED_EN::MED_INT32) - { - med_2_1::med_int *temp=new med_2_1::med_int[lgth2]; - ret=med_2_1::MEDchampLire(MED_FIELD_DRIVER21::_medIdt,const_cast (MeshName.c_str()), + int lgth2=NumberOfValues[i]*numberOfComponents; + if(MED_FIELD_DRIVER::_ptrField->getValueType()==MED_EN::MED_INT32) + { + med_2_1::med_int *temp=new med_2_1::med_int[lgth2]; + ret=med_2_1::MEDchampLire(id,const_cast (meshName.c_str()), const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), (unsigned char*) temp, med_2_1::MED_NO_INTERLACE, MED_ALL, ProfilName, - (med_2_1::med_entite_maillage) MED_FIELD_DRIVER::_ptrField->_support->getEntity(),(med_2_1::med_geometrie_element)Types[i], + (med_2_1::med_entite_maillage) mySupport->getEntity(), + (med_2_1::med_geometrie_element) Types[i], MED_FIELD_DRIVER::_ptrField->getIterationNumber(), MED_FIELD_DRIVER::_ptrField->getOrderNumber() - ); - for(int i2=0;i2::_medIdt,const_cast (MeshName.c_str()), - const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), - (unsigned char*) myValues[i], - med_2_1::MED_NO_INTERLACE, - MED_ALL, - ProfilName, - (med_2_1::med_entite_maillage) MED_FIELD_DRIVER::_ptrField->_support->getEntity(),(med_2_1::med_geometrie_element)Types[i], - MED_FIELD_DRIVER::_ptrField->getIterationNumber(), - MED_FIELD_DRIVER::_ptrField->getOrderNumber() - ); - if (ret < 0) { - // we must do some delete !!! - for(int j=0; j<=i;j++) - delete[] myValues[j]; - delete[] myValues; - delete[] NumberOfValues ; - delete[] ProfilName; - delete[] MED_FIELD_DRIVER::_ptrField->_componentsTypes ; - delete[] MED_FIELD_DRIVER::_ptrField->_componentsNames ; - delete[] MED_FIELD_DRIVER::_ptrField->_componentsUnits ; - delete[] MED_FIELD_DRIVER::_ptrField->_componentsDescriptions ; - delete[] MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits ; - MED_FIELD_DRIVER::_ptrField->_componentsTypes = NULL ; - MED_FIELD_DRIVER::_ptrField->_componentsNames = NULL ; - MED_FIELD_DRIVER::_ptrField->_componentsUnits = NULL ; - MED_FIELD_DRIVER::_ptrField->_componentsDescriptions = NULL ; - MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits = NULL ; - MED_FIELD_DRIVER::_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number - throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ; - } - - delete[] ProfilName ; + ret=med_2_1::MEDchampLire(id,const_cast (meshName.c_str()), + const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), + (unsigned char*) myValues[i], + med_2_1::MED_NO_INTERLACE, + MED_ALL, + ProfilName, + (med_2_1::med_entite_maillage) mySupport->getEntity() + ,(med_2_1::med_geometrie_element)Types[i], + MED_FIELD_DRIVER::_ptrField->getIterationNumber(), + MED_FIELD_DRIVER::_ptrField->getOrderNumber() + ); + if (ret < 0) + { + // The Field can't be read then we mustdelete all previously allocated members in FIELD + for(int j=0; j<=i;j++) + delete[] myValues[j]; + delete[] myValues; + delete[] NumberOfValues ; + delete[] ProfilName; + delete[] MED_FIELD_DRIVER::_ptrField->_componentsTypes ; + delete[] MED_FIELD_DRIVER::_ptrField->_componentsNames ; + delete[] MED_FIELD_DRIVER::_ptrField->_componentsUnits ; + delete[] MED_FIELD_DRIVER::_ptrField->_componentsDescriptions ; + delete[] MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits ; + MED_FIELD_DRIVER::_ptrField->_componentsTypes = NULL ; + MED_FIELD_DRIVER::_ptrField->_componentsNames = NULL ; + MED_FIELD_DRIVER::_ptrField->_componentsUnits = NULL ; + MED_FIELD_DRIVER::_ptrField->_componentsDescriptions = NULL ; + MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits = NULL ; + MED_FIELD_DRIVER::_fieldNum = MED_INVALID ; // we have not found right field, so reset the field number + throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ; } - // allocate _value - // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1) - // MEDARRAY * Values = new MEDARRAY(MED_FIELD_DRIVER::_ptrField->getNumberOfComponents(),TotalNumberOfValues/MED_FIELD_DRIVER::_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE); - - if (MED_FIELD_DRIVER::_ptrField->_value==NULL) - MED_FIELD_DRIVER::_ptrField->_value=new MEDARRAY(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE); - - MEDARRAY * Values = MED_FIELD_DRIVER::_ptrField->_value ; // create by constructor ??? - // check if dimensions are right : inutile : c'est dans le constructeur !!! - //if (Values->getLeadingValue() != numberOfComponents) - // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<getLeadingValue()<<" and "<getLengthValue() != TotalNumberOfValues) - // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<getLengthValue()<<" and "<getRow(i+1) ; - int Count = 1 ; - for (int j=0; jgetRow(i+1) ; + int Count = 1 ; + for (int j=0; j::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! + // MED_FIELD_DRIVER::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! int offset = NumberOf*i ; for (int k=0 ; k void MED_FIELD_RDONLY_DRIVER21::read(void) Count++; } } - } + } - for (int j=0; j::_ptrField->_isRead = true ; + if (MED_FIELD_DRIVER::_ptrField->_value != NULL) + delete MED_FIELD_DRIVER::_ptrField->_value; + + if ( MED_FIELD_DRIVER::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) + { + // dynamic_cast inutile + MED_FIELD_DRIVER::_ptrField->_value=dynamic_cast(ArrayConvert(*Values)); + delete Values; } + else + MED_FIELD_DRIVER::_ptrField->_value=Values; + + MED_FIELD_DRIVER::_ptrField->_isRead = true ; + MED_FIELD_DRIVER::_ptrField->_support=mySupport; //Prévenir l'utilisateur ? + END_OF(LOC); } @@ -614,6 +917,10 @@ template void MED_FIELD_WRONLY_DRIVER21::write(void) const { const char * LOC = "MED_FIELD_WRONLY_DRIVER21::write(void) const " ; BEGIN_OF(LOC); + + typedef typename MEDMEM_ArrayInterface::Array ArrayNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayFull; + if (MED_FIELD_DRIVER::_status==MED_OPENED) { int err ; @@ -719,10 +1026,26 @@ template void MED_FIELD_WRONLY_DRIVER21::write(void) const int Index = 1 ; const MED_EN::medGeometryElement * Types = mySupport->getTypes() ; const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ; + + const T * value = NULL; + ArrayFull * myArray = NULL; + if ( MED_FIELD_DRIVER::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) + myArray = MED_FIELD_DRIVER::_ptrField->getArrayNoGauss(); + else { + // En attendant la convertion de FIELD, on utilise le ArrayConvert + // ( les infos _ptrField-> sont les mêmes ) + myArray = ArrayConvert( *( dynamic_cast< ArrayNo * > + (MED_FIELD_DRIVER::_ptrField->getArrayNoGauss() + )) + ); + } + for (int i=0;igetNumberOfElements(Types[i]) ; - const T * value = MED_FIELD_DRIVER::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ; +// const T * value = MED_FIELD_DRIVER::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ; + + value = myArray->getRow(Index) ; MESSAGE("MED_FIELD_DRIVER21::_medIdt : "<::_medIdt); MESSAGE("MeshName.c_str() : "< void MED_FIELD_WRONLY_DRIVER21::write(void) const MED_FIELD_DRIVER::_ptrField->getOrderNumber() ); if (err < MED_VALID ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) - <<": Error in writing Field "<< MED_FIELD_DRIVER::_ptrField->getName() <<", type "<::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray; + + throw MEDEXCEPTION(LOCALIZED( STRING(LOC) + <<": Error in writing Field "<< MED_FIELD_DRIVER::_ptrField->getName() <<", type "<::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray; + } END_OF(LOC); diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver22.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver22.hxx index 8eca1ff4e..4e1df7f57 100644 --- a/src/MEDMEM/MEDMEM_MedFieldDriver22.hxx +++ b/src/MEDMEM/MEDMEM_MedFieldDriver22.hxx @@ -24,20 +24,20 @@ #include "MEDMEM_define.hxx" -#include "MEDMEM_GenDriver.hxx" +#include "MEDMEM_DriversDef.hxx" #include "MEDMEM_Utilities.hxx" #include "MEDMEM_MedFieldDriver.hxx" #include "MEDMEM_STRING.hxx" #include "MEDMEM_Exception.hxx" #include "MEDMEM_Unit.hxx" -#include "MEDMEM_Array.hxx" + +#include "MEDMEM_ArrayInterface.hxx" +#include "MEDMEM_ArrayConvert.hxx" + #include "MEDMEM_Support.hxx" #include "MEDMEM_Mesh.hxx" namespace MEDMEM { -template class FIELD; - -// A QD LA CLASSE MED_ALL_ELEMENTS_DRIVER.... :) pour mutualiser le open ..... avec led _medIdt... /*! @@ -53,15 +53,21 @@ protected: med_2_2::med_idt _medIdt; - void search_field() ; - + bool createFieldSupport(med_2_2::med_idt id, + string & fieldName, + med_2_2::med_int ndt, + med_2_2::med_int od, + SUPPORT & support, + string & meshName) const throw (MEDEXCEPTION); + + void getMeshGeometricType(med_2_2::med_idt id, + string & meshName, + MED_EN::medEntityMesh entite, + vector & geoType, + vector &nbOfElOfType) const; + public : - // all MED cell type ?? Classe de Définition ?? - // static const medGeometryElement all_cell_type[MED_NBR_GEOMETRIE_MAILLE]; - - // static const char * const all_cell_type_tab [MED_NBR_GEOMETRIE_MAILLE]; - /*! Constructor. */ @@ -70,7 +76,9 @@ public : /*! Constructor. */ - MED_FIELD_DRIVER22(const string & fileName, FIELD * ptrField, + template + MED_FIELD_DRIVER22(const string & fileName, + FIELD * ptrField, MED_EN::med_mode_acces accessMode) : MED_FIELD_DRIVER(fileName,ptrField,accessMode),_medIdt(MED_INVALID) { @@ -104,16 +112,16 @@ public : ); MESSAGE(LOC<<"_fileName.c_str : "<< MED_FIELD_DRIVER::_fileName.c_str()<<",mode : "<< MED_FIELD_DRIVER::_accessMode); - _medIdt = med_2_2::MEDouvrir( (const_cast (MED_FIELD_DRIVER::_fileName.c_str())),(med_2_2::med_mode_acces) MED_FIELD_DRIVER::_accessMode); - MESSAGE(LOC<<"_medIdt : "<< _medIdt ); - if (_medIdt > 0) + MED_FIELD_DRIVER22::_medIdt = med_2_2::MEDouvrir( (const_cast (MED_FIELD_DRIVER::_fileName.c_str())),(med_2_2::med_mode_acces) MED_FIELD_DRIVER::_accessMode); + MESSAGE(LOC<<"_medIdt : "<< MED_FIELD_DRIVER22::_medIdt ); + if (MED_FIELD_DRIVER22::_medIdt > 0) MED_FIELD_DRIVER::_status=MED_OPENED; else { MED_FIELD_DRIVER::_status = MED_INVALID; - _medIdt = MED_INVALID; + MED_FIELD_DRIVER22::_medIdt = MED_INVALID; throw MED_EXCEPTION (LOCALIZED( STRING(LOC) << "Can't open |" << MED_FIELD_DRIVER::_fileName - << "|, _medIdt : " << _medIdt + << "|, _medIdt : " << MED_FIELD_DRIVER22::_medIdt ) ); } @@ -125,16 +133,15 @@ public : BEGIN_OF("MED_FIELD_DRIVER22::close()"); med_2_2::med_int err = 0; if (MED_FIELD_DRIVER::_status == MED_OPENED) { - err=med_2_2::MEDfermer(_medIdt); + err=med_2_2::MEDfermer(MED_FIELD_DRIVER22::_medIdt); //H5close(); // If we call H5close() all the files are closed. MED_FIELD_DRIVER::_status = MED_CLOSED; - _medIdt = MED_INVALID; - MESSAGE(" MED_FIELD_DRIVER22::close() : MEDfermer : _medIdt= " << _medIdt ); + MED_FIELD_DRIVER22::_medIdt = MED_INVALID; + MESSAGE(" MED_FIELD_DRIVER22::close() : MEDfermer : _medIdt= " << MED_FIELD_DRIVER22::_medIdt ); MESSAGE(" MED_FIELD_DRIVER22::close() : MEDfermer : err = " << err ); } END_OF("MED_FIELD_DRIVER22::close()"); } - }; /*! @@ -158,13 +165,15 @@ public : /*! Constructor. */ - MED_FIELD_RDONLY_DRIVER22(const string & fileName, FIELD * ptrField): + template + MED_FIELD_RDONLY_DRIVER22(const string & fileName, + FIELD * ptrField): IMED_FIELD_RDONLY_DRIVER(fileName,ptrField), MED_FIELD_DRIVER22(fileName,ptrField,MED_EN::MED_RDONLY), MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDONLY) { - BEGIN_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); - END_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); + BEGIN_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); + END_OF("MED_FIELD_RDONLY_DRIVER22::MED_FIELD_RDONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); } /*! @@ -174,7 +183,7 @@ public : IMED_FIELD_RDONLY_DRIVER(fieldDriver), MED_FIELD_DRIVER22(fieldDriver), MED_FIELD_DRIVER(fieldDriver) - {}; + {} /*! Destructor. @@ -217,14 +226,16 @@ public : /*! Constructor. */ - MED_FIELD_WRONLY_DRIVER22(const string & fileName, FIELD * ptrField): + template + MED_FIELD_WRONLY_DRIVER22(const string & fileName, + FIELD * ptrField): IMED_FIELD_WRONLY_DRIVER(fileName,ptrField), MED_FIELD_DRIVER22(fileName,ptrField,MED_EN::MED_WRONLY), MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_WRONLY) { - BEGIN_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); - END_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); - }; + BEGIN_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); + END_OF("MED_FIELD_WRONLY_DRIVER22::MED_FIELD_WRONLY_DRIVER22(const string & fileName, const FIELD * ptrField)"); + } /*! Copy constructor. @@ -233,7 +244,7 @@ public : IMED_FIELD_WRONLY_DRIVER(fieldDriver), MED_FIELD_DRIVER22(fieldDriver), MED_FIELD_DRIVER(fieldDriver) - {}; + {} /*! Destructor. @@ -275,7 +286,9 @@ public : /*! Constructor. */ - MED_FIELD_RDWR_DRIVER22(const string & fileName, FIELD * ptrField): + template + MED_FIELD_RDWR_DRIVER22(const string & fileName, + FIELD * ptrField): MED_FIELD_WRONLY_DRIVER22(fileName,ptrField), MED_FIELD_RDONLY_DRIVER22(fileName,ptrField), IMED_FIELD_RDONLY_DRIVER(fileName,ptrField), @@ -283,10 +296,10 @@ public : MED_FIELD_DRIVER(fileName,ptrField,MED_EN::MED_RDWR), IMED_FIELD_RDWR_DRIVER(fileName,ptrField) { - BEGIN_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD * ptrField)"); + BEGIN_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD * ptrField)"); //_accessMode = MED_RDWR ; - END_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD * ptrField)"); - }; + END_OF("MED_FIELD_RDWR_DRIVER22::MED_FIELD_RDWR_DRIVER22(const string & fileName, const FIELD * ptrField)"); + } /*! Copy constructor. @@ -326,49 +339,207 @@ private: /*--------------------- DRIVER PART -------------------------------*/ -// template void MED_FIELD_DRIVER::search_field() { -// const char * LOC = "template class MED_FIELD_DRIVER::search_field() :"; - -// // we search the field number !!!! -// if (_status==MED_OPENED) -// if (_fieldNum==MED_INVALID) { -// int err ; -// int numberOfFields = 0; //MED_INVALID -// // char fieldName[MED_TAILLE_NOM+1] = ""; -// char fieldName[MED_TAILLE_NOM+1] ; -// int numberOfComponents = 0; -// char * componentName = (char *) MED_NULL; -// char * unitName = (char *) MED_NULL; -// med_2_2::med_type_champ type ; -// numberOfFields = med_2_2::MEDnChamp(_medIdt,0) ; -// if ( numberOfFields <= 0 ) -// throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !")); -// for (int i=1;i<=numberOfFields;i++) { - -// numberOfComponents = med_2_2::MEDnChamp(_medIdt,i) ; -// if ( numberOfComponents <= 0 ) -// throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) -// << "Be careful there is no compound for field n°" -// << i << "in file |"<<_fileName<<"| !")); - -// componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ; -// unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ; - -// err = med_2_2::MEDchampInfo(_medIdt, i, fieldName, &type, componentName, -// unitName, numberOfComponents) ; - -// delete[] componentName ; -// delete[] unitName ; -// MESSAGE("Champ "< bool +MED_FIELD_DRIVER22::createFieldSupport(med_2_2::med_idt id, + string & fieldName, + med_2_2::med_int ndt, + med_2_2::med_int od, + SUPPORT & support, + string & meshName) const throw (MEDEXCEPTION) +{ + + //EF : Gérer le meshName pour le driver 2.2 + const char * LOC="MED_FIELD_DRIVER::search_field(...)"; + + map > CellAndNodeEntities; + map >::iterator currentEntity; + CellAndNodeEntities[MED_EN::MED_CELL] = MED_EN::meshEntities[MED_EN::MED_CELL]; + CellAndNodeEntities[MED_EN::MED_NODE] = MED_EN::meshEntities[MED_EN::MED_NODE]; + list< MED_EN::medGeometryElement >::const_iterator currentGeometry; + + //med_2_2::med_entite_maillage + MED_EN::medEntityMesh entity; + bool alreadyFoundAnEntity=false, alreadyFoundPdtIt = false, anyGauss=false; + int numberOfElements = 0; + int numberOfGeometricType = 0; + //med_2_2::med_geometrie_element.. + MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE]; + int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE]; + int numberOfGaussPoint[MED_NBR_GEOMETRIE_MAILLE]; + + med_2_2::med_int nmaa=0, ngauss=0, numdt=-1, numo=-1, nbPdtIt=0; + char dtunit[MED_TAILLE_PNOM22+1]; + char maa[MED_TAILLE_NOM+1]; + med_2_2::med_float dt=-1.0; + med_2_2::med_booleen local; + med_2_2::med_err ret=1; + + for (currentEntity = CellAndNodeEntities.begin(); + currentEntity != CellAndNodeEntities.end(); currentEntity++) { + for (currentGeometry = (*currentEntity).second.begin(); + currentGeometry != (*currentEntity).second.end(); currentGeometry++) { + + + if ( (nbPdtIt = med_2_2::MEDnPasdetemps(id, const_cast ( fieldName.c_str() ), + (med_2_2::med_entite_maillage) (*currentEntity).first, + (med_2_2::med_geometrie_element) *currentGeometry )) <= 0 ) + continue; + + + + if ( alreadyFoundAnEntity ) { + if (entity != (*currentEntity).first ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName + << "| with (ndt,or) = (" << ndt << "," + << od << ") must not be defined on nodes and cells" )); + + } else { entity=(*currentEntity).first; alreadyFoundAnEntity = true; }; + + + ret = 0; alreadyFoundPdtIt = false; ngauss =0; + for ( med_2_2::med_int j=1; j <= nbPdtIt; j++ ) { + + // Search how many (,,) has + ret += med_2_2::MEDpasdetempsInfo(id, const_cast ( fieldName.c_str() ), + (med_2_2::med_entite_maillage) (*currentEntity).first, + (med_2_2::med_geometrie_element) *currentGeometry, + j, &ngauss, &numdt, &numo, dtunit, &dt, + maa, &local, &nmaa); + + if ( ndt == numdt && numo == od ) { + alreadyFoundPdtIt = true; + + if ( nmaa > 1 ) { + MESSAGE(LOC<<" Field |" << fieldName << "| with (ndt,or) = (" + << ndt << "," << od << ") for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" + << "is defined on multiple meshes, using dafault mesh |" << maa << "|" ); + } + + if ( !local) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" + << ndt << "," << od << ") for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" + << "is using a mesh on a different file which is not yet supported" )); + + if ( ! meshName.empty() ) + if ( meshName != maa ) { + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" + << ndt << "," << od << ") for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" + << "is defined on mesh |" << maa << "| not on mesh |" << meshName )); + } + break; + } + + } + + if ( !alreadyFoundPdtIt ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field |" << fieldName << "| with (ndt,or) = (" + << ndt << "," << od << ") should be defined for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" )); + + if ( (ret != 0) || (ngauss < 1 ) ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Error in MEDpasdetempsInfo for Field |" << fieldName + << "| with (ndt,or) = (" + << ndt << "," << od << ") for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" )); ; + + if ( (numberOfElements = med_2_2::MEDnVal(id, const_cast ( fieldName.c_str() ), + (med_2_2::med_entite_maillage) (*currentEntity).first, + (med_2_2::med_geometrie_element) *currentGeometry, + numdt, numo, maa, med_2_2::MED_COMPACT)) <= 0 ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Error in MEDnVal for Field |" << fieldName + << "| with (ndt,or) = (" + << ndt << "," << od << ") for (entityType,geometricType)=(" + << MED_EN::entNames[(*currentEntity).first] << "," + << MED_EN::geoNames[*currentGeometry] << ")" )); ; + + //totalNumberOfElements+=numberOfElements; + numberOfElementsOfType[numberOfGeometricType] = numberOfElements/ngauss; + numberOfGaussPoint[numberOfGeometricType] = ngauss; + anyGauss = (anyGauss || (ngauss-1) ); + geometricType[numberOfGeometricType]= *currentGeometry; + numberOfGeometricType++; + + } // End Second For + + } // End Premier For + + if ( alreadyFoundAnEntity) { + support.setName(fieldName+"Support"); + support.setMeshName(string(maa)); // Vérifier que les différents noms de maillages lus soient identiques + support.setEntity(entity); + // REM : Signification précédente erronée pour un champ qui ne repose pas sur toutes les entités géométriques + // du maillage mais dont le SUPPORT a été crée à partir des informations d'un maillage, comme + // celà fût la plupart du temps. + support.setNumberOfGeometricType(numberOfGeometricType); + support.setGeometricType(geometricType); // Utile uniquement si setAll == false + support.setNumberOfElements(numberOfElementsOfType); //setNumberOfElements effectue une copie + support.setAll(true); + if (anyGauss) + support.setNumberOfGaussPoint(numberOfGaussPoint); + + return alreadyFoundAnEntity; + } else + return false; +} + +template void +MED_FIELD_DRIVER22::getMeshGeometricType(med_2_2::med_idt id, + string & meshName, + MED_EN::medEntityMesh entity, + vector & geoType, + vector &nbOfElOfType) const +{ + const char LOC[] = "MED_FIELD_DRIVER::getMeshGeometricType(...)"; + + int numberOfGeometricType=0; + MED_EN::medGeometryElement geometricType[MED_NBR_GEOMETRIE_MAILLE]; + int numberOfElementsOfType[MED_NBR_GEOMETRIE_MAILLE]; + med_2_2::med_int numberOfElements=0; + med_2_2::med_table quoi; + if (entity == MED_EN::MED_CELL) quoi=med_2_2::MED_CONN; + else + if (entity == MED_EN::MED_NODE) quoi=med_2_2::MED_COOR; + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Support Creation from Mesh |" << meshName + << "| on entity " << MED_EN::entNames[entity] + << "| is impossible, must be on MED_NODE or MED_CELL" )); + + list::const_iterator currentGeometry; + bool alreadyFoundAnEntity = false; + + for (currentGeometry = (MED_EN::meshEntities[entity]).begin(); + currentGeometry != (MED_EN::meshEntities[entity]).end(); currentGeometry++) { + + + if ( (numberOfElements = + med_2_2::MEDnEntMaa(id, + const_cast (meshName.c_str()), + quoi, + (med_2_2::med_entite_maillage) entity, + (med_2_2::med_geometrie_element) *currentGeometry, + med_2_2::MED_NOD) ) <= 0) + continue; + + alreadyFoundAnEntity = true; + numberOfElementsOfType[numberOfGeometricType] = numberOfElements; + geometricType[numberOfGeometricType] = *currentGeometry; + numberOfGeometricType++; + + } + geoType = vector(geometricType,geometricType+numberOfGeometricType); + nbOfElOfType = vector (numberOfElementsOfType,numberOfElementsOfType+numberOfGeometricType); + +} + /*--------------------- RDONLY PART -------------------------------*/ template GENDRIVER * MED_FIELD_RDONLY_DRIVER22::copy(void) const @@ -382,50 +553,80 @@ template void MED_FIELD_RDONLY_DRIVER22::read(void) const char * LOC = " MED_FIELD_RDONLY_DRIVER22::read() " ; BEGIN_OF(LOC); - if (MED_FIELD_DRIVER::_ptrField->_name=="") - MED_FIELD_DRIVER::_ptrField->_name = MED_FIELD_DRIVER::_fieldName ; - else - MED_FIELD_DRIVER::_fieldName = MED_FIELD_DRIVER::_ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!! - - MESSAGE("###### "<::_fieldName<<" fieldName : "<::_ptrField->_name); - - string MeshName = MED_FIELD_DRIVER::_ptrField->getSupport()->getMesh()->getName() ; - - if (MED_FIELD_DRIVER::_status==MED_OPENED) + typedef typename MEDMEM_ArrayInterface::Array ArrayNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayFull; + + if ( ( MED_FIELD_DRIVER::_fieldName.empty() ) && + ( MED_FIELD_DRIVER::_ptrField->_name.empty() ) ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) + <<" neither is set in driver nor in object FIELD.")) ; + + // If _fieldName is not set in driver, try to use _ptrfield->_fieldName + if ( ( MED_FIELD_DRIVER::_fieldName.empty() ) && + ( !MED_FIELD_DRIVER::_ptrField->_name.empty() ) ) + MED_FIELD_DRIVER::_fieldName=MED_FIELD_DRIVER::_ptrField->_name; + + if ( MED_FIELD_DRIVER::_fieldName.size() > MED_TAILLE_NOM ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) + <<" size in object driver FIELD is > MED_TAILLE_NOM .")); + + + MESSAGE("###### "<::_fieldName << + " fieldName : "<::_fieldName); + + + if (MED_FIELD_DRIVER::_status!=MED_OPENED) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": Method open must be called before method read.")) ; + +// EF : +// Si un support a été donnée au champ, pour des raisons de compatibilité avec +// les versions précédentes, ce support sera utilisé pour +// - Obtenir le nom du maillage sur lequel on veut lire le champ +// (eventuellement on pourrait l'utiliser pour selectionner un champ qui +// repose sur plusieurs maillages cf HOMARD-ASTER) +// - vérifier le type d'entité (MED_NOEUD xor MED_MAILLE xor MED_FACE xor MED_ARETE ) sur lequel +// il faut lire le champ qui est également retouvé. +// - Si le support défini une liste d'entité ( différente de MED_ALL_ELEMENTS), celle-ci est ignorée +// à la lecture et écrasé par les listes de profils lus s'il en existe + +// Si aucun support n'a été donné au champ : +// - A la lecture : Un support est crée et le type d'entité unique est lu +// (cf decision gt MED qu'un champ repose sur une entité unique ?), +// l'ensemble des types géométriques est lu, +// l'ensemble des profils par type géométrique est lu +// Le nom du maillage associé est lu mais le pointeur SUPPORT-MESH non initialisé + + char * fieldName = new char[MED_TAILLE_NOM+1] ; + int err ; + int numberOfComponents = 0; + char * componentName = (char *) MED_NULL; + char * unitName = (char *) MED_NULL; + med_2_2::med_type_champ type ; + med_2_2::med_idt id = MED_FIELD_DRIVER22::_medIdt; + + // we search for the field med number of + // Having found variables , + // , , and attribute <_fieldNum> are set. + if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) { + int numberOfFields = med_2_2::MEDnChamp(id,0) ; + if ( numberOfFields <= 0 ) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": There is no field found in the file !")); - // search_field() ; - - char * fieldName ; - fieldName = new char[MED_TAILLE_NOM+1] ; - int err ; - int numberOfComponents = 0; - char * componentName = (char *) MED_NULL; - char * unitName = (char *) MED_NULL; - med_2_2::med_type_champ type ; + for (int i=1;i<=numberOfFields;i++) + { + numberOfComponents = med_2_2::MEDnChamp(id,i) ; - // we search the field number !!!! - if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) { - int numberOfFields = 0; //MED_INVALID - numberOfFields = med_2_2::MEDnChamp(MED_FIELD_DRIVER22::_medIdt,0) ; - if ( numberOfFields <= 0 ) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !")); - for (int i=1;i<=numberOfFields;i++) { - - numberOfComponents = med_2_2::MEDnChamp(MED_FIELD_DRIVER22::_medIdt,i) ; if ( numberOfComponents <= 0 ) - // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) - // << "Be careful there is no compound for field n°" - // << i << "in file |"<<_fileName<<"| !")); MESSAGE(LOC<<"Be careful there is no compound for field n°"<::_fileName<<"| !"); componentName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ; unitName = new char[numberOfComponents*MED_TAILLE_PNOM22+1] ; - err = med_2_2::MEDchampInfo(MED_FIELD_DRIVER22::_medIdt, i, fieldName, &type, componentName, - unitName, numberOfComponents) ; + err = med_2_2::MEDchampInfo(id, i, fieldName, &type, componentName, + unitName, numberOfComponents) ; - MESSAGE("Champ "<::_fieldName.c_str()<<"#"); + MESSAGE("Field "<::_fieldName.c_str()<<"#"); if ( !strcmp(fieldName,MED_FIELD_DRIVER::_fieldName.c_str()) ) { MESSAGE("FOUND FIELD "<< fieldName <<" : "<::_fieldNum = i ; @@ -435,96 +636,193 @@ template void MED_FIELD_RDONLY_DRIVER22::read(void) delete[] componentName ; delete[] unitName ; } - } + } - delete[] fieldName ; - - if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<::_fieldName << " not found in file " << MED_FIELD_DRIVER::_fileName ) ); - MESSAGE ("FieldNum : "<::_fieldNum); - - // int err ; - // int NumberOfComponents = med_2_2::MEDnChamp(MED_FIELD_DRIVER::_medIdt,MED_FIELD_DRIVER::_fieldNum) ; - if (numberOfComponents < 1) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"no component")) ; // use iostring ! - // test type to check if it is rigth !!!??? - MED_FIELD_DRIVER::_ptrField->_numberOfComponents = numberOfComponents ; - MED_FIELD_DRIVER::_ptrField->_componentsTypes = new int[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_componentsNames = new string[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_componentsDescriptions = new string[numberOfComponents] ; - MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ; - for (int i=0; i::_ptrField->_componentsTypes[i] = 1 ; - - // PG : what about space !!! - MED_FIELD_DRIVER::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ; - SCRUTE(MED_FIELD_DRIVER::_ptrField->_componentsNames[i]); - MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ; - SCRUTE(MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i]); - } - delete[] componentName; - delete[] unitName; - - // read values for each geometric type in _support - int NumberOfTypes = MED_FIELD_DRIVER::_ptrField->_support->getNumberOfTypes() ; - const MED_EN::medGeometryElement *Types = MED_FIELD_DRIVER::_ptrField->_support->getTypes() ; - T ** myValues = new T*[NumberOfTypes] ; - int * NumberOfValues = new int[NumberOfTypes] ; - int TotalNumberOfValues = 0 ; - MESSAGE ("NumberOfTypes :"<< NumberOfTypes); - MED_FIELD_DRIVER::_ptrField->_numberOfValues=0 ; - for (int i=0; i::_ptrField->_support->getEntity()); -// NumberOfValues[i] = -// MEDnVal(_medIdt, -// const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), -// (med_2_2::med_entite_maillage)_ptrField->_support->getEntity(), -// (med_2_2::med_geometrie_element)Types[i], -// _ptrField->_iterationNumber, -// _ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss - // test if NumberOfValues is the same in _support !!! TODO that !! - // we suppose it is - // we could allocate array - // Be really carefull about the profil; especially the last arg of - // MEDnVal - - NumberOfValues[i] = - MEDnVal(MED_FIELD_DRIVER22::_medIdt, - const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), - (med_2_2::med_entite_maillage)MED_FIELD_DRIVER::_ptrField->_support->getEntity(), - (med_2_2::med_geometrie_element) Types[i], - MED_FIELD_DRIVER::_ptrField->_iterationNumber, MED_FIELD_DRIVER::_ptrField->_orderNumber, - const_cast (MED_FIELD_DRIVER::_ptrField->_support->getMesh()->getName().c_str()), - med_2_2::MED_COMPACT) ; - - myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ; - TotalNumberOfValues+=NumberOfValues[i] ;// diviser par le nombre de point de gauss - char * ProfilName = new char[MED_TAILLE_NOM+1]; - char * LocalGaussName = new char[MED_TAILLE_NOM+1]; - MESSAGE ("NumberOfValues :"<< NumberOfValues[i]); - MESSAGE ("NumberOfComponents :"<< numberOfComponents); - MESSAGE ("MESH_NAME :"<< MeshName.c_str()); - MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER::_fieldName.c_str()); - MESSAGE ("MED_ENTITE :"<< (med_2_2::med_entite_maillage) MED_FIELD_DRIVER::_ptrField->_support->getEntity()); - MESSAGE("MED_GEOM :"<<(med_2_2::med_geometrie_element)Types[i]); - MESSAGE("Iteration :"<::_ptrField->getIterationNumber()); - MESSAGE("Order :"<::_ptrField->getOrderNumber()); - MED_FIELD_DRIVER::_ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! - - err = MEDchampLire(MED_FIELD_DRIVER22::_medIdt,const_cast (MeshName.c_str()), - const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), + delete[] fieldName ; + + if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) + throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<::_fieldName << " not found in file " << MED_FIELD_DRIVER::_fileName ) ); + MESSAGE ("FieldNum : "<::_fieldNum); + + if (numberOfComponents < 1) { + delete[] componentName; delete[] unitName; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" no component found fo field " + << MED_FIELD_DRIVER::_fieldName)) ; + } + + switch ( (med_2_2::med_type_champ) MED_FIELD_DRIVER::_ptrField->_valueType ) { + case med_2_2::MED_INT : + case med_2_2::MED_INT32 : + case med_2_2::MED_INT64 : + if ( type == ( med_2_2::MED_FLOAT64 ) ) { + delete[] componentName; delete[] unitName; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Field Type in file (" << type + <<") differs from FIELD object type (" << + MED_FIELD_DRIVER::_ptrField->_valueType << ")" )) ; + } + break; + default: + break; + } + + + string meshName=""; + bool haveSupport = false; + if ( MED_FIELD_DRIVER::_ptrField->getSupport() ) { + // Verif sur la taille du meshName + meshName = MED_FIELD_DRIVER::_ptrField->getSupport()->getMesh()->getName() ; + haveSupport = true; + } + + // Cherche le type d'entité, le nombre d'entité par type géométrique sur le type d'entité + // (MED_MAILLE ou MED_NOEUD uniquement car MEDMEMOIRE ne gère pas la connectivité descendante). + // et crée le support correspondant. + SUPPORT * mySupport = new SUPPORT(); + bool found = createFieldSupport(id,MED_FIELD_DRIVER::_fieldName, + MED_FIELD_DRIVER::_ptrField->_iterationNumber, + MED_FIELD_DRIVER::_ptrField->_orderNumber, + *mySupport, meshName) ; + if ( !found ) { + delete mySupport; delete[] componentName; delete[] unitName; + MED_FIELD_DRIVER::_fieldNum = MED_INVALID ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Can't find any entity for field |" + << MED_FIELD_DRIVER::_fieldName + << "| with (it,or) = (" + << MED_FIELD_DRIVER::_ptrField->_iterationNumber << "," + << MED_FIELD_DRIVER::_ptrField->_orderNumber << "), on mesh " + << meshName << "|" )); + } + + if (! haveSupport) + meshName = mySupport->getMeshName(); + else { + if ( mySupport->getEntity() != MED_FIELD_DRIVER::_ptrField->getSupport()->getEntity() ) { + MED_EN::medEntityMesh ent = mySupport->getEntity(); + delete mySupport; delete[] componentName; delete[] unitName; + MED_FIELD_DRIVER::_fieldNum = MED_INVALID ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Given entity |" + << MED_EN::entNames[MED_FIELD_DRIVER::_ptrField-> + getSupport()->getEntity()] + << "| for field |" + << MED_FIELD_DRIVER::_fieldName + << "| with (it,or) = (" + << MED_FIELD_DRIVER::_ptrField->_iterationNumber << "," + << MED_FIELD_DRIVER::_ptrField->_orderNumber << "), on mesh " + << meshName << "| differs from found entity |" + << MED_EN::entNames[ent] << "|." + )); + } + mySupport->setName( MED_FIELD_DRIVER::_ptrField->getSupport()->getName() ); + mySupport->setMesh( MED_FIELD_DRIVER::_ptrField->getSupport()->getMesh() ); + mySupport->setDescription(MED_FIELD_DRIVER::_ptrField->getSupport()->getDescription()); + } + + // Test si le Support du Champ repose ou non sur toutes les entités géométriques du maillage. + // Pour tester les profils aussi ? + vector< MED_EN::medGeometryElement > meshGeoType; + vector< int > meshNbOfElOfType; + getMeshGeometricType(id,meshName,mySupport->getEntity(),meshGeoType,meshNbOfElOfType); + vector < MED_EN::medGeometryElement > v1( mySupport->getTypes(), + mySupport->getTypes()+mySupport->getNumberOfTypes() ); + vector < int > v2(mySupport->getNumberOfElements(), + mySupport->getNumberOfElements()+mySupport->getNumberOfTypes() ); + if ( ( meshGeoType != v1 ) || meshNbOfElOfType != v2 ) { + mySupport->setAll(false); + } + + //??support->setNumber(MEDSKYLINEARRAY * Number); + //??support->setNumber(const int * index, const int* value, bool shallowCopy=false); + + // If an error occurs while reading the field, these allocated FIELD member will be deleted + + MED_FIELD_DRIVER::_ptrField->_name = MED_FIELD_DRIVER::_fieldName; + MED_FIELD_DRIVER::_ptrField->_numberOfComponents = numberOfComponents ; + MED_FIELD_DRIVER::_ptrField->_componentsTypes = new int[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_componentsNames = new string[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_componentsUnits = new UNIT[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_componentsDescriptions = new string[numberOfComponents] ; + MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits = new string[numberOfComponents] ; + + for (int i=0; i::_ptrField->_componentsTypes[i] = 1 ; + MED_FIELD_DRIVER::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ; + SCRUTE(MED_FIELD_DRIVER::_ptrField->_componentsNames[i]); + MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM22,MED_TAILLE_PNOM22) ; + SCRUTE(MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i]); + } + delete[] componentName; + delete[] unitName; + + int NumberOfTypes = mySupport->getNumberOfTypes() ; + const MED_EN::medGeometryElement *Types = mySupport->getTypes() ; + T ** myValues = new T*[NumberOfTypes] ; + int * NumberOfValues = new int[NumberOfTypes] ; + int TotalNumberOfValues = 0 ; //profil a gerer en 2.2 + MESSAGE ("NumberOfTypes :"<< NumberOfTypes); + MED_FIELD_DRIVER::_ptrField->_numberOfValues=0 ; + for (int i=0; igetNumberOfElements(Types[i]) + * mySupport->getNumberOfGaussPoint(Types[i]); + myValues[i] = new T[ NumberOfValues[i]*numberOfComponents ] ; + TotalNumberOfValues+=NumberOfValues[i] ; + char * ProfilName = new char[MED_TAILLE_NOM+1]; + char * LocalGaussName = new char[MED_TAILLE_NOM+1]; + + MESSAGE ("Type["<getEntity()); + MESSAGE ("NumberOfValues :"<< NumberOfValues[i]); + MESSAGE ("NumberOfComponents :"<< numberOfComponents); + MESSAGE ("MESH_NAME :"<< meshName.c_str()); + MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER::_fieldName.c_str()); + MESSAGE ("MED_ENTITE :"<< (med_2_2::med_entite_maillage) mySupport->getEntity()); + MESSAGE("MED_GEOM :"<<(med_2_2::med_geometrie_element)Types[i]); + MESSAGE("Iteration :"<::_ptrField->getIterationNumber()); + MESSAGE("Order :"<::_ptrField->getOrderNumber()); + + MED_FIELD_DRIVER::_ptrField->_numberOfValues+=mySupport->getNumberOfElements(Types[i]); // Ne doit pas prendre en compte les points de Gauss + med_2_2::med_err ret; + +#if defined(IRIX64) || defined(OSF1) || defined(VPP5000) + int lgth2=NumberOfValues[i]*numberOfComponents; + if(_ptrField->getValueType()==MED_EN::MED_INT32) + { + med_2_2::med_int *temp=new med_2_2::med_int[lgth2]; + ret=med_2_2::MEDchampLire(id,const_cast (meshName.c_str()), + const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), + (unsigned char*) temp, + med_2_2::MED_NO_INTERLACE, + MED_ALL, + ProfilName, + (med_2_2::med_entite_maillage) mySupport->getEntity(), + (med_2_2::med_geometrie_element)Types[i], + MED_FIELD_DRIVER::_ptrField->getIterationNumber(), + MED_FIELD_DRIVER::_ptrField->getOrderNumber() + ); + for(int i2=0;i2 (meshName.c_str()), + const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), (unsigned char*) myValues[i], - med_2_2::MED_NO_INTERLACE,MED_ALL, - LocalGaussName,ProfilName, - med_2_2::MED_NO_PFLMOD, - (med_2_2::med_entite_maillage) MED_FIELD_DRIVER::_ptrField->_support->getEntity(),(med_2_2::med_geometrie_element)Types[i], - MED_FIELD_DRIVER::_ptrField->getIterationNumber(), - MED_FIELD_DRIVER::_ptrField->getOrderNumber()); - - if ( err < 0) { - // we must do some delete !!! + med_2_2::MED_NO_INTERLACE, + MED_ALL, + LocalGaussName, + ProfilName, + med_2_2::MED_COMPACT, + (med_2_2::med_entite_maillage) mySupport->getEntity(), + (med_2_2::med_geometrie_element) Types[i], + MED_FIELD_DRIVER::_ptrField->getIterationNumber(), + MED_FIELD_DRIVER::_ptrField->getOrderNumber() + ); + if (ret < 0) + { + // The Field can't be read then we mustdelete all previously allocated members in FIELD for(int j=0; j<=i;j++) delete[] myValues[j]; delete[] myValues; @@ -545,51 +843,56 @@ template void MED_FIELD_RDONLY_DRIVER22::read(void) throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": ERROR when read value")) ; } - // At this time ProfilName should be med_2_2::MED_NOPFL and - // LocalGaussName should be med_2_2::MED_NOGAUSS - delete[] ProfilName ; - delete[] LocalGaussName ; - } - // allocate _value - // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1) - // MEDARRAY * Values = new MEDARRAY(MED_FIELD_DRIVER::_ptrField->getNumberOfComponents(),TotalNumberOfValues/MED_FIELD_DRIVER::_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE); - - if (MED_FIELD_DRIVER::_ptrField->_value==NULL) - MED_FIELD_DRIVER::_ptrField->_value=new MEDARRAY(numberOfComponents,TotalNumberOfValues,MED_EN::MED_NO_INTERLACE); - - MEDARRAY * Values = MED_FIELD_DRIVER::_ptrField->_value ; // create by constructor ??? - // check if dimensions are right : inutile : c'est dans le constructeur !!! - //if (Values->getLeadingValue() != numberOfComponents) - // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": leading dimension are false : "<getLeadingValue()<<" and "<getLengthValue() != TotalNumberOfValues) - // throw MEDEXCEPTION( LOCALIZED( STRING(LOC) <<": length dimension are false : "<getLengthValue()<<" and "<getRow(i+1) ; - int Count = 1 ; - for (int j=0; j::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! - int offset = NumberOf*i ; - for (int k=0 ; kgetRow(i+1) ; + int Count = 1 ; + for (int j=0; j::_ptrField->_numberOfValues+=NumberOf; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! + int offset = NumberOf*i ; + for (int k=0 ; ksetIJ(Count,i+1,myValue[k+offset]); - SCRUTE(Count); - SCRUTE(Values->getIJ(Count,i+1)); +// SCRUTE(Count); +// SCRUTE(Values->getIJ(Count,i+1)); Count++; } - } } + } - for (int j=0; j::_ptrField->_isRead = true ; + if (MED_FIELD_DRIVER::_ptrField->_value != NULL) + delete MED_FIELD_DRIVER::_ptrField->_value; + + if ( MED_FIELD_DRIVER::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) + { + // dynamic_cast inutile + MED_FIELD_DRIVER::_ptrField->_value=dynamic_cast(ArrayConvert(*Values)); + delete Values; } + else + MED_FIELD_DRIVER::_ptrField->_value=Values; + MED_FIELD_DRIVER::_ptrField->_isRead = true ; + + MED_FIELD_DRIVER::_ptrField->_support=mySupport; //Prévenir l'utilisateur ? + END_OF(LOC); } @@ -617,6 +920,10 @@ template void MED_FIELD_WRONLY_DRIVER22::write(void) const { const char * LOC = "MED_FIELD_WRONLY_DRIVER22::write(void) const " ; BEGIN_OF(LOC); + + typedef typename MEDMEM_ArrayInterface::Array ArrayNo; + typedef typename MEDMEM_ArrayInterface::Array ArrayFull; + if (MED_FIELD_DRIVER::_status==MED_OPENED) { int err ; @@ -722,22 +1029,39 @@ template void MED_FIELD_WRONLY_DRIVER22::write(void) const int Index = 1 ; const MED_EN::medGeometryElement * Types = mySupport->getTypes() ; const int * NumberOfGaussPoint = mySupport->getNumberOfGaussPoint() ; - for (int i=0;igetNumberOfElements(Types[i]) ; - - const T * value = MED_FIELD_DRIVER::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ; - - MESSAGE("MED_FIELD_DRIVER22::_medIdt : "<::_medIdt); - MESSAGE("MeshName.c_str() : "<::_ptrField->getName() : "<::_ptrField->getName()); - MESSAGE("value : "<getEntity() : "<getEntity()); - MESSAGE("Types[i] : "<::_ptrField->getIterationNumber() : "<::_ptrField->getIterationNumber()); - MESSAGE("MED_FIELD_DRIVER::_ptrField->getTime() : "<::_ptrField->getTime()); - MESSAGE("MED_FIELD_DRIVER::_ptrField->getOrderNumber() : "<::_ptrField->getOrderNumber()); + + const T * value = NULL; + ArrayFull * myArray = NULL; + if ( MED_FIELD_DRIVER::_ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) + myArray = MED_FIELD_DRIVER::_ptrField->getArrayNoGauss(); + else + { + // En attendant la convertion de FIELD, on utilise le ArrayConvert + // ( les infos _ptrField-> sont les mêmes ) + myArray = ArrayConvert( *( dynamic_cast< ArrayNo * > + (MED_FIELD_DRIVER::_ptrField->getArrayNoGauss() + )) + ); + } + + for (int i=0;igetNumberOfElements(Types[i]) ; + + //value = MED_FIELD_DRIVER::_ptrField->getRow(Index) ; + value = myArray->getRow(Index) ; + + MESSAGE("MED_FIELD_DRIVER22::_medIdt : "<::_medIdt); + MESSAGE("MeshName.c_str() : "<::_ptrField->getName() : "<::_ptrField->getName()); + MESSAGE("value : "<getEntity() : "<getEntity()); + MESSAGE("Types[i] : "<::_ptrField->getIterationNumber() : "<::_ptrField->getIterationNumber()); + MESSAGE("MED_FIELD_DRIVER::_ptrField->getTime() : "<::_ptrField->getTime()); + MESSAGE("MED_FIELD_DRIVER::_ptrField->getOrderNumber() : "<::_ptrField->getOrderNumber()); /* char chanom[MED_TAILLE_NOM+1]; char chacomp[MED_TAILLE_NOM+1]; @@ -745,7 +1069,7 @@ template void MED_FIELD_WRONLY_DRIVER22::write(void) const med_2_2::med_type_champ chatype; med_int chancomp=1; - err=med_2_2::MEDchampInfo(MED_FIELD_DRIVER::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp); + err=med_2_2::MEDchampInfo(MED_FIELD_DRIVER22::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp); if (err<0) { @@ -794,14 +1118,19 @@ template void MED_FIELD_WRONLY_DRIVER22::write(void) const ); if (err < MED_VALID ) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) - <<": Error in writing Field "<< MED_FIELD_DRIVER::_ptrField->getName() <<", type "<::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray; + throw MEDEXCEPTION(LOCALIZED( STRING(LOC) + <<": Error in writing Field "<< MED_FIELD_DRIVER::_ptrField->getName() <<", type "<::_ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) delete myArray; + } END_OF(LOC); @@ -830,8 +1159,7 @@ template void MED_FIELD_RDWR_DRIVER22::read (void) END_OF("MED_FIELD_RDWR_DRIVER22::read(void)"); } -} +} //End namespace MEDMEM /*-----------------------------------------------------------------*/ #endif /* MED_FIELD_DRIVER_HXX */ - diff --git a/src/MEDMEM/MEDMEM_MedMedDriver21.cxx b/src/MEDMEM/MEDMEM_MedMedDriver21.cxx index 12f5ddcb8..b17640a28 100644 --- a/src/MEDMEM/MEDMEM_MedMedDriver21.cxx +++ b/src/MEDMEM/MEDMEM_MedMedDriver21.cxx @@ -567,7 +567,6 @@ void MED_MED_RDONLY_DRIVER21::readFileStruct( void ) break ; } } - ptrField->setValueType((MED_EN::med_type_champ) type) ; // need to write field ! MESSAGE("timeStepNumber :"<setIterationNumber ( timeStepNumber); // A ajouter dans la classe FIELD diff --git a/src/MEDMEM/MEDMEM_MedMedDriver22.cxx b/src/MEDMEM/MEDMEM_MedMedDriver22.cxx index a906fbe7a..23c60b8fb 100644 --- a/src/MEDMEM/MEDMEM_MedMedDriver22.cxx +++ b/src/MEDMEM/MEDMEM_MedMedDriver22.cxx @@ -639,8 +639,6 @@ void MED_MED_RDONLY_DRIVER22::readFileStruct( void ) break ; } } - ptrField->setValueType((MED_EN::med_type_champ) - type) ; // need to write field ! MESSAGE("timeStepNumber :"<_spaceDimension; - if (_status==MED_OPENED) { + int spaceDimension = _ptrMesh->_spaceDimension; + // Get the type of entity to work on (previously set in the Connectivity Object) med_2_1::med_entite_maillage Entity = (med_2_1::med_entite_maillage) Connectivity->getEntity(); @@ -2508,8 +2508,8 @@ int MED_MESH_WRONLY_DRIVER21::writeFamilies(vector & families ) const { const_cast ( _meshName.c_str() ), const_cast ( families[i]->getName().c_str() ), families[i]->getIdentifier(), - families[i]->getAttributesIdentifiers(), - families[i]->getAttributesValues(), + (med_2_1::med_int*) families[i]->getAttributesIdentifiers(), + (med_2_1::med_int*) families[i]->getAttributesValues(), const_cast (attributesDescriptions.c_str()), numberOfAttributes, const_cast (groupsNames.c_str()), diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx b/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx index ff64bb3c0..307619c71 100644 --- a/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx +++ b/src/MEDMEM/MEDMEM_MedMeshDriver22.cxx @@ -791,10 +791,10 @@ int MED_MESH_RDONLY_DRIVER22::getNodalConnectivity(CONNECTIVITY * Connectivity) const char * LOC = "MED_MESH_RDONLY_DRIVER22::getNodalConnectivity : " ; BEGIN_OF(LOC); - int spaceDimension = _ptrMesh->_spaceDimension; - if (_status==MED_OPENED) { + int spaceDimension = _ptrMesh->_spaceDimension; + // Get the type of entity to work on (previously set in the Connectivity Object) med_2_2::med_entite_maillage Entity = (med_2_2::med_entite_maillage) Connectivity->getEntity(); @@ -2072,13 +2072,18 @@ int MED_MESH_WRONLY_DRIVER22::writeCoordinates() const { int meshDimension = med_2_2::MEDdimLire(_medIdt, const_cast (_meshName.c_str()) ); - if ((spaceDimension != MED_VALID) && (meshDimension != MED_VALID)) + SCRUTE(spaceDimension); + SCRUTE(meshDimension); + SCRUTE(_ptrMesh->_spaceDimension); + SCRUTE(_ptrMesh->_meshDimension); + + if ((spaceDimension != MED_VALID) && (meshDimension < MED_VALID)) { err = MEDmaaCr(_medIdt, const_cast (_meshName.c_str()), _ptrMesh->_meshDimension, med_2_2::MED_NON_STRUCTURE, const_cast (_ptrMesh->_description.c_str())); - if (err != MED_VALID) + if (err < MED_VALID) throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "Unable to create Mesh : |" << _meshName << "|")); else MESSAGE(LOC<<"Mesh "<<_meshName<<" created in file "<<_fileName<<" !"); @@ -2769,7 +2774,7 @@ int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector & families ) const if (families[i]->getEntity() == MED_NODE) dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/NOEUD/"+families[i]->getName()+"/"; else - dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEM/"+families[i]->getName()+"/"; + dataGroupFam = "/ENS_MAA/"+_meshName+"/FAS/ELEME/"+families[i]->getName()+"/"; SCRUTE("|"< (dataGroupFam.c_str()) ) ; @@ -2812,8 +2817,8 @@ int MED_MESH_WRONLY_DRIVER22::writeFamilies(vector & families ) const const_cast ( _meshName.c_str() ), const_cast ( families[i]->getName().c_str() ), families[i]->getIdentifier(), - families[i]->getAttributesIdentifiers(), - families[i]->getAttributesValues(), + (med_2_2::med_int*)families[i]->getAttributesIdentifiers(), + (med_2_2::med_int*)families[i]->getAttributesValues(), const_cast (attributesDescriptions.c_str()), numberOfAttributes, const_cast (groupsNames.c_str()), diff --git a/src/MEDMEM/MEDMEM_Mesh.cxx b/src/MEDMEM/MEDMEM_Mesh.cxx index 78f03906b..856bdeb99 100644 --- a/src/MEDMEM/MEDMEM_Mesh.cxx +++ b/src/MEDMEM/MEDMEM_Mesh.cxx @@ -623,7 +623,7 @@ SUPPORT *MESH::buildSupportOnElementsFromElementList(const list& listOfElt, return mySupport ; } -FIELD* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION) +FIELD* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION) { const char * LOC = "MESH::getVolume(SUPPORT*) : "; BEGIN_OF(LOC); @@ -649,7 +649,8 @@ FIELD* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); types = Support->getTypes(); int index; - FIELD* Volume = new FIELD(Support,1); + FIELD* Volume = + new FIELD(Support,1); // double *volume = new double [length_values]; Volume->setName("VOLUME"); Volume->setDescription("cells volume"); @@ -662,12 +663,14 @@ FIELD* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION Volume->setMEDComponentUnit(1,MEDComponentUnit); - Volume->setValueType(MED_REEL64); - Volume->setIterationNumber(0); Volume->setOrderNumber(0); Volume->setTime(0.0); - MEDARRAY *volume = Volume->getvalue(); + + //const double *volume = Volume->getValue(MED_FULL_INTERLACE); + typedef MEDMEM_ArrayInterface::Array ArrayNoGauss; + ArrayNoGauss *volume = Volume->getArrayNoGauss(); + index = 1; const double * coord = getCoordinates(MED_FULL_INTERLACE); @@ -849,7 +852,7 @@ FIELD* MESH::getVolume(const SUPPORT *Support) const throw (MEDEXCEPTION return Volume; } -FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) +FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) { const char * LOC = "MESH::getArea(SUPPORT*) : "; BEGIN_OF(LOC); @@ -877,9 +880,9 @@ FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) types = Support->getTypes(); int index; - FIELD* Area; + FIELD* Area; - Area = new FIELD(Support,1); + Area = new FIELD(Support,1); Area->setName("AREA"); Area->setDescription("cells or faces area"); @@ -892,13 +895,11 @@ FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) Area->setMEDComponentUnit(1,MEDComponentUnit); - Area->setValueType(MED_REEL64); - Area->setIterationNumber(0); Area->setOrderNumber(0); Area->setTime(0.0); - double *area = (double *)Area->getValue(MED_FULL_INTERLACE); + double *area = (double *)Area->getValue(); const double * coord = getCoordinates(MED_FULL_INTERLACE); index = 0; @@ -1014,7 +1015,7 @@ FIELD* MESH::getArea(const SUPPORT * Support) const throw (MEDEXCEPTION) return Area; } -FIELD* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) +FIELD* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTION) { const char * LOC = "MESH::getLength(SUPPORT*) : "; BEGIN_OF(LOC); @@ -1042,14 +1043,14 @@ FIELD* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTIO types = Support->getTypes(); int index; - FIELD* Length; + FIELD* Length; - Length = new FIELD(Support,1); + Length = new FIELD(Support,1); // double *length = new double [length_values]; - Length->setValueType(MED_REEL64); //const double *length = Length->getValue(MED_FULL_INTERLACE); - MEDARRAY * length = Length->getvalue(); + typedef MEDMEM_ArrayInterface::Array ArrayNoGauss; + ArrayNoGauss * length = Length->getArrayNoGauss(); const double * coord = getCoordinates(MED_FULL_INTERLACE); index = 1; @@ -1119,7 +1120,7 @@ FIELD* MESH::getLength(const SUPPORT * Support) const throw (MEDEXCEPTIO return Length; } -FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) +FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTION) { const char * LOC = "MESH::getNormal(SUPPORT*) : "; BEGIN_OF(LOC); @@ -1151,7 +1152,8 @@ FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTIO int index; - FIELD* Normal = new FIELD(Support,dim_space); + FIELD* Normal = + new FIELD(Support,dim_space); Normal->setName("NORMAL"); Normal->setDescription("cells or faces normal"); for (int k=1;k<=dim_space;k++) { @@ -1160,12 +1162,10 @@ FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTIO Normal->setMEDComponentUnit(k,"unit"); } - Normal->setValueType(MED_REEL64); - Normal->setIterationNumber(MED_NOPDT); Normal->setOrderNumber(MED_NONOR); Normal->setTime(0.0); - double *normal = (double *)Normal->getValue(MED_FULL_INTERLACE); + double *normal = (double *)Normal->getValue(); const double * coord = getCoordinates(MED_FULL_INTERLACE); index = 0; @@ -1311,7 +1311,7 @@ FIELD* MESH::getNormal(const SUPPORT * Support) const throw (MEDEXCEPTIO return Normal; } -FIELD* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) +FIELD* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCEPTION) { const char * LOC = "MESH::getBarycenter(SUPPORT*) : "; MESH* myMesh = Support->getMesh(); @@ -1332,8 +1332,8 @@ FIELD* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCE length_values = Support->getNumberOfElements(MED_ALL_ELEMENTS); types = Support->getTypes(); - FIELD* Barycenter; - Barycenter = new FIELD(Support,dim_space); + FIELD* Barycenter; + Barycenter = new FIELD(Support,dim_space); Barycenter->setName("BARYCENTER"); Barycenter->setDescription("cells or faces barycenter"); @@ -1343,11 +1343,10 @@ FIELD* MESH::getBarycenter(const SUPPORT * Support) const throw (MEDEXCE Barycenter->setComponentDescription(kp1,"desc-comp"); Barycenter->setMEDComponentUnit(kp1,myMesh->getCoordinatesUnits()[k]); } - Barycenter->setValueType(MED_REEL64); Barycenter->setIterationNumber(0); Barycenter->setOrderNumber(0); Barycenter->setTime(0.0); - double *barycenter=(double *)Barycenter->getValue(MED_FULL_INTERLACE); + double *barycenter=(double *)Barycenter->getValue(); const double * coord = getCoordinates(MED_FULL_INTERLACE); int index=0; for (int i=0;i class FIELD; - class CELLMODEL; class FAMILY; class GROUP; @@ -299,8 +298,8 @@ public : void fillSupportOnNodeFromElementList(const list& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION); SUPPORT *buildSupportOnElementsFromElementList(const list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); int getElementContainingPoint(const double *coord); - template - static FIELD *mergeFields(const vector< FIELD* >& others,bool meshCompare=false); + template static + FIELD * mergeFields(const vector< FIELD * > & others, bool meshCompare=false); /*! *For ref counter. Only for client */ @@ -1024,7 +1023,8 @@ namespace MEDMEM { //Create a new FIELD that should be deallocated based on a SUPPORT that should be deallocated too. template -FIELD *MESH::mergeFields(const vector< FIELD* >& others,bool meshCompare) +FIELD * MESH::mergeFields(const vector< FIELD * > & others, + bool meshCompare) { const char * LOC = "MESH::mergeFields(const vector< FIELD* >& others,bool meshCompare): "; BEGIN_OF(LOC); @@ -1032,17 +1032,22 @@ FIELD *MESH::mergeFields(const vector< FIELD* >& others,bool meshCompare) if(others.size()==0) return 0; vector sup; - typename vector< FIELD* >::const_iterator iter; + typename vector< FIELD* >::const_iterator iter; + iter = others.begin(); + MED_EN::med_type_champ valueType = (*iter)->getValueType(); for(iter=others.begin();iter!=others.end();iter++) { + MED_EN::med_type_champ valueTypeIter = (*iter)->getValueType(); + if (valueTypeIter != valueType) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<" Fields vector have not the same value type")); + sup.push_back((SUPPORT *)(*iter)->getSupport()); } iter=others.begin(); SUPPORT *retSup=mergeSupports(sup); int retNumberOfComponents=(*iter)->getNumberOfComponents(); - FIELD *ret=new FIELD(retSup,retNumberOfComponents,MED_EN::MED_FULL_INTERLACE); - ret->setValueType((*iter)->getValueType()); - T* valuesToSet=(T*)ret->getValue(MED_EN::MED_FULL_INTERLACE); + FIELD *ret=new FIELD(retSup, retNumberOfComponents); + T* valuesToSet=(T*)ret->getValue(); int nbOfEltsRetSup=retSup->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); T* tempValues=new T[retNumberOfComponents]; if(retSup->isOnAllElements()) diff --git a/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx b/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx index b89150367..9a91106e7 100644 --- a/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx +++ b/src/MEDMEM/MEDMEM_PorflowMeshDriver.cxx @@ -80,7 +80,7 @@ inline static medGeometryElement get2DMedGeomType(int nbSommets); PORFLOW_MESH_DRIVER::PORFLOW_MESH_DRIVER(): GENDRIVER(), - _ptrMesh(( MESH *)MED_NULL), + _ptrMesh(( MESH *) NULL), // A VOIR _medIdt(MED_INVALID), _meshName("") { diff --git a/src/MEDMEM/MEDMEM_STRING.hxx b/src/MEDMEM/MEDMEM_STRING.hxx index 1187bc675..7447ba08b 100644 --- a/src/MEDMEM/MEDMEM_STRING.hxx +++ b/src/MEDMEM/MEDMEM_STRING.hxx @@ -23,7 +23,7 @@ using namespace std; # include -# include +# include /*! A class to generate string from any type: @@ -34,57 +34,44 @@ using namespace std; throw SALOME_EXCEPTION (LOCALIZED(msgErr)) ; */ namespace MEDMEM { -class STRING : public string -{ + class STRING : public string + { -private : - ostrstream _s ; + private : + ostringstream _s ; -public : + public : - STRING() :string(), _s() - { - } + STRING() :string(), _s() + { + } - ~STRING() - { - _s.freeze(false); - } + ~STRING() + { + } - operator const char * () const - { - return const_cast (this->c_str()) ; - } + operator const char * () const + { + // return const_cast (this->c_str()) ; + return this->c_str(); + } - template STRING( const T &valeur ) : string(), _s() - { - _s.freeze(false); + template STRING( const T &valeur ) : string(), _s() + { + _s << valeur ; - _s << valeur ; - _s << ends; + this->string::operator =( _s.str()); + } - this->string::operator =( _s.str()); // freeze is true by now - } + template STRING & operator<<( const T &valeur ) + { + _s << valeur ; - template STRING & operator<<( const T &valeur ) - { - - if ( _s.pcount() ) - { - _s.seekp(-1, ios::cur); // Back up before NULL - _s.rdbuf()->freeze(0); // Unfreeze it - } - - _s << valeur ; - _s << ends; - - this->string::operator = ( _s.str() ) ; // freeze is true by now - _s.freeze( false ) ; - return *this ; + this->string::operator = ( _s.str() ) ; // freeze is true by now - - } -} ; + return *this ; + } + } ; } ; # endif diff --git a/src/MEDMEM/MEDMEM_Support.cxx b/src/MEDMEM/MEDMEM_Support.cxx index 90b5ccbde..6bb604599 100644 --- a/src/MEDMEM/MEDMEM_Support.cxx +++ b/src/MEDMEM/MEDMEM_Support.cxx @@ -26,8 +26,8 @@ #include #include -#include "MEDMEM_DriversDef.hxx" #include "MEDMEM_Support.hxx" +#include "MEDMEM_DriversDef.hxx" #include "MEDMEM_Mesh.hxx" using namespace std; @@ -44,10 +44,7 @@ using namespace MEDMEM; //-------------------------------------------------------------------------- SUPPORT::SUPPORT(): _name(""), _description("None"), _mesh((MESH*)NULL), _entity(MED_CELL), _numberOfGeometricType(0), - _geometricType((medGeometryElement*)NULL), - _numberOfGaussPoint((int*)NULL), _isOnAllElts(false), - _numberOfElements((int*)NULL), _totalNumberOfElements(0), _number((MEDSKYLINEARRAY*)NULL) //-------------------------------------------------------------------------- @@ -61,13 +58,8 @@ SUPPORT::SUPPORT(): _name(""), _description("None"), _mesh((MESH*)NULL), //-------------------------------------------------------------------------- SUPPORT::SUPPORT(MESH* Mesh, string Name/*=""*/, medEntityMesh Entity/*=MED_CELL*/): _name(Name), _description("None"), _mesh(Mesh), _entity(Entity), - _numberOfGeometricType(0), - _geometricType((medGeometryElement*)NULL), - _numberOfGaussPoint((int*)NULL), - _isOnAllElts(true), - _numberOfElements((int*)NULL), - _totalNumberOfElements(0), - _number((MEDSKYLINEARRAY*)NULL) + _numberOfGeometricType(0), _isOnAllElts(true), + _totalNumberOfElements(0), _number((MEDSKYLINEARRAY*)NULL) //-------------------------------------------------------------------------- { MESSAGE("SUPPORT::SUPPORT(MESH*Mesh,string Name,medEntityMesh Entity)"); @@ -84,34 +76,25 @@ SUPPORT::SUPPORT(const SUPPORT & m) const char * LOC = "SUPPORT::SUPPORT(SUPPORT & m) : " ; BEGIN_OF(LOC) ; - _name = m._name; - _description = m._description; - _mesh = m._mesh; // on recopie uniquement l'adresse + _name = m._name ; + _description = m._description ; + _mesh = m._mesh ; // on recopie uniquement l'adresse _entity = m._entity; _numberOfGeometricType = m._numberOfGeometricType; - if (m._geometricType != NULL) - { - _geometricType = new medGeometryElement[m._numberOfGeometricType]; - memcpy(_geometricType,m._geometricType,m._numberOfGeometricType*sizeof(medGeometryElement)); - } - else - _geometricType = (medGeometryElement *) NULL; - if (m._numberOfGaussPoint != NULL) - { - _numberOfGaussPoint = new int[m._numberOfGeometricType]; - memcpy(_numberOfGaussPoint,m._numberOfGaussPoint,m._numberOfGeometricType*sizeof(int)); - } - else - _numberOfGaussPoint = (int *) NULL; + + if (m._geometricType) + _geometricType.set(_numberOfGeometricType,m._geometricType); + + if (m._numberOfGaussPoint) + _numberOfGaussPoint.set(_numberOfGeometricType,m._numberOfGaussPoint); + _isOnAllElts = m._isOnAllElts; - if (m._numberOfElements != NULL) - { - _numberOfElements = new int[_numberOfGeometricType]; - memcpy(_numberOfElements,m._numberOfElements,_numberOfGeometricType*sizeof(int)); - } - else - _numberOfElements = (int *) NULL; + + if (m._numberOfElements) + _numberOfElements.set(_numberOfGeometricType,m._numberOfElements); + _totalNumberOfElements = m._totalNumberOfElements; + if (m._isOnAllElts == false) _number = new MEDSKYLINEARRAY(* m._number); else @@ -119,7 +102,40 @@ SUPPORT::SUPPORT(const SUPPORT & m) END_OF(LOC) ; }; +/*! + Affectation operator. operator = perform et deep copy except for attribute _mesh +*/ +//-------------------------------------------------------------------------- +SUPPORT & SUPPORT::operator=(const SUPPORT & m) +//-------------------------------------------------------------------------- +{ + const char * LOC = "SUPPORT::operator=(const SUPPORT & m) : " ; + BEGIN_OF(LOC) ; + + if ( this == &m ) return *this; + _name = m._name; + _description = m._description; + _mesh = m._mesh ; // on recopie uniquement l'adresse + _entity = m._entity; + _numberOfGeometricType = m._numberOfGeometricType; + if (m._geometricType) + _geometricType.set(_numberOfGeometricType,m._geometricType); + if (m._numberOfGaussPoint) + _numberOfGaussPoint.set(_numberOfGeometricType,m._numberOfGaussPoint); + _isOnAllElts = m._isOnAllElts; + if (m._numberOfElements) + _numberOfElements.set(_numberOfGeometricType,m._numberOfElements); + _totalNumberOfElements = m._totalNumberOfElements; + if (m._isOnAllElts == false) { + if (_number) delete _number; + _number = new MEDSKYLINEARRAY(* m._number); + } else + _number = (MEDSKYLINEARRAY *) NULL; + + END_OF(LOC) ; + return *this; +} /*! Destructor. @@ -151,7 +167,7 @@ ostream & MEDMEM::operator<<(ostream &os, const SUPPORT &my) if (!(my._isOnAllElts)) { int numberoftypes = my._numberOfGeometricType ; os << "NumberOfTypes : "< types = my._geometricType; for (int j=0;jgetNumberOfNodes(); - _totalNumberOfElements=_numberOfElements[0]; - _numberOfGaussPoint = new int[1] ; - _numberOfGaussPoint[0]=1; - } else { // we duplicate information from _mesh - _numberOfGeometricType=_mesh->getNumberOfTypesWithPoly(_entity); - if (_geometricType == (medGeometryElement *) NULL) - _geometricType=_mesh->getTypesWithPoly(_entity); + if (_isOnAllElts) + { + if (_entity == MED_NODE) + { + _numberOfGeometricType=1 ; + _geometricType.set(1); + _geometricType[0]=MED_NONE; + _numberOfElements.set(1); + _numberOfElements[0]=_mesh->getNumberOfNodes(); + _totalNumberOfElements=_numberOfElements[0]; + _numberOfGaussPoint.set(1) ; + _numberOfGaussPoint[0]=1; + } else - memcpy(_geometricType,_mesh->getTypes(_entity),_numberOfGeometricType*sizeof(medGeometryElement)); - if (_numberOfElements == (int *) NULL) - _numberOfElements = new int[_numberOfGeometricType] ; - if (_numberOfGaussPoint == (int *) NULL) - _numberOfGaussPoint = new int[_numberOfGeometricType] ; - _totalNumberOfElements=0; - for (int i=0;i<_numberOfGeometricType;i++) { - _numberOfElements[i]=_mesh->getNumberOfElementsWithPoly(_entity,_geometricType[i]) ; - _totalNumberOfElements+=_numberOfElements[i]; - _numberOfGaussPoint[i]=1 ; - } + { // we duplicate information from _mesh + _numberOfGeometricType=_mesh->getNumberOfTypesWithPoly(_entity); + SCRUTE(_numberOfGeometricType); + _geometricType.set(_numberOfGeometricType,_mesh->getTypesWithPoly(_entity) ); + _numberOfElements.set(_numberOfGeometricType); + _numberOfGaussPoint.set(_numberOfGeometricType); + _totalNumberOfElements=0; + for (int i=0;i<_numberOfGeometricType;i++) + { + _numberOfElements[i]=_mesh->getNumberOfElementsWithPoly(_entity,_geometricType[i]) ; + _totalNumberOfElements+=_numberOfElements[i]; + _numberOfGaussPoint[i]=1 ; + } + } + + SCRUTE(_name); + SCRUTE(_numberOfGeometricType); + SCRUTE(_numberOfGaussPoint); } - } END_OF(LOC); }; +/*! + Get the field value index (in fortran mode) from the support global number. + Becareful, it doesn't take care of the field number of components +*/ +//------------------- +int SUPPORT::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION) +//------------------- +{ + const char * LOC="getValIndFromGlobalNumber(const int number) : "; + BEGIN_OF(LOC); + + if (_isOnAllElts) return number; + + int nbOfEltsThis = getNumberOfElements(MED_ALL_ELEMENTS); + const int *eltsThis = _number->getValue(); + + int iThis; + bool found=false; + + for(iThis=0;iThis idsList; for(iter=idsSet.begin();iter!=idsSet.end();iter++) idsList.push_back(*iter); + + MESSAGE(LOC << " size Set " << idsSet.size() << " size List " << idsList.size()); + if(_entity==MED_NODE) fillFromNodeList(idsList); else @@ -281,14 +345,11 @@ void SUPPORT::setpartial(string Description, int NumberOfGeometricType, _description=Description; _numberOfGeometricType=NumberOfGeometricType; - - if (_geometricType!=NULL) delete[] _geometricType ; - _geometricType = new medGeometryElement[NumberOfGeometricType]; - if (_numberOfElements!=NULL) delete[] _numberOfElements ; - _numberOfElements = new int[NumberOfGeometricType]; + _geometricType.set(NumberOfGeometricType); + _numberOfElements.set(NumberOfGeometricType); _totalNumberOfElements = TotalNumberOfElements; - if (_numberOfGaussPoint!=NULL) delete[] _numberOfGaussPoint ; - _numberOfGaussPoint = new int[NumberOfGeometricType]; + _numberOfGaussPoint.set(NumberOfGeometricType); + int * index = new int[_numberOfGeometricType+1]; index[0]=1; int elemDim = -1; @@ -483,7 +544,11 @@ void SUPPORT::intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) if(idsSetMySupport.find(*iter)!=idsSetMySupport.end()) idsList.push_back(*iter); int size=idsSet.size(); - if(size!=0) + int sizeList = idsList.size(); + + MESSAGE(LOC << " size Set " << idsSet.size() << " size List " << idsList.size()); + + if(size!=0 && sizeList != 0) { if(_entity==MED_NODE) fillFromNodeList(idsList); @@ -497,45 +562,6 @@ void SUPPORT::intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) END_OF(LOC); }; -/*! - operator = perform et deep copy except for attribute _mesh - */ -SUPPORT& MEDMEM::SUPPORT::operator=(const SUPPORT &other) -{ - const char * LOC = "SUPPORT::operator=(const SUPPORT & m) : "; - BEGIN_OF(LOC); - - _name=other._name; - _description=other._description; - _mesh=other._mesh; - _entity=other._entity; - _isOnAllElts=other._isOnAllElts; - clearDataOnNumbers(); - _numberOfGeometricType=other._numberOfGeometricType; - _totalNumberOfElements=other._totalNumberOfElements; - - if(other._geometricType != NULL) - { - _geometricType=new medGeometryElement[other._numberOfGeometricType]; - memcpy(_geometricType,other._geometricType,other._numberOfGeometricType*sizeof(medGeometryElement)); - } - if (other._numberOfGaussPoint != NULL) - { - _numberOfGaussPoint=new int[other._numberOfGeometricType]; - memcpy(_numberOfGaussPoint,other._numberOfGaussPoint,other._numberOfGeometricType*sizeof(int)); - } - if(other._numberOfElements != NULL) - { - _numberOfElements=new int[_numberOfGeometricType]; - memcpy(_numberOfElements,other._numberOfElements,_numberOfGeometricType*sizeof(int)); - } - if(!_isOnAllElts) - { - _number=new MEDSKYLINEARRAY(* other._number); - } - return *this; -} - /*! Method that cleans up all the fields related to _numbers. Defined for code factorization. */ @@ -545,21 +571,7 @@ void MEDMEM::SUPPORT::clearDataOnNumbers() { _numberOfGeometricType=0; _totalNumberOfElements=0; - if(_geometricType) - { - delete [] _geometricType; - _geometricType=(medGeometryElement *) NULL; - } - if(_numberOfGaussPoint) - { - delete [] _numberOfGaussPoint; - _numberOfGaussPoint=(int *) NULL; - } - if(_numberOfElements) - { - delete [] _numberOfElements; - _numberOfElements=(int *) NULL; - } + if(_number) { delete _number; @@ -1053,16 +1065,28 @@ void MEDMEM::SUPPORT::fillFromElementList(const list& listOfElt) throw (MED /*! set the reference _mesh to Mesh */ //-------------------------------------- -void SUPPORT::setMesh(MESH *Mesh) +void SUPPORT::setMesh(MESH *Mesh) const //-------------------------------------- { if(_mesh) _mesh->removeReference(); _mesh=Mesh; + _meshName = ""; if(_mesh) _mesh->addReference(); } +/*! returns the mesh name */ +//------------------------------------ +string SUPPORT::getMeshName() const +//------------------------------------ +{ + if (_mesh) + return _mesh->getName(); + else + return _meshName; +} + /*! addReference : reference counter presently disconnected in C++ -> just connected for client. */ diff --git a/src/MEDMEM/MEDMEM_Support.hxx b/src/MEDMEM/MEDMEM_Support.hxx index d4915b572..8558a9c63 100644 --- a/src/MEDMEM/MEDMEM_Support.hxx +++ b/src/MEDMEM/MEDMEM_Support.hxx @@ -47,7 +47,8 @@ */ namespace MEDMEM { -class MESH ; + + class MESH; class SUPPORT : public RCBASE { @@ -59,6 +60,14 @@ protected: */ string _name; + /*! + \if developper + Name of the associated mesh if the _mesh pointer + is NULL. + \endif + */ + mutable string _meshName; + /*! \if developper Description of the support (optional). @@ -93,7 +102,7 @@ protected: Array of all geometric type defined in the support. \endif */ - MED_EN::medGeometryElement * _geometricType; + PointerOf _geometricType; /*! \if developper @@ -102,17 +111,7 @@ protected: (not yet implemented). \endif */ - mutable int * _numberOfGaussPoint ; - - /* - \if developper - Array of size _numberOfGeometricType - which contains number of geometric - entity type in Mesh - (to get corresponding CellModel). - \endif - */ - //int * _geometricTypeNumber; + mutable PointerOf _numberOfGaussPoint ; /*! \if developper @@ -127,7 +126,7 @@ protected: for each geometric type, the number of elements of this type. \endif */ - int * _numberOfElements; + PointerOf _numberOfElements; /*! \if developper @@ -162,7 +161,8 @@ public: inline void setName(string Name); inline void setDescription(string Description); - void setMesh(MESH *Mesh); + void setMesh(MESH *Mesh) const; + inline void setMeshName(const string & meshName); inline void setAll(bool All); inline void setEntity(MED_EN::medEntityMesh Entity); inline void setNumberOfGeometricType(int NumberOfGeometricType); @@ -176,6 +176,7 @@ public: inline string getName() const; inline string getDescription() const; virtual inline MESH * getMesh() const; + string getMeshName() const; inline MED_EN::medEntityMesh getEntity() const; inline bool isOnAllElements() const; @@ -184,9 +185,14 @@ public: inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION); inline int getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); inline int getNumberOfElements(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); + inline const int * getNumberOfElements() const throw (MEDEXCEPTION); + // rename getnumber -> getGlobalNumberSky() virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION); + // rename getNumber -> getGlobalNumberPtr() virtual inline const int * getNumber(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); + // rename in getGlobalNumberInd() virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION); + virtual int getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION); void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ; @@ -241,6 +247,11 @@ inline int SUPPORT::getNumberOfElements(MED_EN::medGeometryElement GeometricType return _numberOfElements[i]; throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ; } +//----------------------------------------------------------------------------- +inline const int * SUPPORT::getNumberOfElements() const throw (MEDEXCEPTION) { +//----------------------------------------------------------------------------- + return _numberOfElements; +} //--------------------------------------------------------------------- inline MEDSKYLINEARRAY * SUPPORT::getnumber() const @@ -268,14 +279,15 @@ inline const int * SUPPORT::getNumber(MED_EN::medGeometryElement GeometricType) throw (MEDEXCEPTION) //--------------------------------------------------------------------- { + const char * LOC = "Support::getNumber : " ; if (_isOnAllElts) - throw MEDEXCEPTION("Support::getNumber : Not defined, support is on all entity !") ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ; if (GeometricType==MED_EN::MED_ALL_ELEMENTS) return _number->getValue() ; for (int i=0;i<_numberOfGeometricType;i++) if (_geometricType[i]==GeometricType) return _number->getI(i+1) ; - throw MEDEXCEPTION("Support::getNumber : GeometricType not found !") ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ; } /*! @@ -300,6 +312,10 @@ inline const int * SUPPORT::getNumberOfGaussPoint() const throw (MEDEXCEPTION) //------------------------------------------------- { + SCRUTE(_name); + SCRUTE(_numberOfGeometricType); + SCRUTE(_numberOfGaussPoint); + if (_numberOfGaussPoint!=NULL) return _numberOfGaussPoint ; else @@ -324,7 +340,7 @@ inline int SUPPORT::getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement return _numberOfGaussPoint[i] ; throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ; } else - throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ; + return 1; } /*! set the attribute _name to Name */ @@ -343,6 +359,20 @@ inline void SUPPORT::setDescription(string Description) _description=Description; } + +/*! set the meshName if there is ni reference _mesh to Mesh */ +//-------------------------------------- +inline void SUPPORT::setMeshName(const string & meshName) +//-------------------------------------- +{ + const char * LOC = "SUPPORT::setMeshName(const string & meshName) : "; + + if (_mesh) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Setting meshName is not possible when an associated mesh is set !")) ; + + _meshName=meshName; +} + /*! set the attribute _isOnAllElts to All */ //------------------------------------------ inline void SUPPORT::setAll(bool All) @@ -364,18 +394,10 @@ inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType) //--------------------------------------------------------------------- { _numberOfGeometricType=NumberOfGeometricType; - if (_geometricType!=NULL) { - delete[] _geometricType ; - _geometricType = NULL ; - } - if (_numberOfElements!=NULL) { - delete[] _numberOfElements ; - _numberOfElements = NULL ; - } - if (_numberOfGaussPoint!=NULL) { - delete[] _numberOfGaussPoint ; - _numberOfGaussPoint = NULL ; - } + + _geometricType.set(0); + _numberOfElements.set(0); + _numberOfGaussPoint.set(0) ; } /*! set the attribute _geometricType to geometricType */ @@ -384,7 +406,7 @@ inline void SUPPORT::setGeometricType(const MED_EN::medGeometryElement *Geometri //--------------------------------------------------------------------- { if (NULL == _geometricType) - _geometricType=new MED_EN::medGeometryElement[_numberOfGeometricType]; + _geometricType.set(_numberOfGeometricType); for (int i=0;i<_numberOfGeometricType;i++) _geometricType[i] = GeometricType[i]; } @@ -395,7 +417,7 @@ inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint) //----------------------------------------------------------------- { if (NULL == _numberOfGaussPoint) - _numberOfGaussPoint=new int[_numberOfGeometricType]; + _numberOfGaussPoint.set(_numberOfGeometricType); for (int i=0;i<_numberOfGeometricType;i++) _numberOfGaussPoint[i] = NumberOfGaussPoint[i]; } @@ -409,8 +431,7 @@ inline void SUPPORT::setNumberOfElements(const int *NumberOfElements) //---------------------------------------------------------- { if (NULL == _numberOfElements) - _numberOfElements=new int[_numberOfGeometricType]; - memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType); + _numberOfElements.set(_numberOfGeometricType,NumberOfElements); _totalNumberOfElements = 0 ; for (int i=0;i<_numberOfGeometricType;i++) _totalNumberOfElements+=_numberOfElements[i]; diff --git a/src/MEDMEM/MEDMEM_Tags.hxx b/src/MEDMEM/MEDMEM_Tags.hxx new file mode 100644 index 000000000..1fd6bfdc7 --- /dev/null +++ b/src/MEDMEM/MEDMEM_Tags.hxx @@ -0,0 +1,15 @@ +#ifndef MEDMEM_TAGS_HXX +#define MEDMEM_TAGS_HXX + +namespace MEDMEM { + +struct Gauss {}; +struct NoGauss {}; +struct FullInterlace{}; +struct NoInterlace{}; + +} + +#endif + + diff --git a/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx b/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx index d83953b81..f8fa62a15 100644 --- a/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx +++ b/src/MEDMEM/MEDMEM_VtkFieldDriver.hxx @@ -29,9 +29,11 @@ #include "MEDMEM_GenDriver.hxx" #include "MEDMEM_Utilities.hxx" +#include "MEDMEM_STRING.hxx" #include "MEDMEM_Exception.hxx" #include "MEDMEM_Unit.hxx" -#include "MEDMEM_Array.hxx" +#include "MEDMEM_nArray.hxx" +#include "MEDMEM_ArrayConvert.hxx" #include "MEDMEM_Support.hxx" #include "MEDMEM_Mesh.hxx" #include "MEDMEM_CellModel.hxx" @@ -46,7 +48,6 @@ */ namespace MEDMEM { -template class FIELD; template class VTK_FIELD_DRIVER : public GENDRIVER { protected: @@ -66,6 +67,7 @@ public : /*! Constructor. */ + template VTK_FIELD_DRIVER():GENDRIVER(), _ptrField((FIELD *) 0), _fieldName(""), _fieldNum(MED_INVALID) @@ -80,10 +82,12 @@ public : /*! Constructor. */ - VTK_FIELD_DRIVER(const string & fileName, FIELD * ptrField) - : GENDRIVER(fileName,MED_EN::MED_WRONLY), - _ptrField((FIELD *) ptrField), - _fieldName(fileName),_fieldNum(MED_INVALID) + template + VTK_FIELD_DRIVER(const string & fileName, + FIELD * ptrField): + GENDRIVER(fileName,MED_EN::MED_WRONLY), + _ptrField((FIELD *) ptrField), + _fieldName(fileName),_fieldNum(MED_INVALID) { const char * LOC = "VTK_FIELD_DRIVER::VTK_FIELD_DRIVER(const string & fileName, FIELD * ptrField) "; BEGIN_OF(LOC); @@ -564,6 +568,9 @@ template void VTK_FIELD_DRIVER::write(void) const MED_EN::medEntityMesh entitySupport = supportField->getEntity(); name << nameField << "_" << dt << "_" << it ; + if ( _ptrField->getGaussPresence() ) + throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which use Gauss Points !" << entitySupport)); + if (!(supportField->isOnAllElements())) throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport)); @@ -608,7 +615,17 @@ template void VTK_FIELD_DRIVER::write(void) const else throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !")); - const T * value = _ptrField->getValue(MED_EN::MED_NO_INTERLACE) ; + // IL EST POSSIBLE D'AVOIR LES DEUX BOUCLES D'ECRITURE POUR EVITER + // DE CONVERTIR LE CHAMP DANS LE BON TYPE D'ENTRELACEMENT + const T * value; + if ( _ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) + value = _ptrField->getValue(); + else { + MEDMEM_Array_ * ptrArray = _ptrField->getArray(); + MEDMEM_Array * temp = dynamic_cast * > ( ptrArray ); + MEDMEM_Array * array = ArrayConvert( *temp ); + value = array->getPtr(); + } for (int i=0; i void VTK_FIELD_DRIVER::write(void) const (*_vtkFile) << value[j*NomberOfValue+i] << " " ; (*_vtkFile) << endl ; } + + if ( _ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) + delete value; END_OF(LOC); } @@ -648,6 +668,9 @@ template void VTK_FIELD_DRIVER::writeAppend(void) const MED_EN::medEntityMesh entitySupport = supportField->getEntity(); name << nameField << "_" << dt << "_" << it ; + if ( _ptrField->getGaussPresence() ) + throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which use Gauss Points !" << entitySupport)); + if (!(supportField->isOnAllElements())) throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" which is not on all entities of the mesh !" << entitySupport)); @@ -691,7 +714,15 @@ template void VTK_FIELD_DRIVER::writeAppend(void) const else throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !")); - const T * value = _ptrField->getValue(MED_EN::MED_NO_INTERLACE) ; + const T * value ; + if ( _ptrField->getInterlacingType() == MED_EN::MED_NO_INTERLACE ) + value = _ptrField->getValue(); + else { + MEDMEM_Array_ * ptrArray = _ptrField->getArray(); + MEDMEM_Array * temp = dynamic_cast * > ( ptrArray ); + MEDMEM_Array * array = ArrayConvert( *temp ); + value = array->getPtr(); + } for (int i=0; i void VTK_FIELD_DRIVER::writeAppend(void) const (*_vtkFile) << value[j*NomberOfValue+i] << " " ; (*_vtkFile) << endl ; } + + if ( _ptrField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) + delete value; + END_OF(LOC); } }//End namespace MEDMEM diff --git a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx b/src/MEDMEM/MEDMEM_VtkMedDriver.cxx index 4b55bde7a..bdd2a7c4a 100644 --- a/src/MEDMEM/MEDMEM_VtkMedDriver.cxx +++ b/src/MEDMEM/MEDMEM_VtkMedDriver.cxx @@ -450,8 +450,11 @@ void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const { const char * LOC = "VTK_MED_DRIVER::writeField() : "; BEGIN_OF(LOC); - int NomberOfValue = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ; - int NomberOfComponents = myField->getNumberOfComponents() ; + typedef MEDMEM_ArrayInterface::Array ArrayIntNo; + typedef MEDMEM_ArrayInterface::Array ArrayDoubleNo; + + int NumberOfValue = myField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS) ; + int NumberOfComponents = myField->getNumberOfComponents() ; med_type_champ type = myField->getValueType() ; SCRUTE(name); @@ -460,42 +463,68 @@ void VTK_MED_DRIVER::writeField(FIELD_ * myField,string name) const { { case MED_INT32 : { MESSAGE("MED_INT32"); - if (NomberOfComponents==3) { + if (NumberOfComponents==3) { (*_vtkFile) << "VECTORS " << name << " int" << endl ; - } else if (NomberOfComponents<=4) { - (*_vtkFile) << "SCALARS " << name << " int " << NomberOfComponents << endl ; + } else if (NumberOfComponents<=4) { + (*_vtkFile) << "SCALARS " << name << " int " << NumberOfComponents << endl ; (*_vtkFile) << "LOOKUP_TABLE default" << endl ; } else { MESSAGE(LOC << "Could not write field "<getName()<<" there are more than 4 components !"); return ; } - - //const int * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; - const int * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; - for (int i=0; igetInterlacingType() == MED_FULL_INTERLACE ) { + myArray = ArrayConvert( *( dynamic_cast< FIELD* > + (myField)->getArrayNoGauss() + ) + ); + value = myArray->getPtr(); + } else { + value = ((FIELD*)myField)->getValue() ; + } + + for (int i=0; igetInterlacingType() == MED_FULL_INTERLACE ) + delete[] myArray; break ; } case MED_REEL64 : { MESSAGE("MED_REEL64"); - if (NomberOfComponents==3) { + if (NumberOfComponents==3) { (*_vtkFile) << "VECTORS " << name << " float" << endl ; - } else if (NomberOfComponents<=4) { - (*_vtkFile) << "SCALARS " << name << " float " << NomberOfComponents << endl ; + } else if (NumberOfComponents<=4) { + (*_vtkFile) << "SCALARS " << name << " float " << NumberOfComponents << endl ; (*_vtkFile) << "LOOKUP_TABLE default" << endl ; } else { MESSAGE(LOC << "Could not write field "<getName()<<" there are more than 4 components !"); return ; } - const double * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; - for (int i=0; igetInterlacingType() == MED_FULL_INTERLACE ) { + myArray = ArrayConvert( *( dynamic_cast< FIELD* > + (myField)->getArrayNoGauss() + ) + ); + value = myArray->getPtr(); + } else { + value = ((FIELD*)myField)->getValue() ; + } + + for (int i=0; igetInterlacingType() == MED_FULL_INTERLACE ) + delete[] myArray; break ; } default : { diff --git a/src/MEDMEM/MEDMEM_define.hxx b/src/MEDMEM/MEDMEM_define.hxx index a1c6fa7f2..fb0c4e9d0 100644 --- a/src/MEDMEM/MEDMEM_define.hxx +++ b/src/MEDMEM/MEDMEM_define.hxx @@ -75,7 +75,8 @@ namespace MED_EN { typedef long medModeSwitch; const medModeSwitch MED_FULL_INTERLACE = 0; const medModeSwitch MED_NO_INTERLACE = 1; - + const medModeSwitch MED_UNDEFINED_INTERLACE = 3; + typedef long medConnectivity; const medConnectivity MED_NODAL = 0; const medConnectivity MED_DESCENDING = 1; @@ -86,7 +87,7 @@ namespace MED_EN { typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc; - typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26} med_type_champ; + typedef enum {MED_REEL64=6, MED_INT32=24,MED_INT64=26, MED_UNDEFINED_TYPE=0} med_type_champ; // #define MED_NBR_GEOMETRIE_MAILLE 15 // #define MED_NBR_GEOMETRIE_FACE 4 diff --git a/src/MEDMEM/MEDMEM_nArray.hxx b/src/MEDMEM/MEDMEM_nArray.hxx new file mode 100644 index 000000000..b55af88d2 --- /dev/null +++ b/src/MEDMEM/MEDMEM_nArray.hxx @@ -0,0 +1,235 @@ +#ifndef MEDMEM_ARRAY_HXX +#define MEDMEM_ARRAY_HXX + +#include "MEDMEM_InterlacingPolicy.hxx" +#include "MEDMEM_IndexCheckingPolicy.hxx" + +#include "MEDMEM_PointerOf.hxx" +#include "MEDMEM_define.hxx" + +namespace MEDMEM { + +class MEDMEM_Array_ { +public: + //virtual void dummy() {}; + virtual bool getGaussPresence() const { return false; } + virtual MED_EN::medModeSwitch getInterlacingType() const {return MED_EN::MED_UNDEFINED_INTERLACE;} + virtual ~MEDMEM_Array_() {}; //Indispensable pour détruire le vrai objet pointé +}; + +template < class ARRAY_ELEMENT_TYPE, + class INTERLACING_POLICY=FullInterlaceNoGaussPolicy, + class CHECKING_POLICY=IndexCheckPolicy > +class MEDMEM_Array : public INTERLACING_POLICY, public CHECKING_POLICY, public MEDMEM_Array_ { + +public : + + typedef ARRAY_ELEMENT_TYPE ElementType; + typedef INTERLACING_POLICY InterlacingPolicy; + typedef CHECKING_POLICY CheckingPolicy; + +public : + MEDMEM_Array():_array( ( ElementType *) NULL) {}; //Interdit le constructeur par défaut, peut pas à cause du FIELD + + ~MEDMEM_Array() { + // PointerOf s'occupe de la desallocation. + }; + + // Le mot clé inline permettra d'instancier le constructeur uniquement + // s'il est appelé ( ...NoGaussPolicy) + // Rem : Le constructeur de la policy demandée est appelé + inline MEDMEM_Array(int dim, int nbelem) : InterlacingPolicy(nbelem,dim) + { + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); + _array.set(INTERLACING_POLICY::_arraySize); + }; + + // Le mot clé inline permettra d'instancier le constructeur uniquement + // s'il est appelé ( ...NoGaussPolicy) + // Rem : Le constructeur de la policy demandée est appelé + inline MEDMEM_Array( ElementType * values, int dim, int nbelem, + bool shallowCopy=false, + bool ownershipOfValues=false) : InterlacingPolicy(nbelem,dim) + { + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); + if(shallowCopy) + + if(ownershipOfValues) + _array.setShallowAndOwnership((const ElementType *)values); + else + _array.set((const ElementType*)values); + + else // Cas par défaut + _array.set(INTERLACING_POLICY::_arraySize,values); + + } + + // Le mot clé inline permettra d'instancier le constructeur uniquement + // s'il est appelé ( ...GaussPolicy) + // Rem : Le constructeur de la policy demandée est appelé + inline MEDMEM_Array(int dim, int nbelem, int nbtypegeo, + const int * const nbelgeoc, const int * const nbgaussgeo) + : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc, nbgaussgeo) + { + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbtypegeo); + _array.set(INTERLACING_POLICY::_arraySize); + }; + + + // Le mot clé inline permettra d'instancier le constructeur uniquement + // s'il est appelé ( ...GaussPolicy) + // Rem : Le constructeur de la policy demandée est appelé + inline MEDMEM_Array(ElementType * values, int dim, int nbelem, int nbtypegeo, + const int * const nbelgeoc, const int * const nbgaussgeo, + bool shallowCopy=false, + bool ownershipOfValues=false) + : InterlacingPolicy(nbelem, dim, nbtypegeo, nbelgeoc, nbgaussgeo) + { + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbelem); + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",dim); + CHECKING_POLICY::checkMoreThanZero("MEDMEM_Array",nbtypegeo); + + if(shallowCopy) + + if(ownershipOfValues) + _array.setShallowAndOwnership((const ElementType *)values); + else + _array.set((const ElementType*)values); + + else + _array.set(INTERLACING_POLICY::_arraySize,values); + + }; + + // Constructeur de recopie pour un MEDMEM_Array avec les mêmes + // paramètres template qu'à la construction + inline MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false) + :InterlacingPolicy(array,shallowCopy) + { + if (shallowCopy) + this->_array.set(array._array); // Le propriétaire reste le ARRAY initial + else + this->_array.set(INTERLACING_POLICY::_arraySize,array._array); + } + + + // L'utilisation d'une copie superficielle pour l'opérateur d'affectation + // ne me parait pas être une bonne ideé : Compatibilité ancienne version MEDARRAY? + inline MEDMEM_Array & + operator=( const MEDMEM_Array & array) { + if ( this == &array) return *this; + BEGIN_OF("MEDMEM_Array operator ="); + InterlacingPolicy::operator=(array); //Appel des classes de base ? + + this->_array.set(array._array); // Le propriétaire reste le ARRAY initial + // verifier l'appel des opérateurs de la policy + + return *this; + } + + MED_EN::medModeSwitch getInterlacingType() const { + return InterlacingPolicy::getInterlacingType(); + } + + bool getGaussPresence() const { + return InterlacingPolicy::getGaussPresence(); + } + + ElementType * getPtr() { + return _array; + } + + void setPtr(ElementType * values, bool shallowCopy=false, + bool ownershipOfValues=false) { + + if(shallowCopy) + + if(ownershipOfValues) + _array.setShallowAndOwnership((const ElementType *)values); + else + _array.set((const ElementType*)values); + + else + _array.set(INTERLACING_POLICY::_arraySize,values); + } + + inline const ElementType * getRow(int i) const { + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i); + // Empêche l'utilisation de getRow en mode MED_NO_INTERLACE + // Ne devrait pas dépendre de la politique check + checkEquality("MEDMEM_Array (Interlace test)", + MED_EN::MED_NO_INTERLACE, + INTERLACING_POLICY::_interlacing ); + return &(_array[ INTERLACING_POLICY::getIndex(i,1) ]); + + } + + void setRow(int i,const ElementType * const value) { + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i); + // setRow fonctionne + // dans les deux modes d'entrelacement. + + for (int j =1; j <= INTERLACING_POLICY::getDim(); j++) + for (int k = 1 ; k <= INTERLACING_POLICY::getNbGauss(i); k++) + _array[INTERLACING_POLICY::getIndex(i,j,k)] = value[INTERLACING_POLICY::getIndex(1,j,k)]; + } + + inline const ElementType * getColumn(int j) const { + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j); + checkEquality("MEDMEM_Array (Interlace test)", + MED_EN::MED_FULL_INTERLACE, INTERLACING_POLICY::_interlacing ); + return &(_array[ INTERLACING_POLICY::getIndex(1,j) ]); + } + + void setColumn(int j, const ElementType * const value) { + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j); + // setColumn fonctionne + // dans les deux modes d'entrelacement. + + for (int i=1; i <= INTERLACING_POLICY::getNbElem(); i++) + for (int k = 1 ; k <= INTERLACING_POLICY::getNbGauss(i); k++) + _array[INTERLACING_POLICY::getIndex(i,j,k)] = value[INTERLACING_POLICY::getIndex(i,1,k)]; + } + + + inline const ElementType & getIJ(int i, int j) const { + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i); + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j); + return _array[ INTERLACING_POLICY::getIndex(i,j) ]; + } + + inline const ElementType & getIJK(int i, int j, int k ) const { + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i); + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j); + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::getNbGauss(i),k); + + return _array[ INTERLACING_POLICY::getIndex(i,j,k) ]; + }; + + inline void setIJ(int i, int j, const ElementType & value) { //autre signature avec + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i); + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j); + + _array[ INTERLACING_POLICY::getIndex(i,j) ] = value; // retour ElementType & ? + }; + + inline void setIJK(int i, int j, int k, const ElementType & value) { //autre signature avec + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_nbelem,i); + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::_dim,j); + checkInInclusiveRange("MEDMEM_Array",1,INTERLACING_POLICY::getNbGauss(i),k); + + _array[ INTERLACING_POLICY::getIndex(i,j,k) ] = value; // retour ElementType & ? + }; + + +private: + + PointerOf _array; +}; + +} //END NAMESPACE +#endif diff --git a/src/MEDMEM/Makefile.in b/src/MEDMEM/Makefile.in index fb0adfb84..1a4f7957d 100644 --- a/src/MEDMEM/Makefile.in +++ b/src/MEDMEM/Makefile.in @@ -82,7 +82,16 @@ MEDMEM_PolyhedronArray.hxx \ MEDMEM_MedFieldDriver22.hxx \ MEDMEM_MedMedDriver22.hxx \ MEDMEM_MedMeshDriver22.hxx \ -MEDMEM_Utilities.hxx +MEDMEM_Utilities.hxx \ +MEDMEM_ArrayInterface.hxx \ +MEDMEM_IndexCheckingPolicy.hxx \ +MEDMEM_InterlacingPolicy.hxx \ +MEDMEM_InterlacingTraits.hxx \ +MEDMEM_nArray.hxx \ +MEDMEM_Tags.hxx \ +MEDMEM_FieldConvert.hxx \ +MEDMEM_ArrayConvert.hxx \ +MEDMEM_FieldForward.hxx # Libraries targets @@ -128,10 +137,18 @@ BIN_SRC = BIN_SERVER_IDL = BIN_CLIENT_IDL = -TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit testUGeoNameMeshEntities testUMedException testUModulusArray testUSkyLineArray testUArray testUCellModel readEntete readCoordinate test_copie_field_ test_copie_fieldT test_copie_coordinate test_copie_medarray test_copie_connectivity test_copie_support test_copie_family test_copie_group test_copie_mesh test_affect_medarray test_MEDMEM_Meshing test_MEDMEM_MeshingPoly test_operation_fielddouble test_operation_fieldint test_gibi_driver test_porflow_driver test_grid test_MEDMEM_PolyhedronArray test_MEDMEM_PolyConnectivity test_MEDMEM_PolyDriverMedMeshRead test_MEDMEM_PolyDriverMedMeshWrite test_MEDMEM_poly3D -# test_MEDMEM_Meshing_poly - -# testUCellModel -> a revoir car l'API a changee (plus de vector) +TEST_PROGS = test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray \ + test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit \ + testUGeoNameMeshEntities testUMedException testUModulusArray \ + testUSkyLineArray testUArray testUCellModel readEntete readCoordinate \ + test_copie_field_ test_copie_fieldT test_copie_coordinate \ + test_copie_medarray test_copie_connectivity test_copie_support \ + test_copie_family test_copie_group test_copie_mesh test_affect_medarray \ + test_MEDMEM_Meshing test_MEDMEM_MeshingPoly test_operation_fielddouble \ + test_operation_fieldint test_gibi_driver test_porflow_driver \ + test_grid test_MEDMEM_PolyhedronArray test_MEDMEM_PolyConnectivity \ + test_MEDMEM_PolyDriverMedMeshRead test_MEDMEM_PolyDriverMedMeshWrite \ + test_MEDMEM_poly3D test_MEDMEM_nArray test_MEDMEM_Meshing_poly LDFLAGS+= -L$(top_builddir)/lib/salome LDFLAGSFORBIN+= -L$(top_builddir)/lib/salome diff --git a/src/MEDMEM/med_test.cxx b/src/MEDMEM/med_test.cxx index 7bfa2a9ca..45e6aacea 100644 --- a/src/MEDMEM/med_test.cxx +++ b/src/MEDMEM/med_test.cxx @@ -100,7 +100,6 @@ void affiche_groupe(MESH *myMesh,medEntityMesh Entity) } int main (int argc, char ** argv) { - int read; if ((argc !=3) && (argc != 4)) { cerr << "Usage : " << argv[0] @@ -454,7 +453,7 @@ int main (int argc, char ** argv) { // cout << value[j]<< " "; // cout< * myvalue = myField->getvalue(); + MEDMEM_Array * myvalue = myField->getArrayNoGauss(); const double * value ; for (int i=1; igetRow(i) ; diff --git a/src/MEDMEM/test_MEDMEM_Meshing.cxx b/src/MEDMEM/test_MEDMEM_Meshing.cxx index a8defc53b..99e4c9d32 100644 --- a/src/MEDMEM/test_MEDMEM_Meshing.cxx +++ b/src/MEDMEM/test_MEDMEM_Meshing.cxx @@ -24,6 +24,7 @@ using namespace std; using namespace MEDMEM; using namespace MED_EN; +using namespace DRIVERFACTORY; int main (int argc, char ** argv) { @@ -31,14 +32,15 @@ int main (int argc, char ** argv) { cerr << "Usage : " << argv[0] << " filenameRoot" << endl; cerr << " where filenameRoot is a root filename, the program will produce" << endl; - cerr << " 2 files filenameRoot.med and filenameRoot.vtk" << endl << endl; + cerr << " 3 files filenameRoot21.med filenameRoot22.med and filenameRoot.vtk" << endl << endl; exit(-1); } // filename to save the generated MESH string filenameRoot = argv[1] ; - string filenameMed = filenameRoot+".med"; + string filenameMed21 = filenameRoot+"_V21.med"; + string filenameMed22 = filenameRoot+"_V22.med"; string filenameVtk = filenameRoot+".vtk"; MESHING myMeshing ; @@ -156,6 +158,9 @@ int main (int argc, char ** argv) { myMeshing.setConnectivity(ConnectivityQua,MED_FACE,MED_QUAD4); + int meshDimension = SpaceDimension; // because there 3D cells in the mesh + myMeshing.setMeshDimension(meshDimension); + // edge part // not yet implemented : if set, results are unpredictable. @@ -280,10 +285,21 @@ int main (int argc, char ** argv) { myMeshing.addGroup(myGroup); } - // all rigtht, we save it ! + // all rigtht, we save it in Med 2.1 2.2 and vtk ! + + medFileVersion version = getMedFileVersionForWriting(); + if (version == V22) + setMedFileVersionForWriting(V21); + + int idMed21 = myMeshing.addDriver(MED_DRIVER,filenameMed21,myMeshing.getName()); + myMeshing.write(idMed21) ; - int idMed = myMeshing.addDriver(MED_DRIVER,filenameMed,myMeshing.getName()); - myMeshing.write(idMed) ; + version = getMedFileVersionForWriting(); + if (version == V21) + setMedFileVersionForWriting(V22); + + int idMed22 = myMeshing.addDriver(MED_DRIVER,filenameMed22,myMeshing.getName()); + myMeshing.write(idMed22) ; int idVtk = myMeshing.addDriver(VTK_DRIVER,filenameVtk,myMeshing.getName()); myMeshing.write(idVtk) ; @@ -308,8 +324,6 @@ int main (int argc, char ** argv) { fieldDoubleScalarOnNodes->setComponentDescription(1,"comp1"); fieldDoubleScalarOnNodes->setMEDComponentUnit(1,"unit1"); - fieldDoubleScalarOnNodes->setValueType(MED_REEL64); - FIELD * fieldDoubleVectorOnNodes = new FIELD(supportOnNodes,SpaceDimension); fieldDoubleVectorOnNodes->setName("fieldVectorDoubleNode"); fieldDoubleVectorOnNodes->setIterationNumber(-1); @@ -326,8 +340,6 @@ int main (int argc, char ** argv) { fieldDoubleVectorOnNodes->setComponentDescription(3,"comp3"); fieldDoubleVectorOnNodes->setMEDComponentUnit(3,"unit3"); - fieldDoubleVectorOnNodes->setValueType(MED_REEL64); - FIELD * fieldDoubleScalarOnCells = new FIELD(supportOnCells,1); fieldDoubleScalarOnCells->setName("fieldScalarDoubleCell"); fieldDoubleScalarOnCells->setIterationNumber(-1); @@ -338,8 +350,6 @@ int main (int argc, char ** argv) { fieldDoubleScalarOnCells->setComponentDescription(1,"comp1"); fieldDoubleScalarOnCells->setMEDComponentUnit(1,"unit1"); - fieldDoubleScalarOnCells->setValueType(MED_REEL64); - FIELD * fieldDoubleVectorOnCells = new FIELD(supportOnCells,SpaceDimension); fieldDoubleVectorOnCells->setName("fieldVectorrDoubleCell"); fieldDoubleVectorOnCells->setIterationNumber(-1); @@ -356,8 +366,6 @@ int main (int argc, char ** argv) { fieldDoubleVectorOnCells->setComponentDescription(3,"comp3"); fieldDoubleVectorOnCells->setMEDComponentUnit(3,"unit3"); - fieldDoubleVectorOnCells->setValueType(MED_REEL64); - FIELD * fieldIntScalarOnNodes = new FIELD(supportOnNodes,1); fieldIntScalarOnNodes->setName("fieldScalarIntNode"); fieldIntScalarOnNodes->setIterationNumber(-1); @@ -368,8 +376,6 @@ int main (int argc, char ** argv) { fieldIntScalarOnNodes->setComponentDescription(1,"comp1"); fieldIntScalarOnNodes->setMEDComponentUnit(1,"unit1"); - fieldIntScalarOnNodes->setValueType(MED_INT32); - FIELD * fieldIntVectorOnNodes = new FIELD(supportOnNodes,SpaceDimension); fieldIntVectorOnNodes->setName("fieldVectorIntNode"); fieldIntVectorOnNodes->setIterationNumber(-1); @@ -386,8 +392,6 @@ int main (int argc, char ** argv) { fieldIntVectorOnNodes->setComponentDescription(3,"comp3"); fieldIntVectorOnNodes->setMEDComponentUnit(3,"unit3"); - fieldIntVectorOnNodes->setValueType(MED_INT32); - FIELD * fieldIntScalarOnCells = new FIELD(supportOnCells,1); fieldIntScalarOnCells->setName("fieldScalarIntCell"); fieldIntScalarOnCells->setIterationNumber(-1); @@ -398,8 +402,6 @@ int main (int argc, char ** argv) { fieldIntScalarOnCells->setComponentDescription(1,"comp1"); fieldIntScalarOnCells->setMEDComponentUnit(1,"unit1"); - fieldIntScalarOnCells->setValueType(MED_INT32); - FIELD * fieldIntVectorOnCells = new FIELD(supportOnCells,SpaceDimension); fieldIntVectorOnCells->setName("fieldVectorrIntCell"); fieldIntVectorOnCells->setIterationNumber(-1); @@ -416,8 +418,6 @@ int main (int argc, char ** argv) { fieldIntVectorOnCells->setComponentDescription(3,"comp3"); fieldIntVectorOnCells->setMEDComponentUnit(3,"unit3"); - fieldIntVectorOnCells->setValueType(MED_INT32); - for (int i = 0; isetValueIJ(i+1,3,valueInt3); } - idMed = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed,fieldDoubleScalarOnNodes->getName()); - fieldDoubleScalarOnNodes->write(idMed) ; + version = getMedFileVersionForWriting(); + if (version == V22) + setMedFileVersionForWriting(V21); + + idMed21 = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldDoubleScalarOnNodes->getName()); + fieldDoubleScalarOnNodes->write(idMed21) ; + + idMed21 = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldIntScalarOnNodes->getName()); + fieldIntScalarOnNodes->write(idMed21) ; + + idMed21 = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldDoubleVectorOnNodes->getName()); + fieldDoubleVectorOnNodes->write(idMed21) ; + + idMed21 = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed21,fieldIntVectorOnNodes->getName()); + fieldIntVectorOnNodes->write(idMed21) ; + + idMed21 = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed21,fieldDoubleScalarOnCells->getName()); + fieldDoubleScalarOnCells->write(idMed21) ; + + idMed21 = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed21,fieldIntScalarOnCells->getName()); + fieldIntScalarOnCells->write(idMed21) ; + + idMed21 = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed21,fieldDoubleVectorOnCells->getName()); + fieldDoubleVectorOnCells->write(idMed21) ; + + idMed21 = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed21,fieldIntVectorOnCells->getName()); + fieldIntVectorOnCells->write(idMed21) ; + + version = getMedFileVersionForWriting(); + if (version == V21) + setMedFileVersionForWriting(V22); + + idMed22 = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnNodes->getName()); + fieldDoubleScalarOnNodes->write(idMed22) ; - idMed = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed,fieldIntScalarOnNodes->getName()); - fieldIntScalarOnNodes->write(idMed) ; + idMed22 = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnNodes->getName()); + fieldIntScalarOnNodes->write(idMed22) ; - idMed = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed,fieldDoubleVectorOnNodes->getName()); - fieldDoubleVectorOnNodes->write(idMed) ; + idMed22 = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnNodes->getName()); + fieldDoubleVectorOnNodes->write(idMed22) ; - idMed = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed,fieldIntVectorOnNodes->getName()); - fieldIntVectorOnNodes->write(idMed) ; + idMed22 = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnNodes->getName()); + fieldIntVectorOnNodes->write(idMed22) ; - idMed = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed,fieldDoubleScalarOnCells->getName()); - fieldDoubleScalarOnCells->write(idMed) ; + idMed22 = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnCells->getName()); + fieldDoubleScalarOnCells->write(idMed22) ; - idMed = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed,fieldIntScalarOnCells->getName()); - fieldIntScalarOnCells->write(idMed) ; + idMed22 = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnCells->getName()); + fieldIntScalarOnCells->write(idMed22) ; - idMed = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed,fieldDoubleVectorOnCells->getName()); - fieldDoubleVectorOnCells->write(idMed) ; + idMed22 = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnCells->getName()); + fieldDoubleVectorOnCells->write(idMed22) ; - idMed = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed,fieldIntVectorOnCells->getName()); - fieldIntVectorOnCells->write(idMed) ; + idMed22 = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnCells->getName()); + fieldIntVectorOnCells->write(idMed22) ; idVtk = fieldDoubleScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnNodes->getName()); fieldDoubleScalarOnNodes->writeAppend(idVtk) ; diff --git a/src/MEDMEM/test_MEDMEM_MeshingPoly.cxx b/src/MEDMEM/test_MEDMEM_MeshingPoly.cxx index aff80ff78..e2d07138d 100644 --- a/src/MEDMEM/test_MEDMEM_MeshingPoly.cxx +++ b/src/MEDMEM/test_MEDMEM_MeshingPoly.cxx @@ -160,7 +160,7 @@ int main (int argc, char ** argv) { myPolygonMeshing.setPolygonsConnectivity(REFpolygonIndex, REFpolygonFaces, 2, MED_CELL); SUPPORT *sup2 = new SUPPORT(&myPolygonMeshing); FIELD *areas = myPolygonMeshing.getArea(sup2); - const double *vals2 = areas->getValue(MED_FULL_INTERLACE); + const double *vals2 = areas->getValue(); const double REFAreaOfPolyg[4] ={1.5, 2, 6, 6.5}; int nbPts=0; int i; @@ -172,7 +172,7 @@ int main (int argc, char ** argv) { SUPPORT *sup = new SUPPORT(&myMeshing); FIELD *vols = myMeshing.getVolume(sup); - const double *vals = vols->getValue(MED_FULL_INTERLACE); + const double *vals = vols->getValue(); const double REFVolOfPolyHedron[3] = {2.333333333333333, 11.66666666666666, 13.83224131414673}; for(i=0;i<3;i++) if(fabs(REFVolOfPolyHedron[i]-vals[i])<1e-12) diff --git a/src/MEDMEM/test_MEDMEM_Meshing_poly.cxx b/src/MEDMEM/test_MEDMEM_Meshing_poly.cxx index 099bdbf1f..dff34e41f 100644 --- a/src/MEDMEM/test_MEDMEM_Meshing_poly.cxx +++ b/src/MEDMEM/test_MEDMEM_Meshing_poly.cxx @@ -18,10 +18,12 @@ // See http://www.salome-platform.org/ // #include "MEDMEM_Meshing.hxx" +#include "MEDMEM_DriverFactory.hxx" using namespace std; using namespace MEDMEM; using namespace MED_EN; +using namespace DRIVERFACTORY; int main (int argc, char ** argv) { @@ -29,11 +31,14 @@ int main (int argc, char ** argv) if (argc != 2) { cerr << "Usage : " << argv[0] - << " medfilename" << endl << endl - << "-> cré un maillage et le sauve dans le fichier medfilename." << endl; + << " filenameRoot" << endl << endl + << "-> creer un maillage et le sauve dans le fichier filenameRoot22.med sous le format Med Fichier V2.2 car il contient un polygon." << endl; exit(-1); } - string medfilename = argv[1]; + + string filenameRoot = argv[1] ; + + string medfilename = filenameRoot + "22.med"; // Creation maillage //*********************************************************************************** @@ -44,7 +49,6 @@ int main (int argc, char ** argv) // define coordinates int SpaceDimension = 2; - int MeshDimension = SpaceDimension ; int NumberOfNodes = 11; double Coordinates[2*11] = { 0.0, 0.0, @@ -60,8 +64,6 @@ int main (int argc, char ** argv) 1.5, 1.0, }; - myMeshing.setMeshDimension(MeshDimension) ; - myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE); string Names[3] = { "X","Y","Z" }; @@ -70,22 +72,24 @@ int main (int argc, char ** argv) string Units[3] = { "cm","cm","cm" }; myMeshing.setCoordinatesUnits(Units); - // define conectivities + // define conectivities of classic types // cell part - const int NumberOfTypes = 3; - medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4,MED_POLYGON}; - const int NumberOfElements[NumberOfTypes] = {1,4,1}; + const int NumberOfTypes = 2; + medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4}; + const int NumberOfElements[NumberOfTypes] = {1,4}; myMeshing.setNumberOfTypes(NumberOfTypes,MED_CELL); myMeshing.setTypes(Types,MED_CELL); + myMeshing.setNumberOfElements(NumberOfElements,MED_CELL); int ConnectivityTria[1*3]= { 7,4,1 }; + myMeshing.setConnectivity(ConnectivityTria,MED_CELL,MED_TRIA3); int ConnectivityQuad[4*4]= { @@ -95,6 +99,15 @@ int main (int argc, char ** argv) 8,9,6,5 }; + myMeshing.setConnectivity(ConnectivityQuad,MED_CELL,MED_QUAD4); + + int MeshDimension = SpaceDimension ; + // because there are 2D cells in the mesh + + myMeshing.setMeshDimension(MeshDimension) ; + + // then define eventuel polygonal cells + int ConnectivityPolygon[1*5]= { 9,11,10,3,6 @@ -104,55 +117,16 @@ int main (int argc, char ** argv) 1,6 }; - myMeshing.setNumberOfElements(NumberOfElements,MED_CELL,ConnectivityPolygonIndex,1); - myMeshing.setConnectivity(ConnectivityTria,MED_CELL,MED_TRIA3); - myMeshing.setConnectivity(ConnectivityQuad,MED_CELL,MED_QUAD4); - myMeshing.setConnectivity(ConnectivityPolygon,MED_CELL,MED_POLYGON,ConnectivityPolygonIndex,1); - - /* - // face part - - const int NumberOfFacesTypes = 2 ; - medGeometryElement FacesTypes[NumberOfFacesTypes] = {MED_TRIA3,MED_QUAD4} ; - const int NumberOfFacesElements[NumberOfFacesTypes] = {4,4} ; - - myMeshing.setNumberOfTypes(NumberOfFacesTypes,MED_FACE); - myMeshing.setTypes(FacesTypes,MED_FACE); - myMeshing.setNumberOfElements(NumberOfFacesElements,MED_FACE); - - const int sizeTria = 3*4 ; - int ConnectivityTria[sizeTria]= - { - 1,4,3, - 1,5,4, - 1,6,5, - 1,3,6 - }; - - myMeshing.setConnectivity(ConnectivityTria,MED_FACE,MED_TRIA3); - - int ConnectivityQua[4*4]= - { - 7,8,9,10, - 11,12,13,14, - 11,7,8,12, - 12,8,9,13 - }; - - myMeshing.setConnectivity(ConnectivityQua,MED_FACE,MED_QUAD4); - */ - - /* - // edge part - - // not yet implemented : if set, results are unpredictable. - */ + myMeshing.setPolygonsConnectivity(ConnectivityPolygonIndex,ConnectivityPolygon,1,MED_CELL); + // Ecriture fichier - // Ecriture fichier + medFileVersion version = getMedFileVersionForWriting(); + if (version == V21) + setMedFileVersionForWriting(V22); - int idMed = myMeshing.addDriver(MED_DRIVER,medfilename,myMeshing.getName()); - myMeshing.write(idMed) ; + int idMed22 = myMeshing.addDriver(MED_DRIVER,medfilename,myMeshing.getName()); + myMeshing.write(idMed22) ; // int idVtk = myMeshing.addDriver(VTK_DRIVER,"toto.vtk",myMeshing.getName()); // myMeshing.write(idVtk) ; diff --git a/src/MEDMEM/test_MEDMEM_nArray.cxx b/src/MEDMEM/test_MEDMEM_nArray.cxx new file mode 100644 index 000000000..aed8373ae --- /dev/null +++ b/src/MEDMEM/test_MEDMEM_nArray.cxx @@ -0,0 +1,412 @@ +#include +#include +#include + +#include "MEDMEM_ArrayInterface.hxx" +#include "MEDMEM_Field.hxx" +#include "MEDMEM_IndexCheckingPolicy.hxx" +#include "MEDMEM_ArrayConvert.hxx" + +using namespace MEDMEM; + +int main(void) { + + const int mdim = 2; + const int nbelem1 = 20; + + // TEST n° 1 FullInterlace et NoGauss + std::cout << std::endl; + std::cout << "Test de MEDMEM_Array en FullInterlace et NoGauss : " << std::endl; + std::cout << std::endl; + + bool test1ok = true; + const double * myArray1Ptr = 0; + const double array1Ref[] = { 11 , 12 , 21 , 22 , 31 , 32 , 41 , 42 , 51 , 52 , + 61 , 62 , 71 , 72 , 81 , 82 , 91 , 92 , 101 , 102 , + 111 , 112 , 121 , 122 , 131 , 132 , 141 , 142 , + 151 , 152 , 161 , 162 , 171 , 172 , 181 , 182 , + 191 , 192 , 201 , 202 }; + + const double array2Ref[] = { 11 , 21 , 31 , 41 , 51 , 61 , 71 , 81 , 91 , 101 + , 111 , 121 , 131 , 141 , 151 , 161 , 171 , 181 + , 191 , 201 , + 12 , 22 , 32 , 42 , 52 , 62 , 72 , 82 , 92 , 102 + , 112 , 122 , 132 , 142 , 152 , 162 , 172 , 182 + , 192 , 202 }; + + MEDMEM_Array myArray1(mdim,nbelem1); + + for (int i =1; i <= nbelem1; i++) + for (int j =1; j <= mdim; j++) + myArray1.setIJ(i,j,i*10+j); + + myArray1Ptr = myArray1.getPtr(); + for (int i =0; i < mdim*nbelem1; i++) + test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); + + std::cout << "- Egualité de myArray1 et de myArray1Ref : " << test1ok << std::endl ; + + test1ok = true; + MEDMEM_Array myArray1bis(myArray1, false); + myArray1Ptr = myArray1bis.getPtr(); + for (int i =0; i < mdim*nbelem1; i++) + test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); + std::cout << "- Constructeur par recopie en FullInterlace et NoGauss : " << test1ok << std::endl; + + test1ok = true; + MEDMEM_Array myArray1ter; + myArray1ter = myArray1; + myArray1Ptr = myArray1ter.getPtr(); + for (int i =0; i < mdim*nbelem1; i++) + test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); + std::cout << "- Opérateur d'affectation en FullInterlace et NoGauss : " << test1ok << std::endl; + + + test1ok = true; + MEDMEM_Array myArray1qua(mdim,nbelem1); + myArray1Ptr = myArray1qua.getPtr(); + + for (int i =1; i <= nbelem1; i++) + myArray1qua.setRow(i,&array1Ref[(i-1)*mdim]); + + for (int i =0; i < mdim*nbelem1; i++) + test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); + std::cout << "- Méthode setRow en FullInterlace et NoGauss : " << test1ok << std::endl; + + std::cout << "- Test de levée d'exception pour getColumn : "; + try { + myArray1qua.getColumn(1); + } + catch (MEDMEM::MEDEXCEPTION &m) { + std::cout << m.what() << endl ; + } + + test1ok = true; + MEDMEM_Array * myArray1cin = ArrayConvert(myArray1); + myArray1Ptr = myArray1cin->getPtr(); + int elemno = 0; + for (int j=1; j <= mdim; j++) + for (int i=1; i <= nbelem1 ; i++ ) { + test1ok = test1ok + && ( myArray1cin->getIJ(i,j) == array2Ref[elemno] ) + && ( myArray1Ptr[elemno] == array2Ref[elemno] ); + elemno++; + } + std::cout << "- Convertion du mode FullInterlaceNoGaussPolicy au mode NoInterlaceNoGaussPolicy : " + << test1ok << std::endl; + + + + // TEST n°2 NoInterlace et NoGauss + std::cout << std::endl; + std::cout << "Test de MEDMEM_Array en NoInterlace et NoGauss : " << std::endl; + std::cout << std::endl; + + bool test2ok = true; + const double * myArray2Ptr = 0; + + MEDMEM_Array myArray2(mdim,nbelem1); + + for (int i =1; i <= nbelem1; i++) + for (int j =1; j <= mdim; j++) + myArray2.setIJ(i,j,i*10+j); + + myArray2Ptr = myArray2.getPtr(); + for (int i =0; i < mdim*nbelem1; i++) + test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); + + std::cout << "- Egualité de myArray2 et de myArray2Ref : " << test2ok << std::endl ; + + test2ok = true; + MEDMEM_Array myArray2bis(myArray2, false); + myArray2Ptr = myArray2bis.getPtr(); + for (int i =0; i < mdim*nbelem1; i++) + test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); + std::cout << "- Constructeur par recopie en NoInterlace et NoGauss : " << test2ok << std::endl; + + test2ok = true; + MEDMEM_Array myArray2ter; + myArray2ter = myArray2; + myArray2Ptr = myArray2ter.getPtr(); + for (int i =0; i < mdim*nbelem1; i++) + test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); + std::cout << "- Opérateur d'affectation en NoInterlace et NoGauss : " << test2ok << std::endl; + + test2ok = true; + MEDMEM_Array myArray2qua(mdim,nbelem1); + myArray2Ptr = myArray2qua.getPtr(); + + for (int j =1; j <= mdim; j++) + myArray2qua.setColumn(j,&array2Ref[nbelem1*(j-1)]); + + for (int i =0; i < mdim*nbelem1; i++) + test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); + std::cout << "- Méthode setColumn en NoInterlace et NoGauss : " << test2ok << std::endl; + + std::cout << "- Test de levée d'exception pour getRow : " ; + try { + myArray2qua.getRow(1); + } + catch (MEDMEM::MEDEXCEPTION &m) { + std::cout << m.what() << endl ; + } + + test2ok = true; + MEDMEM_Array * myArray2cin = ArrayConvert(myArray2); + myArray2Ptr = myArray2cin->getPtr(); + elemno = 0; + for (int i=1; i <= nbelem1 ; i++ ) + for (int j=1; j <= mdim; j++) { + test2ok = test2ok + && ( myArray2cin->getIJ(i,j) == array1Ref[elemno] ) + && ( myArray2Ptr[elemno] == array1Ref[elemno] ); + elemno++; + } + std::cout << "- Convertion du mode NoInterlaceNoGaussPolicy au mode FullInterlaceNoGaussPolicy : " + << test2ok << std::endl; + + + // TEST n°3 FullInterlace et Gauss + const int nbelem2 = 5; + const int nbtypegeo = 2; + const int nbelgeoc[nbtypegeo+1] = {1,3,6}; + const int nbgaussgeo[nbtypegeo+1] = {-1,2,3}; + + std::cout << std::endl; + std::cout << "Test de MEDMEM_Array en FullInterlace et Gauss : " << std::endl; + std::cout << std::endl; + + bool test3ok = true; + const double * myArray3Ptr = 0; + const double array3Ref[] = {1.11 , 1.12 , 1.21 , 1.22 , + 2.11 , 2.12 , 2.21 , 2.22 , + 13.11 , 13.12 , 13.21 , 13.22 , 13.31 , 13.32 , + 14.11 , 14.12 , 14.21 , 14.22 , 14.31 , 14.32 , + 15.11 , 15.12 , 15.21 , 15.22 , 15.31 , 15.32 }; + + const double array4Ref[] = { 1.11 , 1.21 , 2.11 , 2.21, + 13.11 , 13.21 , 13.31 , 14.11 , 14.21 , 14.31 , + 15.11 , 15.21 , 15.31 , + 1.12 , 1.22 , 2.12 , 2.22 , + 13.12 , 13.22 , 13.32 , 14.12 , 14.22 , 14.32 , + 15.12 , 15.22 , 15.32 }; + + MEDMEM_Array myArray3(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); + + elemno = 1; + for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { + for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { + for (int k=1; k <= nbgaussgeo[ntyp]; k++) + for (int j=1; j <= mdim; j++) { + myArray3.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j); + } + elemno++; + } + } + myArray3Ptr = myArray3.getPtr(); + for (int i =0; i < myArray3.getArraySize(); i++) + test3ok = test3ok && ( myArray3Ptr[i] == array3Ref[i] ); + + std::cout << "- Egualité de myArray3 et de myArray3Ref : " << test3ok << std::endl ; + + test3ok = true; + MEDMEM_Array myArray3bis(myArray3, false); + myArray3Ptr = myArray3bis.getPtr(); + + elemno = 0; + for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) + for (int k=1; k <= myArray3bis.getNbGauss(i); k++) + for (int j=1; j <= mdim; j++) { + test3ok = test3ok + && ( myArray3bis.getIJK(i,j,k) == array3Ref[elemno] ) + && ( myArray3Ptr[elemno] == array3Ref[elemno] ); + elemno++; + } + std::cout << "- Constructeur par recopie en FullInterlace et Gauss : " << test3ok << std::endl; + + test3ok = true; + MEDMEM_Array myArray3ter; + myArray3ter = myArray3; //Opérateur d'affectation + myArray3Ptr = myArray3ter.getPtr(); + + elemno = 0; + for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) + for (int k=1; k <= myArray3ter.getNbGauss(i); k++) + for (int j=1; j <= mdim; j++) { + test3ok = test3ok + && ( myArray3ter.getIJK(i,j,k) == array3Ref[elemno] ) + && ( myArray3Ptr[elemno] == array3Ref[elemno] ); + elemno++; + } + + std::cout << "- Opérateur d'affectation en FullInterlace et Gauss : " << test3ok << std::endl; + + + test3ok = true; + MEDMEM_Array myArray3qua(mdim,nbelem2, + nbtypegeo,nbelgeoc,nbgaussgeo); + myArray3Ptr = myArray3qua.getPtr(); + + int cumul = 0; + for (int i =1; i <= nbelem2; i++){ + myArray3qua.setRow(i,&array3Ref[cumul]); + cumul+=myArray3qua.getNbGauss(i)*mdim; + }; + + for (int i =0; i < myArray3qua.getArraySize(); i++) + test3ok = test3ok && ( myArray3Ptr[i] == array3Ref[i] ); + std::cout << "- Méthode setRow en FullInterlace et Gauss : " << test3ok << std::endl; + + std::cout << "- Test de levée d'exception pour getColumn : " ; + try { + myArray3qua.getColumn(1); + } + catch (MEDMEM::MEDEXCEPTION &m) { + std::cout << m.what() << endl ; + } + + test3ok = true; + MEDMEM_Array * myArray3cin = ArrayConvert(myArray3); + myArray3Ptr = myArray3cin->getPtr(); + elemno = 0; + for (int j=1; j <= mdim; j++) + for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) + for (int k=1; k <= myArray3cin->getNbGauss(i); k++) { + test3ok = test3ok + && ( myArray3cin->getIJK(i,j,k) == array4Ref[elemno] ) + && ( myArray3Ptr[elemno] == array4Ref[elemno] ); + elemno++; + } + std::cout << "- Convertion du mode FullInterlaceGaussPolicy au mode NoInterlaceGaussPolicy : " + << test3ok << std::endl; + + + // TEST n°4 NoInterlace et Gauss + std::cout << std::endl; + std::cout << "Test de MEDMEM_Array en NoInterlace et Gauss : " << std::endl; + std::cout << std::endl; + + bool test4ok = true; + const double * myArray4Ptr = 0; + + MEDMEM_Array myArray4(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); + + elemno = 1; + for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { + for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { + for (int k=1; k <= nbgaussgeo[ntyp]; k++) + for (int j=1; j <= mdim; j++) { + myArray4.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j); + } + elemno++; + } + } + myArray4Ptr = myArray4.getPtr(); + for (int i =0; i < myArray4.getArraySize(); i++) { + test4ok = test4ok && ( myArray4Ptr[i] == array4Ref[i] ); + } + std::cout << "- Egualité de myArray4 et de myArray4Ref : " << test4ok << std::endl ; + + test4ok = true; + MEDMEM_Array myArray4bis(myArray4, false); + myArray4Ptr = myArray4bis.getPtr(); + + elemno = 0; + for (int j=1; j <= mdim; j++) + for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) + for (int k=1; k <= myArray4bis.getNbGauss(i); k++) { + test4ok = test4ok + && ( myArray4bis.getIJK(i,j,k) == array4Ref[elemno] ) + && ( myArray4Ptr[elemno] == array4Ref[elemno] ); + elemno++; + } + std::cout << "- Constructeur par recopie en NoInterlace et Gauss : " << test4ok << std::endl; + + test4ok = true; + MEDMEM_Array myArray4ter; + myArray4ter = myArray4; // Opérateur d'affectation + myArray4Ptr = myArray4ter.getPtr(); + + elemno = 0; + for (int j=1; j <= mdim; j++) + for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) + for (int k=1; k <= myArray4ter.getNbGauss(i); k++) { + test4ok = test4ok + && ( myArray4ter.getIJK(i,j,k) == array4Ref[elemno] ) + && ( myArray4Ptr[elemno] == array4Ref[elemno] ); + elemno++; + } + + std::cout << "- Opérateur d'affectation en NoInterlace et Gauss : " << test4ok << std::endl; + + + test4ok = true; + MEDMEM_Array myArray4qua(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); + myArray4Ptr = myArray4qua.getPtr(); + + for (int j =1; j <= mdim; j++) + myArray4qua.setColumn(j,&array4Ref[(myArray4qua.getArraySize()/mdim)*(j-1)]); + + for (int i =0; i < myArray4qua.getArraySize(); i++) + test4ok = test4ok && ( myArray4Ptr[i] == array4Ref[i] ); + std::cout << "- Méthode setColumn en NoInterlace et Gauss : " << test4ok << std::endl; + + std::cout << "- Test de levée d'exception pour getRow : " ; + try { + myArray4qua.getRow(1); + } + catch (MEDMEM::MEDEXCEPTION &m) { + std::cout << m.what() << endl ; + } + + + test4ok = true; + MEDMEM_Array * myArray4cin = ArrayConvert(myArray4); + //// MEDMEM_Array * myArray4cin; + ////ArrayConvert(myArray4,myArray4cin); + // typedef MEDMEM_Array MyArray; + // MyArray myArray4cin MyArray(myArray4); + // myArray4cin.convert(myArray4); + // MEDMEM_Array myArray4cin(myArray4); + myArray4Ptr = myArray4cin->getPtr(); + elemno = 0; + for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) + for (int k=1; k <= myArray4cin->getNbGauss(i); k++) + for (int j=1; j <= mdim; j++) { + test4ok = test4ok + && ( myArray4cin->getIJK(i,j,k) == array3Ref[elemno] ) + && ( myArray4cin->getIJK(i,j,k) == myArray3.getIJK(i,j,k) ) + && ( myArray4Ptr[elemno] == array3Ref[elemno] ); + elemno++; + } + + std::cout << "- Convertion du mode NoInterlaceGaussPolicy au mode FullInterlaceGaussPolicy : " + << test4ok << std::endl; + + + //TEST DES METHODES D'INTERROGATION en NoInterlace et Gauss : + // MEDMEM_ArrayInterface::Array & myArray4bis = myField4bis.getArray(); + + std::cout << std::endl; + std::cout << "Test de la méthode getDim : " << myArray4bis.getDim() << std::endl; + std::cout << "Test de la méthode getNbelem : " << myArray4bis.getNbElem() << std::endl; + std::cout << "Test de la méthode getArraySize : " << myArray4bis.getArraySize() << std::endl; + std::cout << "Test de la méthode getInterlacingType : " << myArray4bis.getInterlacingType() << std::endl; + + + // Test de levée d'exception si MED_ARRAY compilée avec une politique de checking + std::cout << std::endl; + std::cout << "Test de levée d'exception pour indice incohérent " << std::endl; + try { + myArray4.getIJ(0,2); //L'exception génère des blocks perdus (A voir) + } + catch (MEDMEM::MEDEXCEPTION &m) { + std::cout << m.what() << endl ; + } + + + + return 0; + +}; + diff --git a/src/MEDMEM/test_MEDMEM_poly3D.cxx b/src/MEDMEM/test_MEDMEM_poly3D.cxx index acb311b72..3dd0a5b6b 100755 --- a/src/MEDMEM/test_MEDMEM_poly3D.cxx +++ b/src/MEDMEM/test_MEDMEM_poly3D.cxx @@ -231,8 +231,8 @@ int main (int argc, char ** argv) nbOfPtsForTest=0; SUPPORT *supOnCell=new SUPPORT(myMesh); FIELD* vol1=myMesh->getVolume(supOnCell); - int lgth=vol1->getValueLength(MED_FULL_INTERLACE); - const double *vals=vol1->getValue(MED_FULL_INTERLACE); + int lgth=vol1->getValueLength(); + const double *vals=vol1->getValue(); if(lgth==3) nbOfPtsForTest++; const double REFVolOfPolyHedron[3]={2.333333333333333,11.66666666666666,13.83224131414673}; @@ -241,8 +241,8 @@ int main (int argc, char ** argv) nbOfPtsForTest++; delete vol1; FIELD* bary=myMesh->getBarycenter(supOnCell); - lgth=bary->getValueLength(MED_FULL_INTERLACE); - vals=bary->getValue(MED_FULL_INTERLACE); + lgth=bary->getValueLength(); + vals=bary->getValue(); if(lgth==9) nbOfPtsForTest++; const double REFBaryOfPolyHedron[9]= {5.5, 1, -1, 2, 1.5, 1.0833333333333333, 5.1, 1.6, 0.9}; @@ -253,8 +253,8 @@ int main (int argc, char ** argv) delete supOnCell; //area vol1=myMesh->getArea(fam1); - lgth=vol1->getValueLength(MED_FULL_INTERLACE); - vals=vol1->getValue(MED_FULL_INTERLACE); + lgth=vol1->getValueLength(); + vals=vol1->getValue(); if(lgth==3) nbOfPtsForTest++; const double REFAreaForPolyg[3]={6,5,6.5}; @@ -263,8 +263,8 @@ int main (int argc, char ** argv) nbOfPtsForTest++; vol1=myMesh->getArea(fam2); - lgth=vol1->getValueLength(MED_FULL_INTERLACE); - vals=vol1->getValue(MED_FULL_INTERLACE); + lgth=vol1->getValueLength(); + vals=vol1->getValue(); if(lgth==8) nbOfPtsForTest++; const double REFAreaForQuad[8]={2.1213203435596424, 2.8284271247461903, 4.4721359549995796, 4.4721359549995796, @@ -275,8 +275,8 @@ int main (int argc, char ** argv) delete vol1; vol1=myMesh->getArea(fam3); - lgth=vol1->getValueLength(MED_FULL_INTERLACE); - vals=vol1->getValue(MED_FULL_INTERLACE); + lgth=vol1->getValueLength(); + vals=vol1->getValue(); if(lgth==6) nbOfPtsForTest++; const double REFAreaForTri[6]={2.9580398915498081, 1.4142135623730951, 2.2360679774997898, diff --git a/src/MEDMEM/test_copie_fieldT.cxx b/src/MEDMEM/test_copie_fieldT.cxx index d7ddc46cf..31a66fa01 100644 --- a/src/MEDMEM/test_copie_fieldT.cxx +++ b/src/MEDMEM/test_copie_fieldT.cxx @@ -34,6 +34,7 @@ #include "MEDMEM_MedFieldDriver.hxx" #include "MEDMEM_Support.hxx" #include "MEDMEM_Field.hxx" +#include "MEDMEM_FieldConvert.hxx" #include "MEDMEM_define.hxx" using namespace std; @@ -62,7 +63,9 @@ void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport) cout << "- Adresse support : " << mySupport << endl; } -void affiche_fieldT(FIELD * myField, const SUPPORT * mySupport) +template +void affiche_fieldT(FIELD * myField, + const SUPPORT * mySupport) { affiche_field_((FIELD_ *) myField, mySupport); @@ -70,11 +73,21 @@ void affiche_fieldT(FIELD * myField, const SUPPORT * mySupport) int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS); int NumberOfComponents = myField->getNumberOfComponents() ; - for (int i=1; igetValueI(MED_FULL_INTERLACE,i) ; - for (int j=0; jgetInterlacingType() == MED_EN::MED_FULL_INTERLACE ) { + for (int i=1; igetRow(i) ; + for (int j=0; jgetColumn(j) ; + for (int i=0; i(mySupport,MED_DRIVER,filename,fieldname) ; - myField->setValueType(MED_REEL64); } catch (...) { delete mySupport ; mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE); try { myField = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - myField->setValueType(MED_REEL64); } catch (...) { cout << "Field double " << fieldname << " not found !!!" << endl ; exit (-1) ; @@ -121,11 +132,22 @@ int main (int argc, char ** argv) { } affiche_fieldT(myField, mySupport); - FIELD * myField2 = new FIELD(* myField); - delete myField; + FIELD * myField2 = new FIELD(* myField); // Contructeur par recopie, sauf SUPPORT + delete myField; // Ne détruit pas le Support affiche_fieldT(myField2, myField2->getSupport()); + FIELD * myField3 = FieldConvert( *myField2 ); delete myField2; + affiche_fieldT(myField3, myField3->getSupport()); + FIELD * myField4 = FieldConvert( *myField3 ); + delete myField3; + affiche_fieldT(myField4, myField4->getSupport()); + delete myField4; + + FIELD * myField5 = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; + affiche_fieldT(myField5, myField5->getSupport()); + delete myField5; + delete mySupport ; delete myMesh ; diff --git a/src/MEDMEM/test_copie_field_.cxx b/src/MEDMEM/test_copie_field_.cxx index c8a706684..e0c2a0ce9 100644 --- a/src/MEDMEM/test_copie_field_.cxx +++ b/src/MEDMEM/test_copie_field_.cxx @@ -112,7 +112,6 @@ int main (int argc, char ** argv) { // SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE); SUPPORT * mySupport = new SUPPORT(myMesh,"On_all_cell",MED_EN::MED_CELL); FIELD * myField = new FIELD() ; - myField->setValueType(MED_EN::MED_REEL64); myField->setName(fieldname); myField->setSupport(mySupport); diff --git a/src/MEDMEM/test_gibi_driver.cxx b/src/MEDMEM/test_gibi_driver.cxx index 24ba6de6c..b423bbb84 100644 --- a/src/MEDMEM/test_gibi_driver.cxx +++ b/src/MEDMEM/test_gibi_driver.cxx @@ -19,9 +19,13 @@ // #include "MEDMEM_GibiMeshDriver.hxx" #include "MEDMEM_Mesh.hxx" +#include "MEDMEM_DriverFactory.hxx" using namespace std; using namespace MEDMEM; +using namespace MED_EN; +using namespace DRIVERFACTORY; + int main (int argc, char ** argv) { /* process the arguments */ @@ -29,7 +33,7 @@ int main (int argc, char ** argv) { cerr << "Usage : " << argv[0] << "Gibifilename" << endl << endl - << "-> lit le fichier gibi filename ,crée 2 fichiers : MED et VTK" << endl; + << "-> lit le fichier gibi filename ,crée 3 fichiers : MED 2.1, 2.2 et VTK" << endl; exit(-1); } @@ -39,7 +43,8 @@ int main (int argc, char ** argv) const string ext=".sauve"; string::size_type pos=gibifilename.find(ext,0); string basename (gibifilename, 0, pos); // nom sans extension - string medfile=basename+".med"; // nom fichier med à creer + string medfile21=basename+"_V21.med"; // nom fichier med 2.1 à creer + string medfile22=basename+"_V22.med"; // nom fichier med 2.2 à creer string vtkfile=basename+".vtk"; // nom fichier vtk à creer string::size_type pos1=gibifilename.rfind('/'); string meshName (gibifilename,pos1+1,pos-pos1-1); // get rid of directory & extension @@ -56,10 +61,22 @@ int main (int argc, char ** argv) cout << "Impression de MESH : " << endl; cout << *myMesh; - // creation d'un fichier med - cout << "creation d'un fichier med : " << endl; - int idMed = myMesh->addDriver(MED_DRIVER, medfile, meshName); - myMesh->write(idMed) ; + // creation des fichiers med 2.1 et 2.2 + medFileVersion version = getMedFileVersionForWriting(); + if (version == V22) + setMedFileVersionForWriting(V21); + + cout << "creation du fichier med 21 : " << endl; + int idMed21 = myMesh->addDriver(MED_DRIVER, medfile21, meshName); + myMesh->write(idMed21) ; + + version = getMedFileVersionForWriting(); + if (version == V21) + setMedFileVersionForWriting(V22); + + cout << "creation du fichier med 22 : " << endl; + int idMed22 = myMesh->addDriver(MED_DRIVER, medfile22, meshName); + myMesh->write(idMed22) ; // creation d'un fichier vtk cout << "creation d'un fichier vtk : " << endl; @@ -67,8 +84,8 @@ int main (int argc, char ** argv) myMesh->write(idVtk) ; delete myMesh; - // remontée mémoire du fichier med - myMesh= new MESH(MED_DRIVER,medfile,meshName); + // remontée mémoire du fichier med 21 + myMesh= new MESH(MED_DRIVER,medfile21,meshName); //myMesh= new MESH() ; //myMesh->setName(meshName); //MED_MESH_RDONLY_DRIVER myMeshDriver(medfile,myMesh) ; @@ -80,5 +97,8 @@ int main (int argc, char ** argv) //cout << *myMesh; delete myMesh; + // remontée mémoire du fichier med 22 + myMesh= new MESH(MED_DRIVER,medfile22,meshName); + delete myMesh; } diff --git a/src/MEDMEM/test_operation_fielddouble.cxx b/src/MEDMEM/test_operation_fielddouble.cxx index 981bcf488..8853b089f 100644 --- a/src/MEDMEM/test_operation_fielddouble.cxx +++ b/src/MEDMEM/test_operation_fielddouble.cxx @@ -76,7 +76,7 @@ void affiche_fieldT(FIELD * myField, const SUPPORT * mySupport) int NumberOfComponents = myField->getNumberOfComponents() ; for (int i=1; igetValueI(MED_FULL_INTERLACE,i) ; + const double * value = myField->getRow(i) ; for (int j=0; j * myField, const SUPPORT * mySupport) cout << "Norme euclidienne : " << myField->norm2() << endl; cout << "Norme max : " << myField->normMax() << endl; try - { + { for (int i=1; i<=myField->getNumberOfComponents(); ++i) - cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl; + cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl; cout << "Norme L2 : " << myField->normL2() << endl; for (int i=1; i<=myField->getNumberOfComponents(); ++i) - cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl; + cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl; cout << "Norme L1 : " << myField->normL1() << endl; - } + } catch (MEDEXCEPTION &ex) - { + { cout << ex.what() << endl; - } + } } void affiche_valeur_field(const FIELD& f) { - const int tailleMax=12; - const int taille=f.getNumberOfValues()*f.getNumberOfComponents(); - const double * value=f.getValue(f.getvalue()->getMode()); - if(taille<=tailleMax) - for(int i=0;i& resOp, const FIELD& f1, const FIELD& f2, - char Op, const char* intitule, int verbose) +void checkOperation(const FIELD& resOp, const FIELD& f1, const FIELD& f2, + char Op, const char* intitule, int verbose) { - int res=0; - - // get pointers to inside arrays of values - medModeSwitch mode=resOp.getvalue()->getMode(); - const double * value=resOp.getValue(mode); - const double * value1=f1.getValue(mode); - const double * value2=f2.getValue(mode); - const int size=f1.getNumberOfValues()*f1.getNumberOfComponents(); // size of field1 - - // check size compatibility - if(f1.getNumberOfValues()*f1.getNumberOfComponents()!=size || - resOp.getNumberOfValues()*resOp.getNumberOfComponents()!=size) - res=1; - - if(!res) + int res=0; + + // get pointers to inside arrays of values + const double * value=resOp.getValue(); + const double * value1=f1.getValue(); + const double * value2=f2.getValue(); + const int size=f1.getNumberOfValues()*f1.getNumberOfComponents(); // size of field1 + + // check size compatibility + if(f1.getNumberOfValues()*f1.getNumberOfComponents()!=size || + resOp.getNumberOfValues()*resOp.getNumberOfComponents()!=size) + res=1; + + if(!res) { - switch(Op) + switch(Op) { - case '+': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]+value2[i]) - res+=1; - break; - case '-': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]-value2[i]) - res+=1; - break; - case 'n': - for(int i=0; i!=size; ++i) - if(value[i]!=-value1[i]) - res+=1; - break; - case '*': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]*value2[i]) - res+=1; - break; - case '/': - for(int i=0; i!=size; ++i) - if(value2[i]!=0.0) - if(value[i]!=value1[i]/value2[i]) - res+=1; - break; - case '=': - for(int i=0; i!=size; ++i) - if(value[i]!=value2[i]) - res+=1; - break; - case 'a': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]+value2[i]*value2[i]) - res+=1; - break; + case '+': + for(int i=0; i!=size; ++i) + if(value[i]!=value1[i]+value2[i]) + res+=1; + break; + case '-': + for(int i=0; i!=size; ++i) + if(value[i]!=value1[i]-value2[i]) + res+=1; + break; + case 'n': + for(int i=0; i!=size; ++i) + if(value[i]!=-value1[i]) + res+=1; + break; + case '*': + for(int i=0; i!=size; ++i) + if(value[i]!=value1[i]*value2[i]) + res+=1; + break; + case '/': + for(int i=0; i!=size; ++i) + if(value2[i]!=0.0) + if(value[i]!=value1[i]/value2[i]) + res+=1; + break; + case '=': + for(int i=0; i!=size; ++i) + if(value[i]!=value2[i]) + res+=1; + break; + case 'a': + for(int i=0; i!=size; ++i) + if(value[i]!=value1[i]+value2[i]*value2[i]) + res+=1; + break; } - + } - if (verbose) - cout << endl << intitule << "["; - cout << res; - if (verbose) + if (verbose) + cout << endl << intitule << "["; + cout << res; + if (verbose) { - cout << "] : "; - affiche_valeur_field(resOp); + cout << "] : "; + affiche_valeur_field(resOp); } - else - cout << endl; + else + cout << endl; } int main (int argc, char ** argv) { - /* process the arguments */ - int verbose=0; // verbose=1 if the verbose mode is selected - int res=0; // unit test result - int ntest=0; // numéro du test + /* process the arguments */ + int verbose=0; // verbose=1 if the verbose mode is selected + int res=0; // unit test result + int ntest=0; // numéro du test - if (argc>=2 && !strcmp(argv[1],"-v")) - verbose=1; + if (argc>=2 && !strcmp(argv[1],"-v")) + verbose=1; - if (argc != 4+verbose) + if (argc != 4+verbose) { - cerr << "Usage : " << argv[0] - << "[-v] filename meshname fieldname" << endl << endl - << "-> tests field's operations on the FIELD fieldname" << endl - << "Use optional option -v to select verbose mode" << endl; - exit(-1); + cerr << "Usage : " << argv[0] + << "[-v] filename meshname fieldname" << endl << endl + << "-> tests field's operations on the FIELD fieldname" << endl + << "Use optional option -v to select verbose mode" << endl; + exit(-1); } + string filename = argv[verbose+1]; + string meshname = argv[verbose+2];// Maintenant plus très utile + string fieldname = argv[verbose+3]; - string filename = argv[verbose+1]; - string meshname = argv[verbose+2]; - string fieldname = argv[verbose+3]; + /* read MESH, SUPPORT and FIELDS */ + //MESH * myMesh = new MESH(MED_DRIVER,filename,meshname); + + MESH * myMesh; + const SUPPORT * mySupport; + FIELD * myField1; + + try { + + myField1 = new FIELD(MED_DRIVER,filename,fieldname) ; + mySupport = myField1->getSupport(); + myMesh = new MESH(MED_DRIVER,filename,mySupport->getMeshName()); + mySupport->setMesh(myMesh); - /* read MESH, SUPPORT and FIELDS */ - MESH * myMesh = new MESH(MED_DRIVER,filename,meshname); - SUPPORT * mySupport; - FIELD * myField1; - try - { - mySupport = new SUPPORT(myMesh,"Support on all Cells",MED_CELL); - myField1 = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - myField1->setValueType(MED_REEL64); - } - catch (MEDEXCEPTION &ex) - { - // field wasn't found on cells, try on nodes - delete mySupport ; - mySupport = new SUPPORT(myMesh,"On_all_node",MED_NODE); - try - { - myField1 = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - } - catch (...) - { - cout << "Field double " << fieldname << " not found !!!" << endl ; - exit (-1) ; - } - } FIELD * myField2 = new FIELD(* myField1); FIELD myFieldPlus = *myField1 + *myField2; - if(verbose) - { - // affichage des nprmes,des champs f1, f2, scalarProduct(f1,f2) et f1+f2 - FIELD* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport()); - cout << "Norme L2 calculée en fournissant le volume : " << myField1->normL2(myField1_vol) << endl; - for (int i=1; i<=myField1->getNumberOfComponents(); ++i) - cout << "Norme L2 - comp=" << i << " : " << myField1->normL2(i,myField1_vol) << endl; - cout << "Norme L1 calculée en fournissant le volume : " << myField1->normL1(myField1_vol) << endl; - for (int i=1; i<=myField1->getNumberOfComponents(); ++i) - cout << "Norme L1 - comp=" << i << " : " << myField1->normL1(i,myField1_vol) << endl; - delete myField1_vol; - - affiche_fieldT(myField1, myField1->getSupport()); - cout << endl << string(60,'-') << endl; - affiche_fieldT(myField2, myField2->getSupport()); - cout << endl << string(60,'-') << endl; - - FIELD* myFieldDot = FIELD::scalarProduct(*myField1, *myField2); - affiche_fieldT(myFieldDot, myFieldDot->getSupport()); - delete myFieldDot; - cout << endl << string(60,'-') << endl ; - affiche_fieldT(&myFieldPlus, myFieldPlus.getSupport()); - cout << endl << string(60,'-') << endl << endl ; + if(verbose) { + // affichage des nprmes,des champs f1, f2, scalarProduct(f1,f2) et f1+f2 + FIELD* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport()); + cout << "Norme L2 calculee en fournissant le volume : " << myField1->normL2(myField1_vol) << endl; + for (int i=1; i<=myField1->getNumberOfComponents(); ++i) + cout << "Norme L2 - comp=" << i << " : " << myField1->normL2(i,myField1_vol) << endl; + cout << "Norme L1 calculee en fournissant le volume : " << myField1->normL1(myField1_vol) << endl; + for (int i=1; i<=myField1->getNumberOfComponents(); ++i) + cout << "Norme L1 - comp=" << i << " : " << myField1->normL1(i,myField1_vol) << endl; + delete myField1_vol; + + affiche_fieldT(myField1, myField1->getSupport()); + cout << endl << string(60,'-') << endl; + affiche_fieldT(myField2, myField2->getSupport()); + cout << endl << string(60,'-') << endl; + + FIELD* myFieldDot = FIELD::scalarProduct(*myField1, *myField2); + affiche_fieldT(myFieldDot, myFieldDot->getSupport()); + delete myFieldDot; + cout << endl << string(60,'-') << endl ; + affiche_fieldT(&myFieldPlus, myFieldPlus.getSupport()); + cout << endl << string(60,'-') << endl << endl ; } - // Verifie plusieurs cas de non compatibilité + // Verifie plusieurs cas de non compatibilité // test 1 : Unites non compatibles const string unite=myField1->getMEDComponentUnit(1); myField1->setMEDComponentUnit(1,string("UniteBidon")); ntest++; res=1; try - { + { FIELD myFieldPlus = *myField1 + *myField2; - if(verbose) - { + if(verbose) + { cout << endl << string(60,'-') << endl; - cout<< "Test " << ntest << " : incompatibilité d'unité : " << endl << endl; - } - } + cout<< "Test " << ntest << " : incompatibilité d'unité : " << endl << endl; + } + } catch (MEDEXCEPTION & ex) - { + { res=0; - if(verbose) - cout << ex.what() << endl; + if(verbose) + cout << ex.what() << endl; myField1->setMEDComponentUnit(1,unite); - } + } cout << res << endl; // test 2 : numberOfComponents non compatibles @@ -296,21 +282,21 @@ int main (int argc, char ** argv) myField1->setNumberOfComponents(13); ntest++; res=1; try - { - if(verbose) - { + { + if(verbose) + { cout << endl << string(60,'-') << endl; - cout<< "Test " << ntest << " : incompatibilité nombre de composantes : " << endl << endl; - } + cout<< "Test " << ntest << " : incompatibilité nombre de composantes : " << endl << endl; + } FIELD myFieldPlus = *myField1 + *myField2; - } + } catch (MEDEXCEPTION & ex) - { + { res=0; if(verbose) - cout << endl << ex.what() << endl << endl; + cout << endl << ex.what() << endl << endl; myField1->setNumberOfComponents(numberOfComponents); - } + } cout << res << endl; // test 3 : supports non compatibles @@ -318,18 +304,18 @@ int main (int argc, char ** argv) myField1->setSupport(&mySupport2); ntest++; res=1; try - { + { if(verbose) - cout << endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité des supports" << endl << endl; + cout << endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité des supports" << endl << endl; FIELD myFieldPlus = *myField1 + *myField2; - } + } catch (MEDEXCEPTION & ex) - { + { res=0; if(verbose) - cout << ex.what() << endl << endl << endl; + cout << ex.what() << endl << endl << endl; myField1->setSupport(mySupport); - } + } cout << res << endl; // test 4 : champs de taille nulle @@ -337,42 +323,42 @@ int main (int argc, char ** argv) myField2->setNumberOfComponents(0); ntest++; res=2; try - { + { if(verbose) - cout<< endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité taille nulle" << endl << endl; + cout<< endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité taille nulle" << endl << endl; FIELD myFieldPlus = *myField1 + *myField2; - } + } catch (MEDEXCEPTION & ex) - { + { --res; - if(verbose) - cout << ex.what() << endl << endl ; - } + if(verbose) + cout << ex.what() << endl << endl ; + } try - { + { double mynorm2=myField1->norm2(); - } + } catch (MEDEXCEPTION & ex) - { + { --res; - if(verbose) - cout << ex.what() << endl << endl ; + if(verbose) + cout << ex.what() << endl << endl ; myField1->setNumberOfComponents(numberOfComponents); myField2->setNumberOfComponents(numberOfComponents); - } + } cout << res << endl; - // Apres toutes ces exceptions, des opérations qui marchent! + // Apres toutes ces exceptions, des opérations qui marchent! if(verbose) - { - cout<< endl << string(60,'-') << endl << "Test " << ++ntest << " : Operations arithmétiques" << endl; + { + cout<< endl << string(60,'-') << endl << "Test " << ++ntest << " : Operations arithmétiques" << endl; cout << endl << " f1 : "; affiche_valeur_field(*myField1); cout << endl << " f2 : "; affiche_valeur_field(*myField2); cout << endl << string(140,'-'); - } + } - // Test du résultats de certaines opérations et affichage si verbose + // Test du résultats de certaines opérations et affichage si verbose checkOperation(myFieldPlus, *myField1, *myField2, '+', " f1+f2 ", verbose); FIELD* myFieldadd = FIELD::add(*myField1, *myField2); checkOperation( *myFieldadd, *myField1, *myField2, '+', "add(f1,f2)", verbose); @@ -422,5 +408,11 @@ int main (int argc, char ** argv) delete myField2; delete mySupport ; delete myMesh ; - return 0; + + } + catch ( MEDEXCEPTION & ex) { + cout << ex.what() << endl; + } + + return 0; } diff --git a/src/MEDMEM/test_operation_fieldint.cxx b/src/MEDMEM/test_operation_fieldint.cxx index bd171d60a..9bdb971f6 100644 --- a/src/MEDMEM/test_operation_fieldint.cxx +++ b/src/MEDMEM/test_operation_fieldint.cxx @@ -80,7 +80,7 @@ void affiche_fieldT(FIELD * myField, const SUPPORT * mySupport) int NumberOfComponents = myField->getNumberOfComponents() ; for (int i=1; igetValueI(MED_FULL_INTERLACE,i) ; + const int * value = myField->getRow(i) ; for (int j=0; j * myField, const SUPPORT * mySupport) void affiche_valeur_field(const char * intitule, const int taille, const FIELD& f) { - const int * value=f.getValue(f.getvalue()->getMode()); + const int * value=f.getValue(); std::cout << endl << intitule; for(int i=0;i(mySupport,MED_DRIVER,filename,fieldname) ; - myField1->setValueType(MED_REEL64); } catch (MEDEXCEPTION &ex) { @@ -142,7 +140,6 @@ int main (int argc, char ** argv) try { myField1 = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - myField1->setValueType(MED_INT32); myField1->setValueIJ(10,1,-9); // pour tester les normes max avec une valeur negative } catch (...) @@ -256,7 +253,6 @@ int main (int argc, char ** argv) std::cout << endl << string(60,'-') << endl << " - f1 :" << endl << endl; affiche_fieldT(&myFieldNeg, myFieldNeg.getSupport()); - medModeSwitch mode=myFieldPlus.getvalue()->getMode(); int size=myFieldPlus.getNumberOfValues()*myFieldPlus.getNumberOfComponents(); std::cout << endl << string(60,'-') << endl << "Tests opérations :" << endl << endl; diff --git a/src/MEDMEM_I/MEDMEM_Family_i.cxx b/src/MEDMEM_I/MEDMEM_Family_i.cxx index 3b83b01e4..8a4a95bc1 100644 --- a/src/MEDMEM_I/MEDMEM_Family_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Family_i.cxx @@ -1,22 +1,3 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// //============================================================================= // File : MEDMEM_Family_i.cxx // Project : SALOME @@ -132,7 +113,7 @@ throw (SALOME::SALOME_Exception) { int nbAttribute=_family->getNumberOfAttributes(); myseq->length(nbAttribute); - int * identifiers=_family->getAttributesIdentifiers(); + const int * identifiers=_family->getAttributesIdentifiers(); for (int i=0;igetNumberOfAttributes(); myseq->length(nbAttribute); - int * values=_family->getAttributesValues(); + const int * values=_family->getAttributesValues(); for (int i=0;igetNumberOfAttributes(); myseq->length(nbAttribute); - string * descattribute=_family->getAttributesDescriptions(); + const string * descattribute=_family->getAttributesDescriptions(); for (int i=0;igetNumberOfGroups(); myseq->length(nbGroups); - string * descGroups=_family->getGroupsNames(); + const string * descGroups=_family->getGroupsNames(); for (int i=0;i * const f, bool ownCppPtr): - FIELD_i(f,ownCppPtr) -{ - BEGIN_OF("Constructor FIELDDOUBLE_i"); - END_OF(" Constructor FIELDDOUBLE_i"); -} - -//============================================================================= -/*! - * CORBA: Accessor for Field's values -*/ -//============================================================================= - -SALOME_MED::double_array* FIELDDOUBLE_i::getValue( SALOME_MED::medModeSwitch mode ) -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::double_array_var myseq = new SALOME_MED::double_array; - try - { - medModeSwitch modemed=convertIdlModeToMedMode(mode); -// ::FIELD *ptrD=dynamic_cast< ::FIELD* >(_fieldTptr); -// the alternative is not safe but the dynamic_cast fails using the python API - MEDMEM::FIELD *ptrD = static_cast* >(_fieldTptr); - const double * values =ptrD->getValue(modemed); - int nbval=ptrD->getValueLength(modemed); - myseq->length(nbval); - for (int i=0; i *ptrD=dynamic_cast< ::FIELD* >(_fieldTptr); - // the alternative is not safe but the dynamic_cast fails using the python API - MEDMEM::FIELD *ptrD=static_cast< MEDMEM::FIELD* >(_fieldTptr); - const double * values =ptrD->getValue(modemed); - int nbval=ptrD->getValueLength(modemed); - ret=SenderFactory::buildSender(*this,values,nbval); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces Field "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return ret; -} diff --git a/src/MEDMEM_I/MEDMEM_FieldDouble_i.hxx b/src/MEDMEM_I/MEDMEM_FieldDouble_i.hxx deleted file mode 100644 index da3e16885..000000000 --- a/src/MEDMEM_I/MEDMEM_FieldDouble_i.hxx +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// -//============================================================================= -// File : MEDMEM_Fielddouble_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Fielddouble_i.hxx -//============================================================================= - -#ifndef MED_FIELDDOUBLE_I_HXX_ -#define MED_FIELDDOUBLE_I_HXX_ - -#include - -#include CORBA_SERVER_HEADER(MED) - -#include "MEDMEM_Field_i.hxx" - -#include "MEDMEM_Field.hxx" - -namespace MEDMEM { - class FIELDDOUBLE_i: public POA_SALOME_MED::FIELDDOUBLE, - public FIELD_i, - public SALOMEMultiComm -{ -private: - -public: - FIELDDOUBLE_i(); - ~FIELDDOUBLE_i(); - FIELDDOUBLE_i(MEDMEM::FIELD * const f, bool ownCppPtr=false); - FIELDDOUBLE_i(FIELDDOUBLE_i & f); - - SALOME_MED::double_array * getValue (SALOME_MED::medModeSwitch mode ) - throw (SALOME::SALOME_Exception); - SALOME::SenderDouble_ptr getSenderForValue(SALOME_MED::medModeSwitch mode) - throw (SALOME::SALOME_Exception); -}; -} - - -#endif /* MED_FIELDDOUBLE_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_FieldInt_i.cxx b/src/MEDMEM_I/MEDMEM_FieldInt_i.cxx deleted file mode 100644 index 385b33d86..000000000 --- a/src/MEDMEM_I/MEDMEM_FieldInt_i.cxx +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// -//============================================================================= -// File : MEDMEM_Fieldint_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Fieldint_i.hxx -//============================================================================= - -#include "utilities.h" -#include "MEDMEM_FieldInt_i.hxx" -#include "MEDMEM_convert.hxx" -#include "SenderFactory.hxx" -#include "MultiCommException.hxx" -using namespace MEDMEM; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -FIELDINT_i::FIELDINT_i(): FIELD_i() -{ - BEGIN_OF("Default Constructor FIELDINT_i"); - END_OF("Default Constructor FIELDINT_i"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -FIELDINT_i::~FIELDINT_i() -{ - BEGIN_OF("Default Destructor FIELDINT_i"); - END_OF("Default Destructor FIELDINT_i"); -} -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -FIELDINT_i::FIELDINT_i(::FIELD * const f, bool ownCppPtr): - FIELD_i(f,ownCppPtr) -{ - BEGIN_OF("Constructor FIELDINT_i"); - END_OF(" Constructor FIELDINT_i"); -} -//============================================================================= -/*! - * Constructor par recopie - */ -//============================================================================= -FIELDINT_i::FIELDINT_i(FIELDINT_i &fi):FIELD_i(fi) -{ - BEGIN_OF("Constructor FIELDINT_i"); - END_OF(" Constructor FIELDINT_i"); -} - -//============================================================================= -/*! - * CORBA: Accessor for Field's values -*/ -//============================================================================= - -SALOME_MED::long_array* FIELDINT_i::getValue( SALOME_MED::medModeSwitch mode ) -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::long_array_var myseq = new SALOME_MED::long_array; - try - { - medModeSwitch modemed=convertIdlModeToMedMode(mode); - // ::FIELD *ptrI=dynamic_cast< ::FIELD* >(_fieldTptr); - //the alternative is not safe but the previous one fails using the python API - MEDMEM::FIELD *ptrI = static_cast< MEDMEM::FIELD* >(_fieldTptr); - - const int * values =ptrI->getValue(modemed); - int nbval=ptrI->getValueLength(modemed); - myseq->length(nbval); - for (int i=0; i *ptrI=dynamic_cast< ::FIELD* >(_fieldTptr); - //the alternative is not safe but the previous one fails using the python API - MEDMEM::FIELD *ptrI=static_cast< MEDMEM::FIELD* >(_fieldTptr); - const int * values =ptrI->getValue(modemed); - int nbval=ptrI->getValueLength(modemed); - ret=SenderFactory::buildSender(*this,values,nbval); - } - catch(MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces Field"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return ret; -} diff --git a/src/MEDMEM_I/MEDMEM_FieldInt_i.hxx b/src/MEDMEM_I/MEDMEM_FieldInt_i.hxx deleted file mode 100644 index ae0c59878..000000000 --- a/src/MEDMEM_I/MEDMEM_FieldInt_i.hxx +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// -//============================================================================= -// File : MEDMEM_FieldInt_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_FieldInt_i.hxx -//============================================================================= - -#ifndef MED_FIELDINT_I_HXX_ -#define MED_FIELDINT_I_HXX_ - -#include - -#include CORBA_SERVER_HEADER(MED) - -#include "MEDMEM_Field_i.hxx" - -#include "MEDMEM_Field.hxx" - -namespace MEDMEM { - class FIELDINT_i: public POA_SALOME_MED::FIELDINT, - public FIELD_i, - public SALOMEMultiComm -{ -private: - FIELDINT_i(); - -public: - ~FIELDINT_i(); - FIELDINT_i(MEDMEM::FIELD * const f, bool ownCppPtr=false); - FIELDINT_i(FIELDINT_i & f); - SALOME_MED::long_array * getValue (SALOME_MED::medModeSwitch mode ) - throw (SALOME::SALOME_Exception); - SALOME::SenderInt_ptr getSenderForValue(SALOME_MED::medModeSwitch mode) - throw (SALOME::SALOME_Exception); -}; -} -#endif /* MED_FIELDINT_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_FieldTemplate_i.hxx b/src/MEDMEM_I/MEDMEM_FieldTemplate_i.hxx new file mode 100644 index 000000000..4bc262943 --- /dev/null +++ b/src/MEDMEM_I/MEDMEM_FieldTemplate_i.hxx @@ -0,0 +1,192 @@ +#ifndef __MED_FIELDTEMPLATE_I_HXX__ +#define __MED_FIELDTEMPLATE_I_HXX__ + +#include +#include CORBA_SERVER_HEADER(MED) +#include "MEDMEM_Field_i.hxx" +#include "MEDMEM_Field.hxx" +#include "SenderFactory.hxx" +#include "MultiCommException.hxx" +#include "MEDMEM_ArrayConvert.hxx" +#include "MEDMEM_TraitsForFields.hxx" + +namespace MEDMEM +{ + template < class T, class INTERLACING_TAG > + class FIELDTEMPLATE_I : public FIELDI_TRAITS::InterfaceForServant, + public FIELD_i, + public SALOMEMultiComm + { + public: + FIELDTEMPLATE_I(); + ~FIELDTEMPLATE_I(); + FIELDTEMPLATE_I(MEDMEM::FIELD *f, bool ownCppPtr=false); + FIELDTEMPLATE_I(FIELDTEMPLATE_I & f); + typename FIELDI_TRAITS::SeqType* getValue (SALOME_MED::medModeSwitch mode ) + throw (SALOME::SALOME_Exception); + typename FIELDI_TRAITS::SenderPtrType getSenderForValue(SALOME_MED::medModeSwitch mode) + throw (SALOME::SALOME_Exception); + }; + + //============================================================================= + /*! + * Default constructor + */ + //============================================================================= + template < class T, class INTERLACING_TAG > + FIELDTEMPLATE_I::FIELDTEMPLATE_I(): FIELD_i() + { + BEGIN_OF("Default Constructor FIELDTEMPLATE_I"); + END_OF("Default Constructor FIELDTEMPLATE_I"); + } + //============================================================================= + /*! + * Destructor + */ + //============================================================================= + template < class T, class INTERLACING_TAG > + FIELDTEMPLATE_I::~FIELDTEMPLATE_I() + { + BEGIN_OF("Default Destructor FIELDTEMPLATE_I"); + END_OF("Default Destructor FIELDTEMPLATE_I"); + } + //============================================================================= + /*! + * Constructor par recopie + */ + //============================================================================= + template < class T, class INTERLACING_TAG > + FIELDTEMPLATE_I::FIELDTEMPLATE_I(FIELDTEMPLATE_I& fd): + FIELD_i(fd) + { + BEGIN_OF("Default Constructor FIELDTEMPLATE_I"); + END_OF("Default Constructor FIELDTEMPLATE_I"); + } + //============================================================================= + /*! + * Default constructor + */ + //============================================================================= + template < class T, class INTERLACING_TAG > + FIELDTEMPLATE_I::FIELDTEMPLATE_I(MEDMEM::FIELD *f, bool ownCppPtr):FIELD_i(f,ownCppPtr) + { + BEGIN_OF("Constructor FIELDTEMPLATE_I"); + END_OF(" Constructor FIELDTEMPLATE_I"); + } + + //============================================================================= + /*! + * CORBA: Accessor for Field's values + */ + //============================================================================= + template < class T, class INTERLACING_TAG > + typename FIELDI_TRAITS::SeqType *FIELDTEMPLATE_I::getValue( SALOME_MED::medModeSwitch mode ) + throw (SALOME::SALOME_Exception) + { + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + typename FIELDI_TRAITS::SeqVarType myseq = new typename FIELDI_TRAITS::SeqType; + try + { + medModeSwitch modemed=convertIdlModeToMedMode(mode); + // ::FIELD *ptrD=dynamic_cast< ::FIELD* >(_fieldTptr); + // the alternative is not safe but the dynamic_cast fails using the python API + MEDMEM::FIELD *ptrD = static_cast* >(_fieldTptr); + int nbval=ptrD->getValueLength(); + if(ptrD->getInterlacingType()==modemed) + { + const T* values =ptrD->getValue(); + myseq->length(nbval); + for (int i=0; igetGaussPresence() ) + { + typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayGauss(); + int size=myArray->getArraySize(); + values=new T[size]; + delete ArrayConvert(*myArray,values); + } + else + { + typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayNoGauss(); + int size=myArray->getArraySize(); + values=new T[size]; + delete ArrayConvert(*myArray,values); + } + for (int i=0; i + typename FIELDI_TRAITS::SenderPtrType FIELDTEMPLATE_I::getSenderForValue( SALOME_MED::medModeSwitch mode ) + throw (SALOME::SALOME_Exception) + { + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + typename FIELDI_TRAITS::SenderPtrType ret; + try + { + medModeSwitch modemed=convertIdlModeToMedMode(mode); + // ::FIELD *ptrD=dynamic_cast< ::FIELD* >(_fieldTptr); + // the alternative is not safe but the dynamic_cast fails using the python API + MEDMEM::FIELD *ptrD=static_cast< MEDMEM::FIELD* >(_fieldTptr); + int nbval=ptrD->getValueLength(); + if(ptrD->getInterlacingType()==modemed) + { + const T* values =ptrD->getValue(); + ret=SenderFactory::buildSender(*this,values,nbval); + } + else + { + T *values; + if ( ptrD->getGaussPresence() ) + { + typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayGauss(); + int size=myArray->getArraySize(); + values=new T[size]; + delete ArrayConvert(*myArray,values); + + } + else + { + typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayNoGauss(); + int size=myArray->getArraySize(); + values=new T[size]; + delete ArrayConvert(*myArray,values); + } + ret=SenderFactory::buildSender(*this,values,nbval); + } + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Unable to acces Field "); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } + return ret; + } + +} + +#endif diff --git a/src/MEDMEM_I/MEDMEM_Field_i.cxx b/src/MEDMEM_I/MEDMEM_Field_i.cxx index 1a20624e3..81045022c 100644 --- a/src/MEDMEM_I/MEDMEM_Field_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Field_i.cxx @@ -1,22 +1,3 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// //============================================================================= // File : MEDMEM_Field_i.cxx // Created : mer fév 20 15:47:57 CET 2002 @@ -305,6 +286,26 @@ throw (SALOME::SALOME_Exception) } } //============================================================================= +/*! + * CORBA: Accessor for gauss numbers presence. + */ +//============================================================================= +CORBA::Boolean FIELD_i::getGaussPresence() +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return _fieldTptr->getGaussPresence(); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= /*! * CORBA: Accessor */ @@ -528,14 +529,21 @@ void FIELD_i::addInStudy(SALOMEDS::Study_ptr myStudy, MESSAGE("Computing path to Support"); - string supportEntryPath = SUPPORT_i::getEntryPath( meshNameStudy, - _fieldTptr->getSupport() ); + char * supportEntryPath; + lenName = 28 + 15 + strlen(meshName.c_str()) + 1 + + strlen(supportName.c_str()) + 1; + supportEntryPath = new char[lenName]; + supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/MEDSUPPORTS_OF_"); + supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str()); + supportEntryPath = strcat(supportEntryPath,"/"); + supportEntryPath = strcat(supportEntryPath,supportName.c_str()); + SCRUTE(supportEntryPath); - MESSAGE("supportEntryPath in field " << supportEntryPath /*<< " length " << lenName*/); + MESSAGE("supportEntryPath in field " << supportEntryPath << " length " << lenName); // SALOMEDS::SObject_var supportObject = myStudy->FindObject(supportName.c_str()); - SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath.c_str()); + SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath); SCRUTE(supportObject); @@ -554,7 +562,7 @@ void FIELD_i::addInStudy(SALOMEDS::Study_ptr myStudy, myBuilder->CommitCommand(); - //delete [] supportEntryPath; + delete [] supportEntryPath; delete [] fieldEntryName; // register the Corba pointer: increase the referrence count diff --git a/src/MEDMEM_I/MEDMEM_Field_i.hxx b/src/MEDMEM_I/MEDMEM_Field_i.hxx index c6ed3760b..b2ebbbda3 100644 --- a/src/MEDMEM_I/MEDMEM_Field_i.hxx +++ b/src/MEDMEM_I/MEDMEM_Field_i.hxx @@ -1,22 +1,3 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// //============================================================================= // File : MEDMEM_Field_i.hxx // Project : SALOME @@ -86,6 +67,7 @@ public : CORBA::Long getIterationNumber() throw (SALOME::SALOME_Exception); CORBA::Long getOrderNumber() throw (SALOME::SALOME_Exception); + CORBA::Boolean getGaussPresence(); CORBA::Double getTime() throw (SALOME::SALOME_Exception); CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception); diff --git a/src/MEDMEM_I/MEDMEM_Med_i.cxx b/src/MEDMEM_I/MEDMEM_Med_i.cxx index 2362ecac9..336d8a092 100644 --- a/src/MEDMEM_I/MEDMEM_Med_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Med_i.cxx @@ -1,22 +1,3 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// //============================================================================= // File : MEDMEM_Med_i.cxx // Project : SALOME @@ -31,14 +12,11 @@ #include "MEDMEM_Med_i.hxx" #include "MEDMEM_Mesh_i.hxx" -#include "MEDMEM_FieldDouble_i.hxx" -#include "MEDMEM_FieldInt_i.hxx" +#include "MEDMEM_FieldTemplate_i.hxx" #include "MEDMEM_Support_i.hxx" #include "MEDMEM_Family_i.hxx" #include "MEDMEM_Group_i.hxx" #include "MEDMEM_convert.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" #include "MEDMEM_DriversDef.hxx" #include "utilities.h" @@ -55,7 +33,6 @@ using namespace MEDMEM; MED_i::MED_i():_med((::MED*)NULL) { BEGIN_OF("Default Constructor MED_i"); - _med = new ::MED(); END_OF("Default Constructor MED_i"); } //============================================================================= @@ -69,9 +46,7 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin BEGIN_OF(LOC); // we create all IOR from _med - if ( _med ) - delete _med; - _med = new ::MED(driverType,fileName); + _med = new ::MED(driverType,fileName); // MESHES : deque meshesNames = _med->getMeshNames(); @@ -185,7 +160,7 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin case MED_EN::MED_INT32 : { ((FIELD*)myField)->read(); - FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); + FIELDTEMPLATE_I *myFieldIntI = new FIELDTEMPLATE_I((FIELD*)myField); myFieldIOR = myFieldIntI->_this(); // myFieldIntI->addInStudy(myStudy,myFieldIOR); break; @@ -194,7 +169,7 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin case MED_EN::MED_REEL64: { ((FIELD*)myField)->read(); - FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); + FIELDTEMPLATE_I *myFieldDoubleI = new FIELDTEMPLATE_I((FIELD*)myField); myFieldIOR = myFieldDoubleI->_this(); // myFieldDoubleI->addInStudy(myStudy,myFieldIOR); break; @@ -234,9 +209,7 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType SCRUTE(driverType); SCRUTE(fileName) - if ( _med ) - delete _med; - _med = new ::MED(driverType,fileName); + _med = new ::MED(driverType,fileName); int numberOfMeshes = _med->getNumberOfMeshes(); SCRUTE(numberOfMeshes); @@ -510,7 +483,7 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType case MED_EN::MED_INT32: { ((FIELD*)myField)->read(); - FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); + FIELDTEMPLATE_I *myFieldIntI = new FIELDTEMPLATE_I((FIELD*)myField); SALOME_MED::FIELDINT_ptr myFieldIntIOR; myFieldIntIOR = myFieldIntI->_this(); @@ -524,7 +497,7 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType case MED_EN::MED_REEL64: { ((FIELD*)myField)->read(); - FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); + FIELDTEMPLATE_I *myFieldDoubleI = new FIELDTEMPLATE_I((FIELD*)myField); SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR; myFieldDoubleIOR = myFieldDoubleI->_this(); @@ -691,87 +664,7 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType //============================================================================= MED_i::~MED_i() { - //delete _med; } - -//======================================================================= -//function : updateSupportIORs -//purpose : -//======================================================================= - -void MED_i::updateSupportIORs(SALOMEDS::Study_ptr myStudy, const char* meshName) -{ - vector familyVector; - vector::iterator familyVectorIt; - vector groupVector; - vector::iterator groupVectorIt; - string supportEntryPath; - - ::MESH * ptrMesh = _med->getMesh(meshName); - - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - - for (currentEntity = MED_EN::meshEntities.begin(); - currentEntity != MED_EN::meshEntities.end(); - currentEntity++) - { - // family : - familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first); - int nb = familyVector.size(); - for (familyVectorIt = familyVector.begin(); - familyVectorIt != familyVector.end(); - familyVectorIt++) - { - supportEntryPath = SUPPORT_i::getEntryPath( meshName, *familyVectorIt ); - SALOMEDS::SObject_var familyEntry = myStudy->FindObjectByPath(supportEntryPath.c_str()); - if ( !familyEntry->_is_nil() || CORBA::is_nil( familyEntry->GetObject() )) - { - FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt); - SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this(); - myFamilyI->addInStudy(myStudy,myFamilyIOR); - } - } - - // group : - groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first); - nb = groupVector.size(); - for (groupVectorIt = groupVector.begin(); - groupVectorIt != groupVector.end(); - groupVectorIt++) - { - supportEntryPath = SUPPORT_i::getEntryPath( meshName, *groupVectorIt ); - SALOMEDS::SObject_var groupEntry = myStudy->FindObjectByPath(supportEntryPath.c_str()); - if ( !groupEntry->_is_nil() || CORBA::is_nil( groupEntry->GetObject() )) - { - GROUP_i * myGroupI = new GROUP_i(*groupVectorIt); - SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this(); - myGroupI->addInStudy(myStudy,myGroupIOR); - } - } - } - - _med->updateSupport(); - - // supports - map mySupports = _med->getSupports(meshName); - map::const_iterator itSupport; - map & - mySupportsIOR = _supports[meshName]; - for (itSupport=mySupports.begin(); itSupport!=mySupports.end(); itSupport++ ) - { - supportEntryPath = SUPPORT_i::getEntryPath( meshName, itSupport->second); - SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str()); - if ( !supportEntry->_is_nil() || CORBA::is_nil( supportEntry->GetObject() )) - { - SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second); - SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this(); - mySupportsIOR[(*itSupport).first]= mySupportIOR; - mySupportI->addInStudy(myStudy,mySupportIOR); - } - } -} - - //============================================================================= /*! * CORBA: Accessor for Number of meshes @@ -887,27 +780,18 @@ throw (SALOME::SALOME_Exception) if (_med==NULL) THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\ SALOME::INTERNAL_ERROR); - SALOME_MED::MESH_ptr meshIOR; try { - map::const_iterator name_meshIOR = - _meshes.find( meshName ); - if ( name_meshIOR == _meshes.end() ) { MESH * mesh=_med->getMesh(meshName); MESH_i * m1 = new MESH_i(mesh); - meshIOR = m1->POA_SALOME_MED::MESH::_this(); - _meshes[ meshName ] = meshIOR; - } - else { - meshIOR = name_meshIOR->second; - } + return m1->POA_SALOME_MED::MESH::_this(); } catch (MEDEXCEPTION &ex) { MESSAGE("Unable to get the specified mesh"); THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); } - return meshIOR; + } //============================================================================= /*! @@ -935,7 +819,7 @@ throw (SALOME::SALOME_Exception) ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); ::FIELD * fdouble = (::FIELD *)FIELD_i::fieldMap[ind]; - mesh=_med->getMesh(fdouble); + MESH * mesh=_med->getMesh(fdouble); } else { @@ -943,7 +827,7 @@ throw (SALOME::SALOME_Exception) ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); ::FIELD * fint = (::FIELD *)FIELD_i::fieldMap[ind]; - mesh=_med->getMesh(fint); + MESH * mesh=_med->getMesh(fint); } MESH_i * meshi = new MESH_i(mesh); return meshi->POA_SALOME_MED::MESH::_this(); @@ -1056,11 +940,6 @@ throw (SALOME::SALOME_Exception) { const char * LOC="MED_i::getField(const char*,CORBA::Long,CORBA::Long) "; BEGIN_OF(LOC); - if (_med==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Med object",\ - SALOME::INTERNAL_ERROR); - - SALOME_MED::FIELD_ptr myFieldIOR = SALOME_MED::FIELD::_nil(); DT_IT_ dtIt; @@ -1068,47 +947,19 @@ throw (SALOME::SALOME_Exception) dtIt.it= (int)numOrdre; map::const_iterator itFields = _fields.find(fieldName); - if ( itFields != _fields.end() ) - { - const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second; - MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt); - if ( itMap_dtIt != map_dtIt.end() ) - myFieldIOR = (*itMap_dtIt).second; - } - if ( CORBA::is_nil( myFieldIOR )) - { - try - { - ::FIELD_* myField = _med->getField( fieldName, pasTemps, numOrdre); - - switch ( myField->getValueType() ) { - case MED_EN::MED_INT32 : { - FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); - myFieldIOR = myFieldIntI->_this(); - break; - } - - case MED_EN::MED_REEL64: { - FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); - myFieldIOR = myFieldDoubleI->_this(); - break; - } - default: - THROW_SALOME_CORBA_EXCEPTION ("Wrong field type", SALOME::INTERNAL_ERROR); - } - } - catch (const std::exception & ex) - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR); - } - _fields[fieldName][dtIt] = myFieldIOR; - } + if ( itFields == _fields.end() ) + THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR); + + const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second; + MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt); + + if ( itMap_dtIt == map_dtIt.end() ) + THROW_SALOME_CORBA_EXCEPTION("Iteration not found !", SALOME::INTERNAL_ERROR); + + END_OF(LOC); + return (*itMap_dtIt).second; - END_OF(LOC); - return myFieldIOR; } //============================================================================= /*! diff --git a/src/MEDMEM_I/MEDMEM_Mesh_i.cxx b/src/MEDMEM_I/MEDMEM_Mesh_i.cxx index 6d1c7b006..96581ec89 100644 --- a/src/MEDMEM_I/MEDMEM_Mesh_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Mesh_i.cxx @@ -1,22 +1,3 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// //============================================================================= // File : MEDMEM_Mesh_i.cxx // Project : SALOME @@ -37,7 +18,7 @@ #include "MEDMEM_Support_i.hxx" #include "MEDMEM_Family_i.hxx" #include "MEDMEM_Group_i.hxx" -#include "MEDMEM_FieldDouble_i.hxx" +#include "MEDMEM_FieldTemplate_i.hxx" #include "MEDMEM_Mesh.hxx" #include "MEDMEM_Family.hxx" @@ -1308,7 +1289,7 @@ throw (SALOME::SALOME_Exception) ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; ::FIELD*f=_mesh->getVolume( myCppSupport); - FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); return medf->_this(); } catch (MEDEXCEPTION &ex) @@ -1360,7 +1341,7 @@ throw (SALOME::SALOME_Exception) ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; ::FIELD*f=_mesh->getArea( myCppSupport); - FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); return medf->_this(); } catch (MEDEXCEPTION &ex) @@ -1386,7 +1367,7 @@ throw (SALOME::SALOME_Exception) ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; ::FIELD*f=_mesh->getLength( myCppSupport); - FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); return medf->_this(); } catch (MEDEXCEPTION &ex) @@ -1412,7 +1393,7 @@ throw (SALOME::SALOME_Exception) ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; ::FIELD*f=_mesh->getNormal( myCppSupport); - FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); return medf->_this(); } catch (MEDEXCEPTION &ex) @@ -1438,7 +1419,7 @@ throw (SALOME::SALOME_Exception) ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; ::FIELD*f=_mesh->getBarycenter( myCppSupport); - FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); return medf->_this(); } catch (MEDEXCEPTION &ex) diff --git a/src/MEDMEM_I/MEDMEM_Support_i.cxx b/src/MEDMEM_I/MEDMEM_Support_i.cxx index e43410267..121c6b253 100644 --- a/src/MEDMEM_I/MEDMEM_Support_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Support_i.cxx @@ -1,22 +1,3 @@ -// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// 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/ -// //============================================================================= // File : MEDMEM_Support_i.cxx // Project : SALOME @@ -36,7 +17,6 @@ #include "MEDMEM_define.hxx" #include "MEDMEM_Support.hxx" -#include "MEDMEM_Mesh.hxx" #include "MEDMEM_Support_i.hxx" #include "MEDMEM_Mesh_i.hxx" @@ -177,7 +157,7 @@ throw (SALOME::SALOME_Exception) const int numberOfTypes = _support->getNumberOfTypes(); all->numberOfGeometricType = numberOfTypes; all->entity = _support->getEntity(); - + all->isOnAllElements = _support->isOnAllElements(); all->types.length(numberOfTypes); all->nbEltTypes.length(numberOfTypes); const medGeometryElement * elemts = _support->getTypes(); @@ -453,7 +433,7 @@ throw (SALOME::SALOME_Exception) SALOME_MED::long_array_var myseq= new SALOME_MED::long_array; try { - MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS"); + MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS"); int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS); myseq->length(nbelements); const int * numbers=_support->getNumberIndex(); @@ -485,7 +465,7 @@ SALOME::SenderInt_ptr SUPPORT_i::getSenderForNumberIndex() SALOME::SenderInt_ptr ret; try { - MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS"); + MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS"); int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS); const int * numbers=_support->getNumberIndex(); ret=SenderFactory::buildSender(*this,numbers,nbelements); @@ -624,7 +604,7 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr } MESSAGE(LOC << " Find SObject MESH (represent mesh in support)"); - string meshName = _support->getMesh()->getName() ; + string meshName = getMesh()->getName() ; string meshNameStudy = meshName; for (string::size_type pos=0; posNewCommand(); - string supportEntryPath = getEntryPath( meshName, _support ); + string supportName = _support->getName(); + + SCRUTE(supportName); + + SCRUTE(meshNameStudy); + + char * supportEntryPath; + lenName = 13 + 15 + strlen(meshName.c_str()) + 1 + strlen(supportName.c_str())+1; + supportEntryPath = new char[lenName]; + supportEntryPath = strcpy(supportEntryPath,"/Med/MEDMESH/"); + supportEntryPath = strcat(supportEntryPath,"MEDSUPPORTS_OF_"); + supportEntryPath = strcat(supportEntryPath,meshNameStudy.c_str()); + supportEntryPath = strcat(supportEntryPath,"/"); + supportEntryPath = strcat(supportEntryPath,supportName.c_str()); + //SCRUTE(supportEntryPath); - MESSAGE("supportEntryPath in support " << supportEntryPath/* << " length " << lenName*/); + MESSAGE("supportEntryPath in support " << supportEntryPath << " length " << lenName); - SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str()); +// SALOMEDS::SObject_var supportEntry = myStudy->FindObject(_support->getName().c_str()); + // c'est pas bon, car il faut rechercher uniquement sous le bon MESH !!! + SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath); if ( CORBA::is_nil(supportEntry) ) { @@ -698,7 +694,7 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr } myBuilder->CommitCommand(); - SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath.c_str()); + SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath); MESSAGE("Just for checking, reuse of the corba pointer"); @@ -712,6 +708,7 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr } delete [] medsupfatherName; + delete [] supportEntryPath; // register the Corba pointer: increase the referrence count MESSAGE("Registering of the Corba Support pointer"); @@ -719,23 +716,3 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr END_OF(LOC); } - -//======================================================================= -//function : getEntryPath -//purpose : -//======================================================================= - -string SUPPORT_i::getEntryPath(const string& aMeshName, const ::MEDMEM::SUPPORT * aSupport) -{ - string meshNameStudy( aMeshName.c_str(), strlen( aMeshName.c_str() )); - for (string::size_type pos=0; posgetName(); - string supportNameStudy( supportName.c_str(), strlen( supportName.c_str() )); - string supportEntryPath = - "/Med/MEDMESH/MEDSUPPORTS_OF_" + meshNameStudy + "/" + supportNameStudy; - SCRUTE( supportEntryPath ); - - return supportEntryPath; -} diff --git a/src/MEDMEM_I/MEDMEM_TraitsForFields.hxx b/src/MEDMEM_I/MEDMEM_TraitsForFields.hxx new file mode 100644 index 000000000..8dbb9df95 --- /dev/null +++ b/src/MEDMEM_I/MEDMEM_TraitsForFields.hxx @@ -0,0 +1,76 @@ +#ifndef __MEDMEM_TRAITSFORFIELDS_HXX__ +#define __MEDMEM_TRAITSFORFIELDS_HXX__ + +#include CORBA_SERVER_HEADER(MED) +#include "MEDMEM_Tags.hxx" +#include "MEDMEM_InterlacingPolicy.hxx" + +namespace MEDMEM +{ +template < typename T, typename INTERLACING_TAG > +struct FIELDI_TRAITS +{ + typedef typename T::InterfaceForServant InterfaceForServant; + typedef typename T::FieldCorbaPtrType FieldCorbaPtrType; + typedef typename T::SimpleFieldCorbaPtrType SimpleFieldCorbaPtrType; + typedef typename T::SimpleFieldGlobalType SimpleFieldGlobalType; + typedef typename T::SeqType SeqType; + typedef typename T::SeqVarType SeqVarType; + typedef typename T::SenderPtrType SenderPtrType; + typedef typename T::SenderVarType SenderVarType; +}; + +template < > +struct FIELDI_TRAITS +{ + typedef POA_SALOME_MED::FIELDDOUBLEFULL InterfaceForServant; + typedef SALOME_MED::FIELDDOUBLEFULL_ptr FieldCorbaPtrType; + typedef SALOME_MED::FIELDDOUBLE_ptr SimpleFieldCorbaPtrType; + typedef SALOME_MED::FIELDDOUBLE SimpleFieldGlobalType; + typedef SALOME_MED::double_array SeqType; + typedef SALOME_MED::double_array_var SeqVarType; + typedef SALOME::SenderDouble_ptr SenderPtrType; + typedef SALOME::SenderDouble_var SenderVarType; +}; + +template < > +struct FIELDI_TRAITS +{ + typedef POA_SALOME_MED::FIELDDOUBLENO InterfaceForServant; + typedef SALOME_MED::FIELDDOUBLENO_ptr FieldCorbaPtrType; + typedef SALOME_MED::FIELDDOUBLE_ptr SimpleFieldCorbaPtrType; + typedef SALOME_MED::FIELDDOUBLE SimpleFieldGlobalType; + typedef SALOME_MED::double_array SeqType; + typedef SALOME_MED::double_array_var SeqVarType; + typedef SALOME::SenderDouble_ptr SenderPtrType; + typedef SALOME::SenderDouble_var SenderVarType; +}; + +template < > +struct FIELDI_TRAITS +{ + typedef POA_SALOME_MED::FIELDINTFULL InterfaceForServant; + typedef SALOME_MED::FIELDINTFULL_ptr FieldCorbaPtrType; + typedef SALOME_MED::FIELDINT_ptr SimpleFieldCorbaPtrType; + typedef SALOME_MED::FIELDINT SimpleFieldGlobalType; + typedef SALOME_MED::long_array SeqType; + typedef SALOME_MED::long_array_var SeqVarType; + typedef SALOME::SenderInt_ptr SenderPtrType; + typedef SALOME::SenderInt_var SenderVarType; +}; + +template < > +struct FIELDI_TRAITS +{ + typedef POA_SALOME_MED::FIELDINTNO InterfaceForServant; + typedef SALOME_MED::FIELDINTNO_ptr FieldCorbaPtrType; + typedef SALOME_MED::FIELDINT_ptr SimpleFieldCorbaPtrType; + typedef SALOME_MED::FIELDINT SimpleFieldGlobalType; + typedef SALOME_MED::long_array SeqType; + typedef SALOME_MED::long_array_var SeqVarType; + typedef SALOME::SenderInt_ptr SenderPtrType; + typedef SALOME::SenderInt_var SenderVarType; +}; +} + +#endif diff --git a/src/MEDMEM_I/Makefile.in b/src/MEDMEM_I/Makefile.in index d29750e49..3634a9e47 100644 --- a/src/MEDMEM_I/Makefile.in +++ b/src/MEDMEM_I/Makefile.in @@ -42,8 +42,8 @@ EXPORT_HEADERS = \ MEDMEM_convert.hxx \ MEDMEM_Med_i.hxx \ MEDMEM_Family_i.hxx \ - MEDMEM_FieldDouble_i.hxx \ - MEDMEM_FieldInt_i.hxx \ + MEDMEM_FieldTemplate_i.hxx \ + MEDMEM_TraitsForFields.hxx \ MEDMEM_Field_i.hxx \ MEDMEM_Group_i.hxx \ MEDMEM_Mesh_i.hxx \ @@ -52,7 +52,7 @@ EXPORT_HEADERS = \ # Libraries targets LIB=libMEDMEMImpl.la -LIB_SRC = MEDMEM_Med_i.cxx MEDMEM_Family_i.cxx MEDMEM_FieldDouble_i.cxx MEDMEM_FieldInt_i.cxx MEDMEM_Field_i.cxx MEDMEM_Group_i.cxx MEDMEM_Mesh_i.cxx MEDMEM_Support_i.cxx MEDMEM_convert.cxx +LIB_SRC = MEDMEM_Med_i.cxx MEDMEM_Family_i.cxx MEDMEM_Field_i.cxx MEDMEM_Group_i.cxx MEDMEM_Mesh_i.cxx MEDMEM_Support_i.cxx MEDMEM_convert.cxx LIB_SERVER_IDL = MED.idl LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl SALOME_GenericObj.idl diff --git a/src/MEDMEM_SWIG/Makefile.in b/src/MEDMEM_SWIG/Makefile.in index a2459bf79..9034c4d33 100644 --- a/src/MEDMEM_SWIG/Makefile.in +++ b/src/MEDMEM_SWIG/Makefile.in @@ -35,7 +35,7 @@ VPATH=.:$(srcdir) EXPORT_HEADERS = \ libMEDMEM_Swig.i \ my_typemap.i \ - MEDMEM_SWIG_Templates.hxx + MEDMEM_SWIG_Templates.hxx # MEDMEM_SWIG_MedFieldDoubleDriver.hxx \ # MEDMEM_SWIG_MedFieldIntDriver.hxx \ # MEDMEM_SWIG_AsciiFieldDoubleDriver.hxx \ @@ -81,6 +81,7 @@ EXPORT_PYSCRIPTS = libMEDMEM_Swig.py \ med_opsupp_test.py \ test_gibi.py \ test_porflow.py \ + testDriverAscii.py \ testMedMemGeneral.py ############################################################################# diff --git a/src/MEDMEM_SWIG/libMEDMEM_Swig.i b/src/MEDMEM_SWIG/libMEDMEM_Swig.i index 568fc5050..a55f04363 100644 --- a/src/MEDMEM_SWIG/libMEDMEM_Swig.i +++ b/src/MEDMEM_SWIG/libMEDMEM_Swig.i @@ -43,6 +43,7 @@ #include "MEDMEM_Med.hxx" #include "MEDMEM_Unit.hxx" #include "MEDMEM_Field.hxx" +#include "MEDMEM_FieldConvert.hxx" #include "MEDMEM_MedMedDriver.hxx" #include "MEDMEM_Grid.hxx" #include "MEDMEM_Meshing.hxx" @@ -52,20 +53,38 @@ using namespace MEDMEM; using namespace MED_EN; -typedef FIELD FIELDDOUBLE; -typedef FIELD FIELDINT; + /* typedef FIELD FIELDDOUBLEFULLINTERLACE;*/ + /* typedef FIELD FIELDINTFULLINTERLACE;*/ + typedef FIELD FIELDDOUBLE; + typedef FIELD FIELDINT; + typedef FIELD FIELDDOUBLENOINTERLACE; + typedef FIELD FIELDINTNOINTERLACE; %} -// SWIG needs these typedefs to wrap FIELDDOUBLE*, for ex., to something like -// instance at _d0709808_p_FIELDDOUBLE>, not to -// which has no attributes -typedef FIELD FIELDDOUBLE; -typedef FIELD FIELDINT; +/* + SWIG needs these typedefs to wrap FIELDDOUBLE*, for ex., to something like + instance at _d0709808_p_FIELDDOUBLE>, not to + which has no attributes +*/ + +/*typedef FIELD FIELDDOUBLEFULLINTERLACE;*/ +/*typedef FIELD FIELDINTFULLINTERLACE;*/ +typedef FIELD FIELDDOUBLE; +typedef FIELD FIELDINT; +typedef FIELD FIELDDOUBLENOINTERLACE; +typedef FIELD FIELDINTNOINTERLACE; %include "typemaps.i" %include "my_typemap.i" +/* + mapping between stl string and python string +*/ + +%include "std_string.i" + + /* managing C++ exception in the Python API */ @@ -98,14 +117,14 @@ typedef FIELD FIELDINT; typemap for vector C++ object */ -%typemap(python,in) vector, const vector +%typemap(python,in) vector< FAMILY * >, const vector< FAMILY * > { /* typemap in for vector */ /* Check if is a list */ if (PyList_Check($input)) { int size = PyList_Size($input); - $1.resize(size); + $1 = vector(size); for (int i=0; i < size; i++) { @@ -133,7 +152,7 @@ typedef FIELD FIELDINT; } } -%typemap(python,out) vector +%typemap(python,out) vector< FAMILY * > { /* typemap out for vector */ int size = $1.size(); @@ -153,14 +172,14 @@ typedef FIELD FIELDINT; typemap for vector C++ object */ -%typemap(python,in) vector, const vector +%typemap(python,in) vector< SUPPORT * >, const vector< SUPPORT * > { /* typemap in for vector */ /* Check if is a list */ if (PyList_Check($input)) { int size = PyList_Size($input); - $1.resize(size); + $1 = vector(size); for (int i=0; i < size; i++) { @@ -188,7 +207,7 @@ typedef FIELD FIELDINT; } } -%typemap(python,out) vector +%typemap(python,out) vector< SUPPORT * > { /* typemap out for vector */ int size = $1.size(); @@ -204,7 +223,8 @@ typedef FIELD FIELDINT; } } -%typemap(python,in) vector< FIELD * >, const vector< FIELD * > + +%typemap(python,in) vector< FIELD< double > * >, const vector< FIELD< double > * > { /* typemap in for vector *> */ /* Check if is a list */ @@ -216,9 +236,9 @@ typedef FIELD FIELDINT; for (int i=0; i < size; i++) { PyObject * tmp = PyList_GetItem($input,i); - FIELDDOUBLE * s; + FIELD * s; - int err = SWIG_ConvertPtr(tmp, (void **) &s, $descriptor(FIELDDOUBLE *), + int err = SWIG_ConvertPtr(tmp, (void **) &s, $descriptor(FIELD *), SWIG_POINTER_EXCEPTION); if (err == -1) @@ -240,7 +260,7 @@ typedef FIELD FIELDINT; } } -%typemap(python,out) vector *> +%typemap(python,out) vector< FIELD< double > * > { /* typemap out for vector *> */ int size = $1.size(); @@ -256,7 +276,7 @@ typedef FIELD FIELDINT; } } -%typemap(python,in) vector *>, const vector *> +%typemap(python,in) vector< FIELD< int > * >, const vector< FIELD< int > * > { /* typemap in for vector *> */ /* Check if is a list */ @@ -292,7 +312,7 @@ typedef FIELD FIELDINT; } } -%typemap(python,out) vector *> +%typemap(python,out) vector< FIELD< int > * > { /* typemap out for vector *> */ int size = $1.size(); @@ -308,20 +328,6 @@ typedef FIELD FIELDINT; } } -%typemap(python,out) char * -{ - /* typemap out for char * */ - - $result = PyString_FromString($1); -} - -%typemap(python,out) string { - $result = PyString_FromString($1.c_str()); -} - -%typemap(python,in) string { - $1=string(PyString_AsString($input)); -} /* typemap in for PyObject * fonction Python wrapping of a @@ -353,15 +359,16 @@ typedef FIELD FIELDINT; { PyObject *py_list = PyList_New(size); for (int i=0; i < size; i++) - { - int err = PyList_SetItem(py_list, i, type_converter( arrayvar[ i ])); - if(err) { - char * message = "Error in " #method; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; + int err = PyList_SetItem(py_list, i, type_converter( arrayvar[ i ])); + if(err) + { + char * message = "Error in " #method; + PyErr_SetString(PyExc_RuntimeError, message); + return NULL; + } } - } + PyObject * result = Py_BuildValue("O", py_list); Py_DECREF(py_list); return result; @@ -373,7 +380,10 @@ typedef FIELD FIELDINT; */ %{ - PyObject *PyString_FromStdString(const std::string &str) { return PyString_FromString(str.c_str()); } + PyObject *PyString_FromStdString(const std::string &str) + { + return PyString_FromString(str.c_str()); + } %} @@ -437,6 +447,12 @@ void setMedFileVersionForWriting(medFileVersion version); return self->it; } } + +%typecheck(SWIG_TYPECHECK_POINTER) vector< SUPPORT * >, const vector< SUPPORT * > +{ + $1 = ($input != 0); +} + /* Class et methodes du MED++ que l'on utilise dans l'API Python */ @@ -466,18 +482,11 @@ class CELLMODEL int getNumberOfConstituentsType(); + std::string getName() const; + ~CELLMODEL(); %extend { - %newobject getName(); - char * getName() - { - string tmp_str = self->getName(); - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - %newobject __str__(); const char* __str__() { @@ -501,7 +510,7 @@ class SUPPORT MESH * getMesh() const; - void setMesh(MESH * Mesh); + void setMesh(MESH * Mesh) const; medEntityMesh getEntity() const; @@ -529,12 +538,21 @@ class SUPPORT bool deepCompare(const SUPPORT &support) const; - %extend { - SUPPORT(MESH* Mesh, char * Name="", medEntityMesh Entity=MED_CELL) - { - return new SUPPORT(Mesh,string(Name),Entity); - } + SUPPORT(MESH* Mesh, std::string Name="", medEntityMesh Entity=MED_CELL); + + void setpartial(std::string Description, int NumberOfGeometricType, + int TotalNumberOfElements, medGeometryElement *GeometricType, + int *NumberOfElements, int *NumberValue); + + std::string getName() const; + + void setName(std::string Name); + std::string getDescription(); + + void setDescription(std::string Description); + + %extend { %newobject __str__(); const char* __str__() { @@ -545,63 +563,29 @@ class SUPPORT return returned; } - void setpartial(char * Description, int NumberOfGeometricType, - int TotalNumberOfElements, medGeometryElement *GeometricType, - int *NumberOfElements, int *NumberValue) - { - self->setpartial(string(Description), NumberOfGeometricType, - TotalNumberOfElements, GeometricType, - NumberOfElements, NumberValue); - } - - void setName(char * Name) - { - self->setName(string(Name)); - } - - %newobject getName(); - const char * getName() - { - string tmp_str = self->getName(); - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - - void setDescription(char * Description) - { - self->setDescription(string(Description)); - } - - %newobject getDescription(); - const char * getDescription() - { - string tmp_str = self->getDescription(); - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - PyObject * getTypes() { const medGeometryElement * types = self->getTypes(); int size = self->getNumberOfTypes(); - TYPEMAP_OUTPUT_ARRAY( types, size, PyInt_FromLong, SUPPORT::getTypes ); + TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, SUPPORT::getTypes); } PyObject * getNumber(medGeometryElement GeometricType) { const int * number = self->getNumber(GeometricType); int size = self->getNumberOfElements(GeometricType); - TYPEMAP_OUTPUT_ARRAY( number, size, PyInt_FromLong, SUPPORT::getNumber ); + TYPEMAP_OUTPUT_ARRAY(number, size, PyInt_FromLong, + SUPPORT::getNumber); } PyObject * getNumberIndex() { const int * numberindex = self->getNumberIndex(); int size = (self->getNumberOfElements(MED_ALL_ELEMENTS))+1; - TYPEMAP_OUTPUT_ARRAY( numberindex, size, PyInt_FromLong, SUPPORT::getNumberIndex ); + TYPEMAP_OUTPUT_ARRAY(numberindex, size, PyInt_FromLong, + SUPPORT::getNumberIndex); } + %newobject getComplement() const; SUPPORT *getComplement() const { @@ -653,22 +637,18 @@ class FAMILY : public SUPPORT int getNumberOfGroups() const; - %extend { - FAMILY(MESH* Mesh, int Identifier, char * Name, int NumberOfAttribute, - int *AttributeIdentifier, int *AttributeValue, - char * AttributeDescription, int NumberOfGroup, - char * GroupName, int * MEDArrayNodeFamily, - int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily, - int ** MEDArrayEdgeFamily) - { - return new FAMILY(Mesh,Identifier,string(Name),NumberOfAttribute, - AttributeIdentifier,AttributeValue, - string(AttributeDescription),NumberOfGroup, - string(GroupName), MEDArrayNodeFamily, - MEDArrayCellFamily, MEDArrayFaceFamily, - MEDArrayEdgeFamily); - } + FAMILY(MESH* Mesh, int Identifier, std::string Name, int NumberOfAttribute, + int *AttributeIdentifier, int *AttributeValue, + std::string AttributeDescription, int NumberOfGroup, + std::string GroupName, int * MEDArrayNodeFamily, + int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily, + int ** MEDArrayEdgeFamily); + std::string getAttributeDescription(int i); + + std::string getGroupName(int i); + + %extend { %newobject __str__(); const char* __str__() { @@ -677,47 +657,28 @@ class FAMILY : public SUPPORT return strdup(mess.str().c_str()); } - %newobject getAttributeDescription(int ); - const char * getAttributeDescription(int i) - { - string tmp_str = self->getAttributeDescription(i); - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - - %newobject getGroupName(int ); - const char * getGroupName(int i) - { - string tmp_str = self->getGroupName(i); - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - PyObject * getAttributesIdentifiers() { const int * attributesids = self->getAttributesIdentifiers(); int size = self->getNumberOfAttributes(); - TYPEMAP_OUTPUT_ARRAY(attributesids,size,PyInt_FromLong,FAMILY::getAttributesIdentifiers ); + TYPEMAP_OUTPUT_ARRAY(attributesids,size,PyInt_FromLong, + FAMILY::getAttributesIdentifiers); } PyObject * getAttributesValues() { const int * attributesvals = self->getAttributesValues(); int size = self->getNumberOfAttributes(); - TYPEMAP_OUTPUT_ARRAY(attributesvals,size,PyInt_FromLong,FAMILY::getAttributesValues ); + TYPEMAP_OUTPUT_ARRAY(attributesvals,size,PyInt_FromLong, + FAMILY::getAttributesValues); } } }; - - - class FIELD_ { public: - // FIELD_(const SUPPORT * Support, const int NumberOfComponents); + FIELD_(const SUPPORT * Support, const int NumberOfComponents); ~FIELD_(); @@ -732,9 +693,10 @@ public: void setOrderNumber (int OrderNumber); int getOrderNumber() const; - void setValueType(med_type_champ ValueType) ; med_type_champ getValueType() ; + medModeSwitch getInterlacingType(); + SUPPORT * getSupport(); void setSupport(SUPPORT * support); @@ -744,26 +706,32 @@ public: void setNumberOfValues(int NumberOfValues); int getNumberOfValues() const; - string getName() const; - string getDescription() const; - string getComponentName(int i) const; - string getComponentDescription(int i) const; - string getMEDComponentUnit(int i) const; - void setName(string Name); - void setComponentName(int i, string ComponentName); - void setMEDComponentUnit(int i, string MEDComponentUnit); - void setDescription(string Description); - void setComponentDescription(int i, string ComponentDescription); + std::string getName() const; + + std::string getDescription() const; + + std::string getComponentName(int i) const; + + std::string getComponentDescription(int i) const; + + std::string getMEDComponentUnit(int i) const; + + void setName(std::string Name); + + void setComponentName(int i, std::string ComponentName); + + void setMEDComponentUnit(int i, std::string MEDComponentUnit); + + void setDescription(std::string Description); + + void setComponentDescription(int i, std::string ComponentDescription); + + int addDriver(driverTypes driverType, + const std::string& fileName="Default File Name.med", + const std::string& driverName="Default Field Name", + med_mode_acces access=MED_REMP); %extend { - int addDriver(driverTypes driverType, - char * fileName="Default File Name.med", - char * driverName="Default Field Name", - med_mode_acces access=MED_REMP) - { - return self->addDriver(driverType,string(fileName), - string(driverName),access); - } %newobject getSupportAndOwner(); SUPPORT * getSupportAndOwner() { @@ -772,33 +740,35 @@ public: } }; -template< class T1 > -class FIELD : public FIELD_ +/* + Class FIELD has now two template parameters T1 is a double or an int + INTERLACING_TAG is FullInterlace or NoInterlace +*/ + +template class FIELD : public FIELD_ { public: ~FIELD(); FIELD(const SUPPORT * Support, const int NumberOfComponents); - /* - WARNING: - other constructor of FIELD (C++ FIELD) object. - Only one constructor could be wrapped and - the others commented out when using - SWIG with a version lesser than 1.3 - */ - FIELD(); FIELD(const FIELD & m); + FIELD(const SUPPORT * Support, driverTypes driverType, + const std::string& fileName, const std::string& fieldName, + const int iterationNumber, const int orderNumber); + void read(int index=0); T1 getValueIJ(int i,int j) const; - void setValue(medModeSwitch mode, T1* value); + void setValue(T1* value); + + void setRow( int i, T1 * value); - void setValueI(medModeSwitch mode, int i, T1* value); + void setColumn( int i, T1 * value); void setValueIJ(int i, int j, T1 value); @@ -810,140 +780,179 @@ public: void applyPow(T1 scalar); - T1 normMax(); - T1 norm2(); - T1 normL2(int component, const FIELD * p_field_volume=NULL) const; - T1 normL2(const FIELD * p_field_volume=NULL) const; - T1 normL1(int component, const FIELD * p_field_volume=NULL) const; - T1 normL1(const FIELD * p_field_volume=NULL) const; + double normMax(); + + double norm2(); + + double normL2(int component,const FIELD * + p_field_volume=NULL) const; + + double normL2(const FIELD * + p_field_volume=NULL) const; + + double normL1(int component, const FIELD * + p_field_volume=NULL) const; + double normL1(const FIELD * + p_field_volume=NULL) const; + + void write(int index=0, const std::string& driverName=""); + + void writeAppend(int index=0, const std::string& driverName=""); %extend { PyObject * applyPyFunc( PyObject * func ) - { + { MESSAGE("Appel de applyPyFunc"); if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, "FIELD.applyPyFunc prend en argument une fonction"); - return NULL; + PyErr_SetString(PyExc_TypeError, "FIELD.applyPyFunc prend en argument une fonction"); + return NULL; } int nComp=self->getNumberOfComponents(); int nVal=self->getNumberOfValues(); for (int i=1; i!=nVal+1; ++i) - for ( int j=1 ;j!=nComp+1 ;++j ) + for ( int j=1 ;j!=nComp+1 ;++j ) { self->setValueIJ(i,j, Binding::Functor( func, self->getValueIJ(i,j) ) ); } - PyObject * result = Binding::Traducer(nComp*nVal); - return result; - } - %newobject __add__(const FIELD & ); - FIELD * __add__(const FIELD & m) + PyObject * result = Binding::Traducer(nComp*nVal); + return result; + } + + %newobject __add__(const FIELD & ); + FIELD * __add__(const FIELD & m) { MESSAGE("operator + : Creation of the addition of two FIELDs"); - - FIELD* result = FIELD::add( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + + FIELD* result = + FIELD::add( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - %newobject __sub__(const FIELD & ); - FIELD * __sub__(const FIELD & m) + %newobject __sub__(const FIELD & ); + FIELD * __sub__(const FIELD & m) { MESSAGE("operator - : Creation of the substraction of two FIELDs"); - FIELD* result = FIELD::sub( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + FIELD* result = + FIELD::sub( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - %newobject __mul__(const FIELD & ); - FIELD * __mul__(const FIELD & m) + %newobject __mul__(const FIELD & ); + FIELD * __mul__(const FIELD & m) { MESSAGE("operator * : Creation of the multiplication of two FIELDs"); - FIELD* result = FIELD::mul( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + FIELD* result = + FIELD::mul( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - %newobject __div__(const FIELD & ); - FIELD * __div__(const FIELD & m) + %newobject __div__(const FIELD & ); + FIELD * __div__(const FIELD & m) { MESSAGE("operator / : Creation of the division of two FIELDs"); - FIELD* result = FIELD::div( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + FIELD* result = + FIELD::div( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - %newobject addDeep(const FIELDINT & ); - FIELD * addDeep(const FIELD & m) + %newobject addDeep(const FIELD & ); + FIELD * addDeep(const FIELD & m) { MESSAGE("operator + : Creation of the addition of two FIELDINTs"); - FIELD* result = FIELD::addDeep( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + FIELD* result = + FIELD::addDeep( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - %newobject subDeep(const FIELD & ); - FIELD * subDeep(const FIELD & m) + %newobject subDeep(const FIELD & ); + FIELD * subDeep(const FIELD & m) { MESSAGE("operator - : Creation of the substraction of two FIELDs"); - FIELD* result = FIELD::subDeep( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + FIELD* result = + FIELD::subDeep( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - %newobject mulDeep(const FIELD & ); - FIELD * mulDeep(const FIELD & m) + %newobject mulDeep(const FIELD & ); + FIELD * mulDeep(const FIELD & m) { MESSAGE("operator * : Creation of the multiplication of two FIELDs"); - FIELD* result = FIELD::mulDeep( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + FIELD* result = + FIELD::mulDeep( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - %newobject divDeep(const FIELD & ); - FIELD * divDeep(const FIELD & m) + %newobject divDeep(const FIELD & ); + FIELD * divDeep(const FIELD & m) { MESSAGE("operator / : Creation of the division of two FIELDs"); - FIELD* result = FIELD::divDeep( *(FIELD*)self , (FIELD&)m ); - return (FIELD*) result; + FIELD* result = + FIELD::divDeep( *(FIELD*)self , + (FIELD&)m ); + return (FIELD*) result; } - FIELD (const SUPPORT * Support, driverTypes driverType, - char * fileName, char * fieldName, - const int iterationNumber, - const int orderNumber) + PyObject * getValue() { - return new FIELD(Support, driverType, string(fileName), - string(fieldName),iterationNumber, - orderNumber); - } + int size = (self->getNumberOfComponents())* + ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); - void write(int index=0, char * driverName="") - { - self->write(index, string(driverName)); + const T1 * value = self->getValue(); + + TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer, + FIELD::getValue); } - void writeAppend(int index=0, char * driverName="") + // this method replaces getValueI() in FullInterlace mode + /* %newobject getRow(int );*/ + PyObject * getRow(int index) { - self->writeAppend(index, string(driverName)); + int size = self->getNumberOfComponents(); + + const T1 * value = self->getRow(index); + + TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer, + FIELD::getRow); } - PyObject * getValue(medModeSwitch Mode) + // this method replaces getValueI() in NInterlace mode + /*%newobject getColum(int );*/ + PyObject * getColumn(int index) { - int size = (self->getNumberOfComponents())* - ((self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS)); + int size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - const T1 * value = self->getValue(Mode); + const T1 * value = self->getColumn(index); - TYPEMAP_OUTPUT_ARRAY( value, size, Binding< T1 >::Traducer, FIELD::getValue ); + TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer, + FIELD::getColumn); } - %newobject getValueI(medModeSwitch , int ); - PyObject * getValueI(medModeSwitch Mode, int index) + /* + %newobject getValueI(int ); + PyObject * getValueI(int index) { int size = self->getNumberOfComponents(); + medModeSwitch Mode = self->getInterlacingType(); + if ( Mode == MED_NO_INTERLACE ) size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - const T1 * value = self->getValueI(Mode,index); + const T1 * value = self->getValueI(index); - TYPEMAP_OUTPUT_ARRAY( value, size, Binding< T1 >::Traducer, FIELD::getValueI ); + TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer, + FIELD::getValueI); } + */ void allocValue2(int NumberOfComponents, int LengthValue) { @@ -951,16 +960,20 @@ public: } %newobject extract(const SUPPORT *subSupport); - FIELD *extract(const SUPPORT *subSupport) + FIELD *extract(const SUPPORT *subSupport) { - FIELD* result=self->extract(subSupport); - return (FIELD *)result; + FIELD* result=self->extract(subSupport); + return (FIELD *)result; } } }; -%template (FIELDDOUBLE) FIELD ; -%template (FIELDINT) FIELD ; +/*%template(FIELDDOUBLEFULLINTERLACE) FIELD;*/ +%template(FIELDDOUBLE) FIELD; +%template(FIELDDOUBLENOINTERLACE) FIELD; +/*%template(FIELDINTFULLINTERLACE) FIELD;*/ +%template(FIELDINT) FIELD; +%template(FIELDINTNOINTERLACE) FIELD; class GROUP : public SUPPORT { @@ -970,24 +983,16 @@ public: ~GROUP(); void setNumberOfFamilies(int numberOfFamilies); - void setFamilies(vector Family); + void setFamilies(vector< FAMILY * > Family); int getNumberOfFamilies() const ; - vector getFamilies() const ; + vector< FAMILY * > getFamilies() const ; FAMILY * getFamily(int i) const ; }; class MESH { public : - /* - WARNING: - other constructor of MESH object. - Only one constructor could be wrapped and - the others commented out when using - SWIG with a version lesser than 1.3 - */ - MESH(); ~MESH(); @@ -1029,16 +1034,25 @@ public : int getElementContainingPoint(const double *coord); int getNumberOfTypesWithPoly(medEntityMesh Entity); + int getNumberOfPolygons(); + int getNumberOfPolyhedronFaces(); + int getNumberOfPolyhedron(); + int getNumberOfElementsWithPoly(medEntityMesh Entity, medGeometryElement Type); + bool existPolygonsConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity); + bool existPolyhedronConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity); + medGeometryElement getElementTypeWithPoly(medEntityMesh Entity,int Number); + + std::string getName() const; %extend { %newobject getBoundaryElements(medEntityMesh ); @@ -1053,28 +1067,28 @@ public : return self->getSkin(Support3D); } - %newobject mergeSupports(const vector ); - SUPPORT * mergeSupports(const vector Supports) + %newobject mergeSupports(const vector< SUPPORT * > ); + SUPPORT * mergeSupports(const vector< SUPPORT * > Supports) { return self->mergeSupports(Supports); } - %newobject intersectSupports(const vector ); - SUPPORT * intersectSupports(const vector Supports) + %newobject intersectSupports(const vector< SUPPORT * > ); + SUPPORT * intersectSupports(const vector< SUPPORT * > Supports) { return self->intersectSupports(Supports); } %newobject mergeFieldsDouble(const vector< FIELD* > others); - FIELDDOUBLE * mergeFieldsDouble(const vector< FIELD* > others) + FIELD * mergeFieldsDouble(const vector< FIELD* > others) { - return (FIELDDOUBLE *)self->mergeFields(others); + return (FIELD *)self->mergeFields(others); } %newobject mergeFieldsInt(const vector< FIELD* > others); - FIELDINT * mergeFieldsInt(const vector< FIELD* > others) + FIELD * mergeFieldsInt(const vector< FIELD* > others) { - return (FIELDINT *)self->mergeFields(others); + return (FIELD *)self->mergeFields(others); } CELLMODEL getCellType(medEntityMesh Entity,int i) @@ -1106,15 +1120,6 @@ public : self->setName(string(name)); } - %newobject getName(); - const char * getName() - { - string tmp_str = self->getName(); - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - %newobject getCoordinatesSystem(); const char * getCoordinatesSystem() { @@ -1154,28 +1159,31 @@ public : { const string * array = self->getCoordinatesNames(); int size = self->getSpaceDimension(); - TYPEMAP_OUTPUT_ARRAY( array, size, PyString_FromStdString, MESH::getCoordinatesNames ); + TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString, + MESH::getCoordinatesNames); } PyObject * getCoordinatesUnits() { const string * array = self->getCoordinatesUnits(); int size = self->getSpaceDimension(); - TYPEMAP_OUTPUT_ARRAY( array, size, PyString_FromStdString, MESH::getCoordinatesUnits ); + TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString, + MESH::getCoordinatesUnits); } PyObject * getCoordinates(medModeSwitch Mode) { const double * array = self->getCoordinates(Mode); int size = (self->getSpaceDimension())*(self->getNumberOfNodes()); - TYPEMAP_OUTPUT_ARRAY( array, size, PyFloat_FromDouble, MESH::getCoordinates ); + TYPEMAP_OUTPUT_ARRAY(array, size, PyFloat_FromDouble, + MESH::getCoordinates); } PyObject * getTypes(medEntityMesh Entity) { const medGeometryElement * types = self->getTypes(Entity); int size = self->getNumberOfTypes(Entity); - TYPEMAP_OUTPUT_ARRAY( types, size, PyInt_FromLong, MESH::getTypes ); + TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, MESH::getTypes); } PyObject * getConnectivity(medModeSwitch Mode, @@ -1186,7 +1194,8 @@ public : const int * connectivity = self->getConnectivity(Mode,ConnectivityType, Entity,Type); int size = self->getConnectivityLength(Mode,ConnectivityType,Entity,Type); - TYPEMAP_OUTPUT_ARRAY( connectivity, size, PyInt_FromLong, MESH::getConnectivity ); + TYPEMAP_OUTPUT_ARRAY(connectivity, size, PyInt_FromLong, + MESH::getConnectivity ); } PyObject * getConnectivityIndex(medConnectivity ConnectivityType, @@ -1195,7 +1204,8 @@ public : const int * connectivity_index = self->getConnectivityIndex(ConnectivityType,Entity); int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1; - TYPEMAP_OUTPUT_ARRAY(connectivity_index,size,PyInt_FromLong,MESH::getConnectivityIndex); + TYPEMAP_OUTPUT_ARRAY(connectivity_index,size,PyInt_FromLong, + MESH::getConnectivityIndex); } PyObject * getReverseConnectivity(medConnectivity ConnectivityType, @@ -1204,7 +1214,8 @@ public : const int * reverseconnectivity = self->getReverseConnectivity(ConnectivityType,Entity); int size = self->getReverseConnectivityLength(ConnectivityType,Entity); - TYPEMAP_OUTPUT_ARRAY(reverseconnectivity,size,PyInt_FromLong,MESH::getReverseConnectivity); + TYPEMAP_OUTPUT_ARRAY(reverseconnectivity, size, PyInt_FromLong, + MESH::getReverseConnectivity); } PyObject * getReverseConnectivityIndex(medConnectivity ConnectivityType, @@ -1213,7 +1224,8 @@ public : const int * reverseconnectivity_index = self->getReverseConnectivityIndex(ConnectivityType,Entity); int size=self->getReverseConnectivityIndexLength(ConnectivityType,Entity); - TYPEMAP_OUTPUT_ARRAY(reverseconnectivity_index,size,PyInt_FromLong,MESH::getReverseConnectivityIndex); + TYPEMAP_OUTPUT_ARRAY(reverseconnectivity_index,size, PyInt_FromLong, + MESH::getReverseConnectivityIndex); } PyObject * getGlobalNumberingIndex(medEntityMesh Entity) @@ -1221,79 +1233,90 @@ public : const int * numberingIndex = self->getGlobalNumberingIndex(Entity); int nbOfTypes = self->getNumberOfTypes(Entity); int size = nbOfTypes+1; - TYPEMAP_OUTPUT_ARRAY(numberingIndex,size,PyInt_FromLong,MESH::getGlobalNumberingIndex); + TYPEMAP_OUTPUT_ARRAY(numberingIndex, size, PyInt_FromLong, + MESH::getGlobalNumberingIndex); } - PyObject * getPolygonsConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) { const int * array = self->getPolygonsConnectivity(ConnectivityType,Entity); int size = self->getPolygonsConnectivityLength(ConnectivityType, Entity); - TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolygonsConnectivity); + TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong, + MESH::getPolygonsConnectivity); } + PyObject * getPolygonsConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity) { const int * array = self->getPolygonsConnectivityIndex(ConnectivityType,Entity); int size = self->getNumberOfPolygons() + 1; - TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolygonsConnectivity); + TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong, + MESH::getPolygonsConnectivity); } + PyObject * getPolyhedronConnectivity(medConnectivity ConnectivityType) { const int * array = self->getPolyhedronConnectivity(ConnectivityType); int size = self->getPolyhedronConnectivityLength(ConnectivityType); - TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolygonsConnectivity); + TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong, + MESH::getPolygonsConnectivity); } + PyObject * getPolyhedronIndex(medConnectivity ConnectivityType) { const int * array = self->getPolyhedronIndex(ConnectivityType); int size = self->getNumberOfPolyhedron() + 1; - TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolyhedronIndex); + TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong, + MESH::getPolyhedronIndex); } + PyObject * getPolyhedronFacesIndex() { const int * array = self->getPolyhedronFacesIndex(); int size = self->getNumberOfPolyhedronFaces() + 1; - TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getPolyhedronFacesIndex); + TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong, + MESH::getPolyhedronFacesIndex); } + PyObject * getTypesWithPoly(medEntityMesh Entity) { medGeometryElement * array = self->getTypesWithPoly(Entity); int size = self->getNumberOfTypesWithPoly(Entity); - TYPEMAP_OUTPUT_ARRAY(array,size,PyInt_FromLong,MESH::getTypesWithPoly); + TYPEMAP_OUTPUT_ARRAY(array, size, PyInt_FromLong, + MESH::getTypesWithPoly); delete [] array; } %newobject getVolume(const SUPPORT * ); - FIELDDOUBLE * getVolume(const SUPPORT * Support) + FIELD * getVolume(const SUPPORT * Support) { - return (FIELDDOUBLE *) self->getVolume(Support); + return (FIELD *) self->getVolume(Support); } %newobject getArea(const SUPPORT * ); - FIELDDOUBLE * getArea(const SUPPORT * Support) + FIELD * getArea(const SUPPORT * Support) { - return (FIELDDOUBLE *) self->getArea(Support); + return (FIELD *) self->getArea(Support); } %newobject getLength(const SUPPORT * ); - FIELDDOUBLE * getLength(const SUPPORT * Support) + FIELD * getLength(const SUPPORT * Support) { - return (FIELDDOUBLE *) self->getLength(Support); + return (FIELD *) self->getLength(Support); } %newobject getNormal(const SUPPORT * ); - FIELDDOUBLE * getNormal(const SUPPORT * Support) + FIELD * getNormal(const SUPPORT * Support) { - return (FIELDDOUBLE *) self->getNormal(Support); + return (FIELD *) self->getNormal(Support); } %newobject getBarycenter(const SUPPORT * ); - FIELDDOUBLE * getBarycenter(const SUPPORT * Support) + FIELD * getBarycenter(const SUPPORT * Support) { - return (FIELDDOUBLE *) self->getBarycenter(Support); + return (FIELD *) self->getBarycenter(Support); } } } ; @@ -1306,6 +1329,8 @@ public : void setSpaceDimension (const int SpaceDimension) ; + void setMeshDimension (const int MeshDimension) ; + void setNumberOfNodes (const int NumberOfNodes) ; void setNumberOfTypes (const int NumberOfTypes, @@ -1467,14 +1492,6 @@ class MED void addMesh ( MESH * const ptrMesh ); %extend { - /* - WARNING: - other constructor of MED object. - Only one constructor could be wrapped and - the others commented out when using - SWIG with a version lesser than 1.3 - */ - MED(driverTypes driverType, char * fileName) { return new MED(driverType,string(fileName)); @@ -2296,49 +2313,63 @@ public: %template (ASCII_FIELDDOUBLE_DRIVER) ASCII_FIELD_DRIVER< double >; %template (ASCII_FIELDINT_DRIVER) ASCII_FIELD_DRIVER< int >; - - %{ -template FIELD * createFieldScalarProduct(FIELD * field1, FIELD * field2) { - return (FIELD *) FIELD::scalarProduct( (FIELD)*field1, (FIELD)*field2); -} -template FIELD * createFieldScalarProductDeep(FIELD * field1, FIELD * field2) { - return (FIELD*) FIELD::scalarProduct( (FIELD)*field1, (FIELD)*field2, true); -} -template FIELD * createFieldFromField(FIELD_ * field) { - MESSAGE("createFieldFromField : Constructor (for Python API) FIELD with parameter FIELD_"); - MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELD"); - return (FIELD *) field; -} -%} - -template FIELD * createFieldFromField(FIELD_ * field); -%template ( createFieldDoubleFromField ) createFieldFromField < double >; -%template ( createFieldIntFromField ) createFieldFromField < int >; - -template FIELD * createFieldScalarProduct(FIELD * field1, FIELD * field2); -%newobject createFieldDoubleScalarProduct(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ; -%newobject createFieldIntScalarProduct(FIELDINT * field1, FIELDINT * field2) ; -%template ( createFieldDoubleScalarProduct ) createFieldScalarProduct < double >; -%template ( createFieldIntScalarProduct ) createFieldScalarProduct < int >; + template + FIELD * createFieldScalarProduct(FIELD * field1, + FIELD * field2) + { + return (FIELD *) + FIELD::scalarProduct((FIELD)*field1, + (FIELD)*field2); + } -template FIELD * createFieldScalarProductDeep(FIELD * field1, FIELD * field2); -%newobject createFieldDoubleScalarProductDeep(FIELDDOUBLE * field1, FIELDDOUBLE * field2) ; -%newobject createFieldIntScalarProductDeep(FIELDINT * field1, FIELDINT * field2) ; -%template ( createFieldDoubleScalarProductDeep ) createFieldScalarProductDeep < double >; -%template ( createFieldIntScalarProductDeep ) createFieldScalarProductDeep < int >; + template + FIELD * createFieldScalarProductDeep(FIELD * field1, + FIELD * field2) + { + return (FIELD*) FIELD::scalarProduct((FIELD)*field1, + (FIELD)*field2, true); + } -%newobject createFieldDoubleFromAnalytic(SUPPORT * , int , PyObject *); -%newobject createFieldIntFromAnalytic(SUPPORT * , int , PyObject *); -FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support, - int NumberOfComponents, - PyObject * double_function); -FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support, - int NumberOfComponents, - PyObject * integer_function); + template + FIELD * createTypedFieldFromField(FIELD_ * field) + { + MESSAGE("createTypedFieldFromField : Constructor (for Python API) FIELD with parameter FIELD_"); + MESSAGE("Its returns a proper cast of the input pointer :: FIELD_ --> FIELD"); + return (FIELD *) field; + } +%} +template FIELD * createTypedFieldFromField(FIELD_ * field); +%template ( createFieldDoubleFromField ) createTypedFieldFromField < double, FullInterlace>; +%template ( createFieldIntFromField ) createTypedFieldFromField < int, FullInterlace >; +%template ( createFieldDoubleNoInterlaceFromField ) createTypedFieldFromField < double, NoInterlace>; +%template ( createFieldIntNoInterlaceFromField ) createTypedFieldFromField < int, NoInterlace >; + +template FIELD * createFieldScalarProduct(FIELD * field1, FIELD * field2); +%newobject createFieldDoubleScalarProduct ; +%newobject createFieldIntScalarProduct ; +%newobject createFieldDoubleNoInterlaceScalarProduct ; +%newobject createFieldIntNoInterlaceScalarProduct ; +%template ( createFieldDoubleScalarProduct ) createFieldScalarProduct < double, FullInterlace >; +%template ( createFieldIntScalarProduct ) createFieldScalarProduct < int, FullInterlace >; +%template ( createFieldDoubleNoInterlaceScalarProduct ) createFieldScalarProduct < double, NoInterlace >; +%template ( createFieldIntNoInterlaceScalarProduct ) createFieldScalarProduct < int, NoInterlace >; + +template FIELD * createFieldScalarProductDeep(FIELD * field1, FIELD * field2); +%newobject createFieldDoubleScalarProductDeep ; +%newobject createFieldIntScalarProductDeep ; +%newobject createFieldDoubleNoInterlaceScalarProductDeep ; +%newobject createFieldIntNoInterlaceScalarProductDeep ; +%template ( createFieldDoubleScalarProductDeep ) createFieldScalarProductDeep < double, FullInterlace >; +%template ( createFieldIntScalarProductDeep ) createFieldScalarProductDeep < int, FullInterlace >; +%template ( createFieldDoubleNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < double, NoInterlace >; +%template ( createFieldIntNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < int, NoInterlace >; + +template FIELD * createFieldFromAnalytic(SUPPORT * Support, int NumberOfComponents, PyObject * double_function); GRID * createGridFromMesh( MESH * aMesh ); + %{ GRID * createGridFromMesh( MESH * aMesh ) { @@ -2353,29 +2384,25 @@ GRID * createGridFromMesh( MESH * aMesh ); return NULL; } - FIELDDOUBLE * createFieldDoubleFromAnalytic(SUPPORT * Support, - int NumberOfComponents, - PyObject * double_function) + template + FIELD * createFieldFromAnalytic(SUPPORT * Support, + int NumberOfComponents, + PyObject * double_function) { - MESSAGE("createFieldDoubleFromAnalytic : Constructor (for Python API) FIELDDOUBLE from an analytic fonction"); - FIELDDOUBLE * fieldDouble = new FIELDDOUBLE(Support,NumberOfComponents); - MyFunction::_pyFunc=double_function; - MyFunction::_nbOfComponent=NumberOfComponents; - MyFunction::_spaceDim=Support->getMesh()->getSpaceDimension(); - fieldDouble->fillFromAnalytic< MyFunction::EvalPy2Cpp >(); - return fieldDouble; - } + MESSAGE("createFieldFromAnalytic : Constructor (for Python API) FIELD from an analytic fonction"); - FIELDINT * createFieldIntFromAnalytic(SUPPORT * Support, - int NumberOfComponents, - PyObject * integer_function) - { - MESSAGE("createFieldIntFromAnalytic : Constructor (for Python API) FIELDINT from an analytic fonction"); - FIELDINT * fieldInt = new FIELDINT(Support,NumberOfComponents); - MyFunction::_pyFunc=integer_function; - MyFunction::_nbOfComponent=NumberOfComponents; - MyFunction::_spaceDim=Support->getMesh()->getSpaceDimension(); - fieldInt->fillFromAnalytic< MyFunction::EvalPy2Cpp >(); - return fieldInt; + FIELD * fieldAnalytic = + new FIELD(Support, NumberOfComponents); + + MyFunction::_pyFunc=double_function; + MyFunction::_nbOfComponent=NumberOfComponents; + MyFunction::_spaceDim=Support->getMesh()->getSpaceDimension(); + fieldAnalytic->fillFromAnalytic(MyFunction::EvalPy2Cpp); + return fieldAnalytic; } %} + +%template (createFieldDoubleFromAnalytic) createFieldFromAnalytic; +%template (createFieldIntFromAnalytic) createFieldFromAnalytic; +%template (createFieldDoubleNoInterlaceFromAnalytic) createFieldFromAnalytic; +%template (createFieldIntNoInterlaceFromAnalytic) createFieldFromAnalytic; diff --git a/src/MEDMEM_SWIG/medMeshing_test.py b/src/MEDMEM_SWIG/medMeshing_test.py index 63090c50e..9d88636d6 100644 --- a/src/MEDMEM_SWIG/medMeshing_test.py +++ b/src/MEDMEM_SWIG/medMeshing_test.py @@ -9,9 +9,12 @@ from libMEDMEM_Swig import * -# file name to save the generated MESH(ING) +# files name to save the generated MESH(ING) in different format +# Med V2.1 Med V2.2 and vtk -medFileName = "toto.med" +med21FileName = "toto21.med" + +med22FileName = "toto22.med" vtkFileName = "toto.vtk" @@ -305,9 +308,10 @@ connectivityQuad.append(connectivity[3]) myMeshing.setConnectivity(connectivityQuad,entity,types[1]) -# edge part +meshDimension = spaceDimension # because there 3D cells in the mesh +myMeshing.setMeshDimension(meshDimension) -# saving of the generated mesh in MED and VTK format +# edge part # adding GROUPs # on Node @@ -436,8 +440,23 @@ myGroup.setNumber(index,values) myMeshing.addGroup(myGroup) -idMed = myMeshing.addDriver(MED_DRIVER,medFileName,myMeshing.getName()) -myMeshing.write(idMed) +# saving of the generated mesh in MED 2.1, 2.2 and VTK format + +medFileVersion = getMedFileVersionForWriting() +print "Med File Version For Writing ",medFileVersion + +if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + +idMedV21 = myMeshing.addDriver(MED_DRIVER,med21FileName,myMeshing.getName()) +myMeshing.write(idMedV21) + +medFileVersion = getMedFileVersionForWriting() +if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + +idMedV22 = myMeshing.addDriver(MED_DRIVER,med22FileName,myMeshing.getName()) +myMeshing.write(idMedV22) idVtk = myMeshing.addDriver(VTK_DRIVER,vtkFileName,myMeshing.getName()) myMeshing.write(idVtk) @@ -594,29 +613,63 @@ for i in range(numberOfCells): fieldIntVectorOnCells.setValueIJ(i+1,2,valueInt2) fieldIntVectorOnCells.setValueIJ(i+1,3,valueInt3) -idMed = fieldDoubleScalarOnNodes.addDriver(MED_DRIVER,medFileName,fieldDoubleScalarOnNodes.getName()) -fieldDoubleScalarOnNodes.write(idMed) +medFileVersion = getMedFileVersionForWriting() +print "Med File Version For Writing ",medFileVersion + +if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + +idMedV21 = fieldDoubleScalarOnNodes.addDriver(MED_DRIVER,med21FileName,fieldDoubleScalarOnNodes.getName()) +fieldDoubleScalarOnNodes.write(idMedV21) + +idMedV21 = fieldIntScalarOnNodes.addDriver(MED_DRIVER,med21FileName,fieldIntScalarOnNodes.getName()) +fieldIntScalarOnNodes.write(idMedV21) + +idMedV21 = fieldDoubleVectorOnNodes.addDriver(MED_DRIVER,med21FileName,fieldDoubleVectorOnNodes.getName()) +fieldDoubleVectorOnNodes.write(idMedV21) + +idMedV21 = fieldIntVectorOnNodes.addDriver(MED_DRIVER,med21FileName,fieldIntVectorOnNodes.getName()) +fieldIntVectorOnNodes.write(idMedV21) + +idMedV21 = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,med21FileName,fieldDoubleScalarOnCells.getName()) +fieldDoubleScalarOnCells.write(idMedV21) + +idMedV21 = fieldIntScalarOnCells.addDriver(MED_DRIVER,med21FileName,fieldIntScalarOnCells.getName()) +fieldIntScalarOnCells.write(idMedV21) + +idMedV21 = fieldDoubleVectorOnCells.addDriver(MED_DRIVER,med21FileName,fieldDoubleVectorOnCells.getName()) +fieldDoubleVectorOnCells.write(idMedV21) + +idMedV21 = fieldIntVectorOnCells.addDriver(MED_DRIVER,med21FileName,fieldIntVectorOnCells.getName()) +fieldIntVectorOnCells.write(idMedV21) + +medFileVersion = getMedFileVersionForWriting() +if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + +idMedV22 = fieldDoubleScalarOnNodes.addDriver(MED_DRIVER,med22FileName,fieldDoubleScalarOnNodes.getName()) +fieldDoubleScalarOnNodes.write(idMedV22) -idMed = fieldIntScalarOnNodes.addDriver(MED_DRIVER,medFileName,fieldIntScalarOnNodes.getName()) -fieldIntScalarOnNodes.write(idMed) +idMedV22 = fieldIntScalarOnNodes.addDriver(MED_DRIVER,med22FileName,fieldIntScalarOnNodes.getName()) +fieldIntScalarOnNodes.write(idMedV22) -idMed = fieldDoubleVectorOnNodes.addDriver(MED_DRIVER,medFileName,fieldDoubleVectorOnNodes.getName()) -fieldDoubleVectorOnNodes.write(idMed) +idMedV22 = fieldDoubleVectorOnNodes.addDriver(MED_DRIVER,med22FileName,fieldDoubleVectorOnNodes.getName()) +fieldDoubleVectorOnNodes.write(idMedV22) -idMed = fieldIntVectorOnNodes.addDriver(MED_DRIVER,medFileName,fieldIntVectorOnNodes.getName()) -fieldIntVectorOnNodes.write(idMed) +idMedV22 = fieldIntVectorOnNodes.addDriver(MED_DRIVER,med22FileName,fieldIntVectorOnNodes.getName()) +fieldIntVectorOnNodes.write(idMedV22) -idMed = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,medFileName,fieldDoubleScalarOnCells.getName()) -fieldDoubleScalarOnCells.write(idMed) +idMedV22 = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,med22FileName,fieldDoubleScalarOnCells.getName()) +fieldDoubleScalarOnCells.write(idMedV22) -idMed = fieldIntScalarOnCells.addDriver(MED_DRIVER,medFileName,fieldIntScalarOnCells.getName()) -fieldIntScalarOnCells.write(idMed) +idMedV22 = fieldIntScalarOnCells.addDriver(MED_DRIVER,med22FileName,fieldIntScalarOnCells.getName()) +fieldIntScalarOnCells.write(idMedV22) -idMed = fieldDoubleVectorOnCells.addDriver(MED_DRIVER,medFileName,fieldDoubleVectorOnCells.getName()) -fieldDoubleVectorOnCells.write(idMed) +idMedV22 = fieldDoubleVectorOnCells.addDriver(MED_DRIVER,med22FileName,fieldDoubleVectorOnCells.getName()) +fieldDoubleVectorOnCells.write(idMedV22) -idMed = fieldIntVectorOnCells.addDriver(MED_DRIVER,medFileName,fieldIntVectorOnCells.getName()) -fieldIntVectorOnCells.write(idMed) +idMedV22 = fieldIntVectorOnCells.addDriver(MED_DRIVER,med22FileName,fieldIntVectorOnCells.getName()) +fieldIntVectorOnCells.write(idMedV22) idVtk = fieldDoubleScalarOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleScalarOnNodes.getName()) fieldDoubleScalarOnNodes.writeAppend(idVtk) diff --git a/src/MEDMEM_SWIG/med_field_anal.py b/src/MEDMEM_SWIG/med_field_anal.py index 3f90aeca7..dafa86a6d 100755 --- a/src/MEDMEM_SWIG/med_field_anal.py +++ b/src/MEDMEM_SWIG/med_field_anal.py @@ -176,7 +176,7 @@ support = fieldDoubleScalOnCell.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldDoubleScalOnCell.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldDoubleScalOnCell.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -205,7 +205,7 @@ support = fieldDoubleVectOnCell.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldDoubleVectOnCell.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldDoubleVectOnCell.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -234,7 +234,7 @@ support = fieldIntScalOnCell.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldIntScalOnCell.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldIntScalOnCell.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -263,7 +263,7 @@ support = fieldIntVectOnCell.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldIntVectOnCell.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldIntVectOnCell.getRow(k+1) print " *",valueI[:nbOfComp] ##print "" @@ -328,7 +328,7 @@ support = fieldDoubleScalOnNode.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldDoubleScalOnNode.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldDoubleScalOnNode.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -357,7 +357,7 @@ support = fieldDoubleVectOnNode.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldDoubleVectOnNode.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldDoubleVectOnNode.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -386,7 +386,7 @@ support = fieldIntScalOnNode.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldIntScalOnNode.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldIntScalOnNode.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -415,7 +415,7 @@ support = fieldIntVectOnNode.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldIntVectOnNode.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldIntVectOnNode.getRow(k+1) print " *",valueI[:nbOfComp] ##print "" @@ -480,7 +480,7 @@ support = fieldDoubleScalOnConst.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldDoubleScalOnConst.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldDoubleScalOnConst.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -509,7 +509,7 @@ support = fieldDoubleVectOnConst.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldDoubleVectOnConst.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldDoubleVectOnConst.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -538,7 +538,7 @@ support = fieldIntScalOnConst.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldIntScalOnConst.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldIntScalOnConst.getRow(k+1) print " *",valueI[:nbOfComp] print "" @@ -567,7 +567,7 @@ support = fieldIntVectOnConst.getSupport() nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldIntVectOnConst.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldIntVectOnConst.getRow(k+1) print " *",valueI[:nbOfComp] print "" diff --git a/src/MEDMEM_SWIG/med_opfield_test.py b/src/MEDMEM_SWIG/med_opfield_test.py index 4012353a9..995df1482 100755 --- a/src/MEDMEM_SWIG/med_opfield_test.py +++ b/src/MEDMEM_SWIG/med_opfield_test.py @@ -87,6 +87,7 @@ if (nbFields>0): if type == MED_INT32: fieldint = createFieldIntFromField(field) fieldint.read() + fieldint.getSupport().update() name = fieldint.getName() desc = fieldint.getDescription() nbOfComp = fieldint.getNumberOfComponents() @@ -125,7 +126,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldint.getRow(k+1) print " *",valueI[:nbOfComp] fieldint2 = FIELDINT(fieldint) print "" @@ -157,7 +158,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldintadd.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldintadd.getRow(k+1) print " *",valueI[:nbOfComp] print "" fieldintsub = fieldint - fieldint2 @@ -188,7 +189,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldintsub.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldintsub.getRow(k+1) print " *",valueI[:nbOfComp] print "" fieldintmul = fieldint * fieldint2 @@ -219,42 +220,47 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldintmul.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldintmul.getRow(k+1) print " *",valueI[:nbOfComp] print "" - fieldintdiv = fieldint / fieldint2 - print "Test of the division of two integer fields with creation a new one" - print "" - name = fieldintdiv.getName() - desc = fieldintdiv.getDescription() - nbOfComp = fieldintdiv.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintdiv.getIterationNumber() - orderNb = fieldintdiv.getOrderNumber() - time = fieldintdiv.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintdiv.getComponentName(kp1) - compDesc = fieldintdiv.getComponentDescription(kp1) - compUnit = fieldintdiv.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintdiv.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintdiv.getValueI(MED_FULL_INTERLACE,k+1) - print " *",valueI[:nbOfComp] + try: + fieldintdiv = fieldint / fieldint2 + print "Test of the division of two integer fields with creation a new one" + print "" + name = fieldintdiv.getName() + desc = fieldintdiv.getDescription() + nbOfComp = fieldintdiv.getNumberOfComponents() + print " Field",name," : ",desc + print " Number Of Components:",nbOfComp + iterationNb = fieldintdiv.getIterationNumber() + orderNb = fieldintdiv.getOrderNumber() + time = fieldintdiv.getTime() + print " Iteration Number",iterationNb + print " Order Number",orderNb + print " Time",time + for k in range(nbOfComp): + kp1 = k+1 + compName = fieldintdiv.getComponentName(kp1) + compDesc = fieldintdiv.getComponentDescription(kp1) + compUnit = fieldintdiv.getMEDComponentUnit(kp1) + print " * Component:",kp1 + print " Name:",compName + print " Description:",compDesc + print " Unit:",compUnit + + support = fieldintdiv.getSupport() + nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) + print " Values:",nbOf + for k in range(nbOf): + valueI = fieldintdiv.getRow(k+1) + print " *",valueI[:nbOfComp] + + except: + print "fieldintdiv = fieldint / fieldint2 catch/except error" elif type == MED_REEL64: fielddouble = createFieldDoubleFromField(field) fielddouble.read() + fielddouble.getSupport().update() name = fielddouble.getName() desc = fielddouble.getDescription() nbOfComp = fielddouble.getNumberOfComponents() @@ -296,7 +302,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddouble.getRow(k+1) print " *",valueI[:nbOfComp] fielddouble2 = FIELDDOUBLE(fielddouble) print "" @@ -328,7 +334,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddoubleadd.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddoubleadd.getRow(k+1) print " *",valueI[:nbOfComp] print "" fielddoublesub = fielddouble - fielddouble2 @@ -359,7 +365,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddoublesub.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddoublesub.getRow(k+1) print " *",valueI[:nbOfComp] print "" fielddoublemul = fielddouble * fielddouble2 @@ -390,39 +396,42 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddoublemul.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddoublemul.getRow(k+1) print " *",valueI[:nbOfComp] print "" - fielddoublediv = fielddouble / fielddouble2 - print "Test of the division of two double fields with creation a new one" - print "" - name = fielddoublediv.getName() - desc = fielddoublediv.getDescription() - nbOfComp = fielddoublediv.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoublediv.getIterationNumber() - orderNb = fielddoublediv.getOrderNumber() - time = fielddoublediv.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoublediv.getComponentName(kp1) - compDesc = fielddoublediv.getComponentDescription(kp1) - compUnit = fielddoublediv.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoublediv.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoublediv.getValueI(MED_FULL_INTERLACE,k+1) + try: + fielddoublediv = fielddouble / fielddouble2 + print "Test of the division of two double fields with creation a new one" + print "" + name = fielddoublediv.getName() + desc = fielddoublediv.getDescription() + nbOfComp = fielddoublediv.getNumberOfComponents() + print " Field",name," : ",desc + print " Number Of Components:",nbOfComp + iterationNb = fielddoublediv.getIterationNumber() + orderNb = fielddoublediv.getOrderNumber() + time = fielddoublediv.getTime() + print " Iteration Number",iterationNb + print " Order Number",orderNb + print " Time",time + for k in range(nbOfComp): + kp1 = k+1 + compName = fielddoublediv.getComponentName(kp1) + compDesc = fielddoublediv.getComponentDescription(kp1) + compUnit = fielddoublediv.getMEDComponentUnit(kp1) + print " * Component:",kp1 + print " Name:",compName + print " Description:",compDesc + print " Unit:",compUnit + + support = fielddoublediv.getSupport() + nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) + print " Values:",nbOf + for k in range(nbOf): + valueI = fielddoublediv.getRow(k+1) print " *",valueI[:nbOfComp] + except: + print "fielddoublediv = fielddouble / fielddouble2 catch/except error" else: print " !!!! Bad type of Field !!!!" @@ -432,33 +441,42 @@ print "TESTS OPERATIONS SUR FIELDDOUBLE : " fielddoublesub = fielddouble-fielddouble2 fielddoublemul = fielddouble*fielddouble2 -fielddoublediv = fielddouble/fielddouble2 + +try: + fielddoublediv = fielddouble/fielddouble2 +except: + pass + fielddoubleasso = fielddouble+fielddouble2*fielddouble2 fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2) -print " f1 : ",fielddouble.getValue(MED_FULL_INTERLACE) -print " f2 : ",fielddouble2.getValue(MED_FULL_INTERLACE) +print " f1 : ",fielddouble.getValue() +print " f2 : ",fielddouble2.getValue() print "--------------------------------------------------------------------------------------------------------------" -print " + : ",fielddoubleadd.getValue(MED_FULL_INTERLACE) -print " - : ",fielddoublesub.getValue(MED_FULL_INTERLACE) -print " * : ",fielddoublemul.getValue(MED_FULL_INTERLACE) -print " / : ",fielddoublediv.getValue(MED_FULL_INTERLACE) +print " + : ",fielddoubleadd.getValue() +print " - : ",fielddoublesub.getValue() +print " * : ",fielddoublemul.getValue() + +try: + print " / : ",fielddoublediv.getValue() +except: + pass fielddouble+=fielddouble2; -print " += : ",fielddouble.getValue(MED_FULL_INTERLACE) +print " += : ",fielddouble.getValue() fielddouble-=fielddouble2; -print " -= : ",fielddouble.getValue(MED_FULL_INTERLACE) +print " -= : ",fielddouble.getValue() fielddouble*=fielddouble2; -print " *= : ",fielddouble.getValue(MED_FULL_INTERLACE) +print " *= : ",fielddouble.getValue() fielddouble/=fielddouble2; -print " /= : ",fielddouble.getValue(MED_FULL_INTERLACE) -print "f1+f2*f2: ",fielddoubleasso.getValue(MED_FULL_INTERLACE) +print " /= : ",fielddouble.getValue() +print "f1+f2*f2: ",fielddoubleasso.getValue() fielddouble.applyLin(4,1); -print " 4f1+1 : ",fielddouble.getValue(MED_FULL_INTERLACE) -print " f1.f2 : ",fielddoubleSP.getValue(MED_FULL_INTERLACE) +print " 4f1+1 : ",fielddouble.getValue() +print " f1.f2 : ",fielddoubleSP.getValue() fielddouble2.applyPyFunc(add_one) -print " CB:f2+1: ",fielddouble2.getValue(MED_FULL_INTERLACE) +print " CB:f2+1: ",fielddouble2.getValue() print "" print "TESTS OPERATIONS SUR FIELDINT : " @@ -467,31 +485,41 @@ print "TESTS OPERATIONS SUR FIELDINT : " fieldintadd = fieldint+fieldint2 fieldintsub = fieldint-fieldint2 fieldintmul = fieldint*fieldint2 -fieldintdiv = fieldint/fieldint2 + +try: + fieldintdiv = fieldint/fieldint2 +except: + pass + fieldintasso = fieldint+fieldint*fieldint fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2) -print " f1 : ",fieldint.getValue(MED_FULL_INTERLACE) -print " f2 : ",fieldint2.getValue(MED_FULL_INTERLACE) +print " f1 : ",fieldint.getValue() +print " f2 : ",fieldint2.getValue() print "--------------------------------------------------------------------------------------------------------------" -print " + : ",fieldintadd.getValue(MED_FULL_INTERLACE) -print " - : ",fieldintsub.getValue(MED_FULL_INTERLACE) -print " * : ",fieldintmul.getValue(MED_FULL_INTERLACE) -print " / : ",fieldintdiv.getValue(MED_FULL_INTERLACE) +print " + : ",fieldintadd.getValue() +print " - : ",fieldintsub.getValue() +print " * : ",fieldintmul.getValue() + +try: + print " / : ",fieldintdiv.getValue() +except: + pass + fieldint+=fieldint2; -print " += : ",fieldint.getValue(MED_FULL_INTERLACE) +print " += : ",fieldint.getValue() fieldint-=fieldint2; -print " -= : ",fieldint.getValue(MED_FULL_INTERLACE) +print " -= : ",fieldint.getValue() fieldint*=fieldint2; -print " *= : ",fieldint.getValue(MED_FULL_INTERLACE) +print " *= : ",fieldint.getValue() fieldint/=fieldint2; -print " /= : ",fieldint.getValue(MED_FULL_INTERLACE) -print "f1+f2*f2: ",fieldintasso.getValue(MED_FULL_INTERLACE) +print " /= : ",fieldint.getValue() +print "f1+f2*f2: ",fieldintasso.getValue() fieldint.applyLin(4,1); -print " 4f1+1 : ",fieldint.getValue(MED_FULL_INTERLACE) -print " f1.f2 : ",fieldintSP.getValue(MED_FULL_INTERLACE) +print " 4f1+1 : ",fieldint.getValue() +print " f1.f2 : ",fieldintSP.getValue() fieldint2.applyPyFunc(add_one) -print " CB:f2+1: ",fieldint2.getValue(MED_FULL_INTERLACE) +print " CB:f2+1: ",fieldint2.getValue() myname="toto" fieldint.setName(myname) name = fieldint.getName() diff --git a/src/MEDMEM_SWIG/med_test1.py b/src/MEDMEM_SWIG/med_test1.py index be47667f2..ad1782f24 100644 --- a/src/MEDMEM_SWIG/med_test1.py +++ b/src/MEDMEM_SWIG/med_test1.py @@ -199,7 +199,8 @@ if (nbMeshes>0): number = family.getNumber(type) print " * Type",type print " * Number",number[0:nbOfElmtsOfType] - print "" + print "" + numberFamily = family.getNumber(MED_ALL_ELEMENTS) print " * Getting an Integer Field on the family ",familyName fieldFamilyIntg = FIELDINT(family,spaceDim) fieldFamilyIntg.setIterationNumber(0) @@ -243,16 +244,15 @@ if (nbMeshes>0): nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf print " Randomly set and get to check ..!" - mode = MED_FULL_INTERLACE for k in range(nbOf): valueI = [] for kcomp in range(nbOfComp): valueI.append(randint(0,100)) # print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - - fieldFamilyIntg.setValueI(mode,k+1,valueI) - valueIverif = fieldFamilyIntg.getValueI(mode,k+1) + valInd = numberFamily[k] + fieldFamilyIntg.setRow(valInd,valueI) + valueIverif = fieldFamilyIntg.getRow(valInd) print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] print " * Getting a Real Field" fieldFamilyDble = FIELDDOUBLE(family,spaceDim) @@ -304,9 +304,9 @@ if (nbMeshes>0): valueI.append(random()) # print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - - fieldFamilyDble.setValueI(MED_FULL_INTERLACE,k+1,valueI) - valueIverif = fieldFamilyDble.getValueI(MED_FULL_INTERLACE,k+1) + valInd = numberFamily[k] + fieldFamilyDble.setRow(valInd,valueI) + valueIverif = fieldFamilyDble.getRow(valInd) print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] print "" print "" @@ -359,7 +359,7 @@ if (nbMeshes>0): barycenter = mesh.getBarycenter(supportCell) print "Getting barycenter of all Cells of the mesh" for j in range(nbElemts): - barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1) + barycenterCell = barycenter.getRow(j+1) print " * ",barycenterCell[:spaceDim] print "" if spaceDim == 3 : @@ -383,8 +383,8 @@ if (nbMeshes>0): normal = mesh.getNormal(supportFace) area = mesh.getArea(supportFace) for j in range(nbFace): - normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1) - areaFace = area.getValueI(MED_FULL_INTERLACE,j+1) + normalFace = normal.getRow(j+1) + areaFace = area.getRow(j+1) value1 = normalFace[0] value2 = normalFace[1] value3 = normalFace[2] @@ -411,8 +411,8 @@ if (nbMeshes>0): normal = mesh.getNormal(supportEdge) length = mesh.getLength(supportEdge) for j in range(nbEdge): - normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1) - lengthEdge = length.getValueI(MED_FULL_INTERLACE,j+1) + normalEdge = normal.getRow(j+1) + lengthEdge = length.getRow(j+1) value1 = normalEdge[0] value2 = normalEdge[1] norm = (value1*value1 + value2*value2)**(0.5) @@ -424,8 +424,10 @@ if (nbMeshes>0): nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound normalBound = mesh.getNormal(suppBound) + numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) for j in range(nbElmBound): - normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) + valInd = numberSuppBound[j] + normalBoundJ = normalBound.getRow(valInd) value1 = normalBoundJ[0] value2 = normalBoundJ[1] value3 = normalBoundJ[2] @@ -436,8 +438,10 @@ if (nbMeshes>0): nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound normalBound = mesh.getNormal(suppBound) + numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) for j in range(nbElmBound): - normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) + valInd = numberSuppBound[j] + normalBoundJ = normalBound.getRow(valInd) value1 = normalBoundJ[0] value2 = normalBoundJ[1] norm = (value1*value1 + value2*value2)**(0.5) @@ -486,7 +490,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldint.getRow(k+1) print " *",valueI[:nbOfComp] elif type == MED_REEL64: fielddouble = createFieldDoubleFromField(field) @@ -516,7 +520,7 @@ if (nbFields>0): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddouble.getRow(k+1) print " *",valueI[:nbOfComp] else: print " !!!! Bad type of Field !!!!" diff --git a/src/MEDMEM_SWIG/med_test2.py b/src/MEDMEM_SWIG/med_test2.py index 9fadb1032..95cbad106 100644 --- a/src/MEDMEM_SWIG/med_test2.py +++ b/src/MEDMEM_SWIG/med_test2.py @@ -2,9 +2,9 @@ # # This Python script is parsing a MED file using MED Memory from SALOME platform: # It analyses all meshes in the MED file (coordinates, connectivity of d-cells as -# well as (d-1)-cells, families), it tests all fields generated ine the MESH class -# and write them in a new file , it gives only the number of fields stored in the -# MED file (d is the space dimension). +# well as (d-1)-cells, families), it tests all fields generated in the MESH class +# and write them in a 2 new med files (V2.1 and V2.2), it gives only the number of +# fields stored in the MED file (d is the mesh/space dimension). # ################################################################################### @@ -25,7 +25,7 @@ def AnalyzeField(field): print "iteration number ",itNum," order Number ",ordNum print "It has ",nbComp," component(s) with the type ",type - fieldValue = field.getValue(MED_FULL_INTERLACE) + fieldValue = field.getValue() fieldSupport = field.getSupport() fieldMesh = fieldSupport.getMesh() fieldEntity = fieldSupport.getEntity() @@ -224,6 +224,7 @@ if (nbMeshes>0): print " * Type",type print " * Number",number[0:nbOfElmtsOfType] print "" + numberFamily = family.getNumber(MED_ALL_ELEMENTS) print " * Getting an Integer Field on the family ",familyName fieldFamilyIntg = FIELDINT(family,spaceDim) fieldFamilyIntg.setIterationNumber(0) @@ -267,16 +268,15 @@ if (nbMeshes>0): nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf print " Randomly set and get to check ..!" - mode = MED_FULL_INTERLACE for k in range(nbOf): valueI = [] for kcomp in range(nbOfComp): valueI.append(randint(0,100)) # print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - - fieldFamilyIntg.setValueI(mode,k+1,valueI) - valueIverif = fieldFamilyIntg.getValueI(mode,k+1) + valInd = numberFamily[k] + fieldFamilyIntg.setRow(valInd,valueI) + valueIverif = fieldFamilyIntg.getRow(valInd) print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] print " * Getting a Real Field" fieldFamilyDble = FIELDDOUBLE(family,spaceDim) @@ -328,18 +328,21 @@ if (nbMeshes>0): valueI.append(random()) # print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - - fieldFamilyDble.setValueI(MED_FULL_INTERLACE,k+1,valueI) - valueIverif = fieldFamilyDble.getValueI(MED_FULL_INTERLACE,k+1) + valInd = numberFamily[k] + fieldFamilyDble.setRow(valInd,valueI) + valueIverif = fieldFamilyDble.getRow(valInd) print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] if (entity != MED_NODE): print "" print "Getting barycenter on this family" barycenterfamily = mesh.getBarycenter(family) + if (not familyBool): numberFamily = family.getNumber(MED_ALL_ELEMENTS) nbVal = barycenterfamily.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) nbComp = barycenterfamily.getNumberOfComponents() for j in range(nbVal): - barycenterfamilyentity = barycenterfamily.getValueI(MED_FULL_INTERLACE,j+1) + valInd = j+1 + if (not familyBool): valInd = numberFamily[j] + barycenterfamilyentity = barycenterfamily.getRow(valInd) print " * ",barycenterfamilyentity[:nbComp] print "" @@ -350,25 +353,49 @@ if (nbMeshes>0): print "Getting barycenter of all Cells of the mesh" barycenter = mesh.getBarycenter(supportCell) for j in range(nbElemts): - barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1) + barycenterCell = barycenter.getRow(j+1) print " * ",barycenterCell[:spaceDim] print "Writing on file the mesh" - - writeMedFile = medFile[0:(len(medFile)-4)]+"_fields.med" + writeMed21File = medFile[0:(len(medFile)-4)]+"_V21_fields.med" + writeMed22File = medFile[0:(len(medFile)-4)]+"_V22_fields.med" fieldsMesh = barycenter.getSupport().getMesh() fieldsMeshName = "Fields Mesh" fieldsMesh.setName(fieldsMeshName) - indexMesh = fieldsMesh.addDriver(MED_DRIVER,writeMedFile,fieldsMeshName) - fieldsMesh.write(indexMesh,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + + index21Mesh = fieldsMesh.addDriver(MED_DRIVER,writeMed21File,fieldsMeshName) + fieldsMesh.write(index21Mesh,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + + index22Mesh = fieldsMesh.addDriver(MED_DRIVER,writeMed22File,fieldsMeshName) + fieldsMesh.write(index22Mesh,"") AnalyzeField(barycenter) print "Writing on file the cells barycenter field" barycenterName = barycenter.getName() - indexFieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMedFile,barycenterName) - barycenter.write(indexFieldBarycenter,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + + index21FieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMed21File,barycenterName) + barycenter.write(index21FieldBarycenter,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + + index22FieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMed22File,barycenterName) + barycenter.write(index22FieldBarycenter,"") print "" if spaceDim == 3 : @@ -387,8 +414,20 @@ if (nbMeshes>0): print "Writing on file the cells volume field" volumeName = volume.getName() - indexFieldVolume = volume.addDriver(MED_DRIVER,writeMedFile,volumeName) - volume.write(indexFieldVolume,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + + index21FieldVolume = volume.addDriver(MED_DRIVER,writeMed21File,volumeName) + volume.write(index21FieldVolume,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + + index22FieldVolume = volume.addDriver(MED_DRIVER,writeMed22File,volumeName) + volume.write(index22FieldVolume,"") print "" print "Building of the support on all Faces of the mesh." @@ -402,7 +441,7 @@ if (nbMeshes>0): print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace] normal = mesh.getNormal(supportFace) for j in range(nbFace): - normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1) + normalFace = normal.getRow(j+1) value1 = normalFace[0] value2 = normalFace[1] value3 = normalFace[2] @@ -415,8 +454,20 @@ if (nbMeshes>0): print "Writing on file the face normal field" normalName = normal.getName() - indexFieldNormal = normal.addDriver(MED_DRIVER,writeMedFile,normalName) - normal.write(indexFieldNormal,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + + index21FieldNormal = normal.addDriver(MED_DRIVER,writeMed21File,normalName) + normal.write(index21FieldNormal,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + + index22FieldNormal = normal.addDriver(MED_DRIVER,writeMed22File,normalName) + normal.write(index22FieldNormal,"") elif spaceDim == 2: print "Getting area on all Cells of the mesh:" @@ -434,8 +485,21 @@ if (nbMeshes>0): print "Writing on file the cells area field" areaName = area.getName() - indexFieldArea = area.addDriver(MED_DRIVER,writeMedFile,areaName) - area.write(indexFieldArea,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + + index21FieldArea = area.addDriver(MED_DRIVER,writeMed21File,areaName) + area.write(index21FieldArea,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + + index22FieldArea = area.addDriver(MED_DRIVER,writeMed22File,areaName) + area.write(index22FieldArea,"") + print "" print "Building of the support on all Edges of the mesh." supportEdge = SUPPORT(mesh,"Support on all edges of the mesh",MED_EDGE) @@ -448,7 +512,7 @@ if (nbMeshes>0): print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge] normal = mesh.getNormal(supportEdge) for j in range(nbEdge): - normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1) + normalEdge = normal.getRow(j+1) value1 = normalEdge[0] value2 = normalEdge[1] norm = (value1*value1 + value2*value2)**(0.5) @@ -460,6 +524,20 @@ if (nbMeshes>0): print "Writing on file the edge normal field" normalName = normal.getName() - indexFieldNormal = normal.addDriver(MED_DRIVER,writeMedFile,normalName) - normal.write(indexFieldNormal,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V22): + setMedFileVersionForWriting(V21) + + index21FieldNormal = normal.addDriver(MED_DRIVER,writeMed21File,normalName) + normal.write(index21FieldNormal,"") + + medFileVersion = getMedFileVersionForWriting() + if (medFileVersion == V21): + setMedFileVersionForWriting(V22) + + index22FieldNormal = normal.addDriver(MED_DRIVER,writeMed22File,normalName) + normal.write(index22FieldNormal,"") print "" + +print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_test3.py b/src/MEDMEM_SWIG/med_test3.py index ed73f9b23..26c74f3c3 100644 --- a/src/MEDMEM_SWIG/med_test3.py +++ b/src/MEDMEM_SWIG/med_test3.py @@ -1,3 +1,8 @@ +# +# This script does not work at the moment !!! +# + + ################################################################################### # # This Python script is parsing a MED file using MED Memory from SALOME platform: @@ -112,6 +117,7 @@ if (nbMeshes>0): print " * Type",type print " * Number",number[0:nbOfElmtsOfType] print "" + numberFamily = family.getNumber(MED_ALL_ELEMENTS) print " * Getting an Integer Field on the family ",familyName fieldFamilyIntg = FIELDINT(family,spaceDim) fieldFamilyIntg.setIterationNumber(0) @@ -160,8 +166,8 @@ if (nbMeshes>0): value.append(randint(0,100)) print " the mode is full interlace" mode = MED_FULL_INTERLACE - fieldFamilyIntg.setValue(mode,value) - valueverif = fieldFamilyIntg.getValue(mode) + fieldFamilyIntg.setValue(value) + valueverif = fieldFamilyIntg.getValue() for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" @@ -170,8 +176,8 @@ if (nbMeshes>0): value.append(randint(0,100)) print " the mode is no interlace" mode = MED_NO_INTERLACE - fieldFamilyIntg.setValue(mode,value) - valueverif = fieldFamilyIntg.getValue(mode) + fieldFamilyIntg.setValue(value) + valueverif = fieldFamilyIntg.getValue() for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" @@ -182,8 +188,8 @@ if (nbMeshes>0): print " the mode for set is full interlace and no interlace for get" mode_full = MED_FULL_INTERLACE mode_no = MED_NO_INTERLACE - fieldFamilyIntg.setValue(mode_full,value) - valueverif = fieldFamilyIntg.getValue(mode_no) + fieldFamilyIntg.setValue(value) + valueverif = fieldFamilyIntg.getValue() for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" @@ -191,8 +197,8 @@ if (nbMeshes>0): for k in range(nbOf*nbOfComp): value.append(randint(0,100)) print " the mode for set is no interlace and full interlace for get" - fieldFamilyIntg.setValue(mode_no,value) - valueverif = fieldFamilyIntg.getValue(mode_full) + fieldFamilyIntg.setValue(value) + valueverif = fieldFamilyIntg.getValue() for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" @@ -203,10 +209,10 @@ if (nbMeshes>0): print " the mode is full interlace" mode = MED_FULL_INTERLACE for k in range(nbOf): - fieldFamilyIntg.setValueI(mode,(k+1),value[k*nbOfComp:(k+1)*nbOfComp]) + fieldFamilyIntg.setRow((k+1),value[k*nbOfComp:(k+1)*nbOfComp]) valueverif = [] for k in range(nbOf): - valueverif.extend(fieldFamilyIntg.getValueI(mode,(k+1))) + valueverif.extend(fieldFamilyIntg.getRow((k+1))) for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" @@ -216,10 +222,10 @@ if (nbMeshes>0): print " the mode is no interlace" mode = MED_NO_INTERLACE for k in range(nbOfComp): - fieldFamilyIntg.setValueI(mode,(k+1),value[k*nbOf:(k+1)*nbOf]) + fieldFamilyIntg.setColumn((k+1),value[k*nbOf:(k+1)*nbOf]) valueverif = [] for k in range(nbOfComp): - valueverif.extend(fieldFamilyIntg.getValueI(mode,(k+1))) + valueverif.extend(fieldFamilyIntg.getColumn((k+1))) for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" @@ -231,10 +237,10 @@ if (nbMeshes>0): mode_full = MED_FULL_INTERLACE mode_no = MED_NO_INTERLACE for k in range(nbOf): - fieldFamilyIntg.setValueI(mode_full,(k+1),value[k*nbOfComp:(k+1)*nbOfComp]) + fieldFamilyIntg.setRow((k+1),value[k*nbOfComp:(k+1)*nbOfComp]) valueverif = [] for k in range(nbOfComp): - valueverif.extend(fieldFamilyIntg.getValueI(mode_no,(k+1))) + valueverif.extend(fieldFamilyIntg.getColumn((k+1))) for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" @@ -243,10 +249,10 @@ if (nbMeshes>0): value.append(randint(0,100)) print " the mode for set is no interlace and full interlace for get" for k in range(nbOfComp): - fieldFamilyIntg.setValueI(mode_no,(k+1),value[k*nbOf:(k+1)*nbOf]) + fieldFamilyIntg.setColumn((k+1),value[k*nbOf:(k+1)*nbOf]) valueverif = [] for k in range(nbOf): - valueverif.extend(fieldFamilyIntg.getValueI(mode_full,(k+1))) + valueverif.extend(fieldFamilyIntg.getRow((k+1))) for k in range(nbOf*nbOfComp): print " Set/Get Entry * ",value[k]," / ",valueverif[k] print "" diff --git a/src/MEDMEM_SWIG/testDriverAscii.py b/src/MEDMEM_SWIG/testDriverAscii.py new file mode 100644 index 000000000..cc63c96a9 --- /dev/null +++ b/src/MEDMEM_SWIG/testDriverAscii.py @@ -0,0 +1,43 @@ +from libMEDMEM_Swig import * + +import os + +# +#before running this script, please be sure about the path the file fileName +# + +filePath=os.environ["MED_ROOT_DIR"] +filePath=filePath+"/share/salome/resources/" + +medFile = filePath + "test_2D.med" + +asciiFile = "tyst.txt" + +md=MED() +dr=MED_MED_RDONLY_DRIVER(medFile,md) + +dr.open() +dr.readFileStruct() +dr.read() +dr.close() + +nbMeshes = md.getNumberOfMeshes() + +nbFields = md.getNumberOfFields() + +print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)" +f1Name=md.getFieldName(0) +f1It=md.getFieldNumberOfIteration(f1Name) +it=md.getFieldIteration(f1Name,0) +f1=md.getField(f1Name,it.dt,it.it) +f1=createFieldDoubleFromField(f1) +#f1.read() +id2=f1.addDriver(ASCII_DRIVER,asciiFile,"Default Field Name",MED_ECRI) +#dr=ASCII_FIELDDOUBLE_DRIVER(asciiFile,f1,DESCENDING) +#dr.open() +#dr.write() +#dr.close() +##print f1It +f1.write(id2) + +print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/testMedMemGeneral.py b/src/MEDMEM_SWIG/testMedMemGeneral.py index e2c25505b..8720c7833 100755 --- a/src/MEDMEM_SWIG/testMedMemGeneral.py +++ b/src/MEDMEM_SWIG/testMedMemGeneral.py @@ -83,11 +83,11 @@ meshNameFiles.append("CUBE_EN_HEXA8") files.append("cube_hexa8_import22.med") meshNameFiles.append("CUBE_EN_HEXA8") -files.append("test19.med") -meshNameFiles.append("CartGrid") +##files.append("test19.med") +##meshNameFiles.append("CartGrid") -files.append("test19.med") -meshNameFiles.append("bodyfitted") +##files.append("test19.med") +##meshNameFiles.append("bodyfitted") ##files.append("test19.med") ##meshNameFiles.append("maa1") @@ -587,12 +587,11 @@ for i in range(nbOfFiles): print "Building of the support on all Cells of the mesh." supportCell = SUPPORT(mesh) - supportCell.update() print "" barycenter = mesh.getBarycenter(supportCell) print "Getting barycenter of all Cells of the mesh" for j in range(nbElemts): - barycenterCell = barycenter.getValueI(MED_FULL_INTERLACE,j+1) + barycenterCell = barycenter.getRow(j+1) print " * ",barycenterCell[:spaceDim] print "" @@ -665,8 +664,8 @@ for i in range(nbOfFiles): normal = mesh.getNormal(supportFace) area = mesh.getArea(supportFace) for j in range(nbFace): - normalFace = normal.getValueI(MED_FULL_INTERLACE,j+1) - areaFace = area.getValueI(MED_FULL_INTERLACE,j+1) + normalFace = normal.getRow(j+1) + areaFace = area.getRow(j+1) value1 = normalFace[0] value2 = normalFace[1] value3 = normalFace[2] @@ -742,8 +741,8 @@ for i in range(nbOfFiles): normal = mesh.getNormal(supportEdge) length = mesh.getLength(supportEdge) for j in range(nbEdge): - normalEdge = normal.getValueI(MED_FULL_INTERLACE,j+1) - lengthEdge = length.getValueI(MED_FULL_INTERLACE,j+1) + normalEdge = normal.getRow(j+1) + lengthEdge = length.getRow(j+1) value1 = normalEdge[0] value2 = normalEdge[1] norm = (value1*value1 + value2*value2)**(0.5) @@ -778,8 +777,10 @@ for i in range(nbOfFiles): nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound normalBound = mesh.getNormal(suppBound) + numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) for j in range(nbElmBound): - normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) + valInd = numberSuppBound[j] + normalBoundJ = normalBound.getRow(valInd) value1 = normalBoundJ[0] value2 = normalBoundJ[1] value3 = normalBoundJ[2] @@ -790,8 +791,10 @@ for i in range(nbOfFiles): nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound normalBound = mesh.getNormal(suppBound) + numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) for j in range(nbElmBound): - normalBoundJ = normalBound.getValueI(MED_FULL_INTERLACE,j+1) + valInd = numberSuppBound[j] + normalBoundJ = normalBound.getRow(valInd) value1 = normalBoundJ[0] value2 = normalBoundJ[1] norm = (value1*value1 + value2*value2)**(0.5) @@ -892,7 +895,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldint.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldint.getRow(k+1) print " *",valueI[:nbOfComp] fieldint2 = FIELDINT(fieldint) print "" @@ -924,7 +927,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldintadd.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldintadd.getRow(k+1) print " *",valueI[:nbOfComp] print "" fieldintsub = fieldint - fieldint2 @@ -955,7 +958,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldintsub.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldintsub.getRow(k+1) print " *",valueI[:nbOfComp] print "" fieldintmul = fieldint * fieldint2 @@ -986,7 +989,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldintmul.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldintmul.getRow(k+1) print " *",valueI[:nbOfComp] print "" try: @@ -1018,7 +1021,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldintdiv.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldintdiv.getRow(k+1) print " *",valueI[:nbOfComp] print "" print "TESTS OPERATIONS SUR FIELDINT : " @@ -1035,35 +1038,35 @@ for i in range(nbOfFiles): fieldintasso = fieldint+fieldint*fieldint fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2) - print " f1 : ",fieldint.getValue(MED_FULL_INTERLACE) - print " f2 : ",fieldint2.getValue(MED_FULL_INTERLACE) + print " f1 : ",fieldint.getValue() + print " f2 : ",fieldint2.getValue() print "--------------------------------------------------------------------------------------------------------------" - print " + : ",fieldintadd.getValue(MED_FULL_INTERLACE) - print " - : ",fieldintsub.getValue(MED_FULL_INTERLACE) - print " * : ",fieldintmul.getValue(MED_FULL_INTERLACE) + print " + : ",fieldintadd.getValue() + print " - : ",fieldintsub.getValue() + print " * : ",fieldintmul.getValue() if fieldintdiv == None : print "testMedMemGeneral / : None" else: - print " / : ",fieldintdiv.getValue(MED_FULL_INTERLACE) + print " / : ",fieldintdiv.getValue() fieldint+=fieldint2; - print " += : ",fieldint.getValue(MED_FULL_INTERLACE) + print " += : ",fieldint.getValue() fieldint-=fieldint2; - print " -= : ",fieldint.getValue(MED_FULL_INTERLACE) + print " -= : ",fieldint.getValue() fieldint*=fieldint2; - print " *= : ",fieldint.getValue(MED_FULL_INTERLACE) + print " *= : ",fieldint.getValue() try: fieldint/=fieldint2; - print " /= : ",fieldint.getValue(MED_FULL_INTERLACE) + print " /= : ",fieldint.getValue() except : fieldint = None print " /= : Catch/Except : None" - print "f1+f2*f2: ",fieldintasso.getValue(MED_FULL_INTERLACE) + print "f1+f2*f2: ",fieldintasso.getValue() if fieldint != None : fieldint.applyLin(4,1); - print " 4f1+1 : ",fieldint.getValue(MED_FULL_INTERLACE) - print " f1.f2 : ",fieldintSP.getValue(MED_FULL_INTERLACE) + print " 4f1+1 : ",fieldint.getValue() + print " f1.f2 : ",fieldintSP.getValue() fieldint2.applyPyFunc(add_one) - print " CB:f2+1: ",fieldint2.getValue(MED_FULL_INTERLACE) + print " CB:f2+1: ",fieldint2.getValue() elif type == MED_REEL64: fielddouble = createFieldDoubleFromField(field) fielddouble.read() @@ -1080,6 +1083,7 @@ for i in range(nbOfFiles): print " Time",time print " Norme 2 : ", fielddouble.norm2() print " Norme Max : ", fielddouble.normMax() + fielddouble.getSupport().update() print "try sobolev",fielddouble.getSupport().getEntity() if fielddouble.getSupport().getEntity()!=MED_NODE: if (spaceDim == 3): @@ -1108,7 +1112,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddouble.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddouble.getRow(k+1) print " *",valueI[:nbOfComp] fielddouble2 = FIELDDOUBLE(fielddouble) print "" @@ -1140,7 +1144,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddoubleadd.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddoubleadd.getRow(k+1) print " *",valueI[:nbOfComp] print "" fielddoublesub = fielddouble - fielddouble2 @@ -1171,7 +1175,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddoublesub.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddoublesub.getRow(k+1) print " *",valueI[:nbOfComp] print "" fielddoublemul = fielddouble * fielddouble2 @@ -1202,7 +1206,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddoublemul.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddoublemul.getRow(k+1) print " *",valueI[:nbOfComp] print "" try: @@ -1234,7 +1238,7 @@ for i in range(nbOfFiles): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fielddoublediv.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fielddoublediv.getRow(k+1) print " *",valueI[:nbOfComp] except: print "testMedMemGeneral fielddoublediv = fielddouble / fielddouble2 catch/except error" @@ -1250,32 +1254,32 @@ for i in range(nbOfFiles): fielddoublediv = None fielddoubleasso = fielddouble+fielddouble2*fielddouble2 fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2) - print " f1 : ",fielddouble.getValue(MED_FULL_INTERLACE) - print " f2 : ",fielddouble2.getValue(MED_FULL_INTERLACE) + print " f1 : ",fielddouble.getValue() + print " f2 : ",fielddouble2.getValue() print "--------------------------------------------------------------------------------------------------------------" - print " + : ",fielddoubleadd.getValue(MED_FULL_INTERLACE) - print " - : ",fielddoublesub.getValue(MED_FULL_INTERLACE) - print " * : ",fielddoublemul.getValue(MED_FULL_INTERLACE) + print " + : ",fielddoubleadd.getValue() + print " - : ",fielddoublesub.getValue() + print " * : ",fielddoublemul.getValue() if fielddoublediv != None: - print " / : ",fielddoublediv.getValue(MED_FULL_INTERLACE) + print " / : ",fielddoublediv.getValue() pass fielddouble+=fielddouble2; - print " += : ",fielddouble.getValue(MED_FULL_INTERLACE) + print " += : ",fielddouble.getValue() fielddouble-=fielddouble2; - print " -= : ",fielddouble.getValue(MED_FULL_INTERLACE) + print " -= : ",fielddouble.getValue() fielddouble*=fielddouble2; - print " *= : ",fielddouble.getValue(MED_FULL_INTERLACE) + print " *= : ",fielddouble.getValue() try: fielddouble/=fielddouble2; - print " /= : ",fielddouble.getValue(MED_FULL_INTERLACE) + print " /= : ",fielddouble.getValue() except: print "testMedMemGeneral /= : " - print "f1+f2*f2: ",fielddoubleasso.getValue(MED_FULL_INTERLACE) + print "f1+f2*f2: ",fielddoubleasso.getValue() fielddouble.applyLin(4,1); - print " 4f1+1 : ",fielddouble.getValue(MED_FULL_INTERLACE) - print " f1.f2 : ",fielddoubleSP.getValue(MED_FULL_INTERLACE) + print " 4f1+1 : ",fielddouble.getValue() + print " f1.f2 : ",fielddoubleSP.getValue() fielddouble2.applyPyFunc(add_one) - print " CB:f2+1: ",fielddouble2.getValue(MED_FULL_INTERLACE) + print " CB:f2+1: ",fielddouble2.getValue() else: print " !!!! Bad type of Field !!!!" diff --git a/src/MedClient/src/FIELDClient.cxx b/src/MedClient/src/FIELDClient.cxx index a0ed65543..66f3914c5 100644 --- a/src/MedClient/src/FIELDClient.cxx +++ b/src/MedClient/src/FIELDClient.cxx @@ -17,25 +17,25 @@ // // See http://www.salome-platform.org/ // -template -FIELDClient::FIELDClient(typename MapCppFieldServ::FieldPtrType ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(MapCppFieldServ::FieldGlobalType::_duplicate(ptrCorba)),_refCounter(1) +template +FIELDClient::FIELDClient(typename FIELDI_TRAITS::SimpleFieldCorbaPtrType ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(FIELDI_TRAITS::SimpleFieldGlobalType::_duplicate(ptrCorba)),_refCounter(1) { if (!S) { SCRUTE(_fieldPtr); SCRUTE(_fieldPtr->getSupport()); - MEDMEM::FIELD::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport()); + MEDMEM::FIELD::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport()); } else - MEDMEM::FIELD::setSupport(S); + MEDMEM::FIELD::setSupport(S); setName(_fieldPtr->getName()); - MEDMEM::FIELD::setDescription(_fieldPtr->getDescription()); + MEDMEM::FIELD::setDescription(_fieldPtr->getDescription()); int nc = _fieldPtr->getNumberOfComponents(); - MEDMEM::FIELD::setNumberOfComponents(nc); + MEDMEM::FIELD::setNumberOfComponents(nc); - MEDMEM::FIELD::setNumberOfValues( MEDMEM::FIELD::_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); + MEDMEM::FIELD::setNumberOfValues( MEDMEM::FIELD::_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); string * _s = new string[nc]; @@ -43,48 +43,48 @@ FIELDClient::FIELDClient(typename MapCppFieldServ::FieldPtrType ptrCorba,M s = _fieldPtr->getComponentsNames(); for (int i=0; i::setComponentsNames(_s); + MEDMEM::FIELD::setComponentsNames(_s); s = _fieldPtr->getComponentsDescriptions(); for (int i=0; i::setComponentsDescriptions(_s); + MEDMEM::FIELD::setComponentsDescriptions(_s); s = _fieldPtr->getComponentsUnits(); for (int i=0; i::setMEDComponentsUnits(_s); + MEDMEM::FIELD::setMEDComponentsUnits(_s); delete [] _s; - -// s = _fieldPtr->getComponentsDescriptions(); -// for (int i=0; isetComponentsDescriptions(_s); setIterationNumber(_fieldPtr->getIterationNumber()); setTime(_fieldPtr->getTime()); setOrderNumber(_fieldPtr->getOrderNumber()); fillCopy(); } -template -void FIELDClient::fillCopy() +template +void FIELDClient::fillCopy() { - //setValueType(typeChamps); WARNING TO DO..... - //setValueType(_fieldPtr->getValueType()); long n; - typename mapCppSender::SenderVarType sender=_fieldPtr->getSenderForValue(MED_EN::MED_FULL_INTERLACE); + typename FIELDI_TRAITS::SenderVarType sender=_fieldPtr->getSenderForValue(MEDMEM::FIELD::_interlacingType); T *v = (T *)ReceiverFactory::getValue(sender,n); - MEDMEM::MEDARRAY * M = new MEDMEM::MEDARRAY(v, MEDMEM::FIELD::getNumberOfComponents(),MEDMEM::FIELD::getNumberOfValues(),MED_EN::MED_FULL_INTERLACE,true,true); - setValue(M); + MEDMEM::MEDMEM_Array_ * array; + if(_fieldPtr->getGaussPresence()) + array=0; + //array=new typename MEDMEM::MEDMEM_ArrayInterface::Array + // (v, MEDMEM::FIELD::getNumberOfComponents(),MEDMEM::FIELD::getNumberOfValues(),true,true); + else + array=new typename MEDMEM::MEDMEM_ArrayInterface::Array + (v, MEDMEM::FIELD::getNumberOfComponents(),MEDMEM::FIELD::getNumberOfValues(),true,true); + MEDMEM::FIELD::setArray(array); } -template -FIELDClient::~FIELDClient() +template +FIELDClient::~FIELDClient() { _fieldPtr->Destroy(); CORBA::release(_fieldPtr); - if(FIELD::_support) - FIELD::_support->removeReference(); + if(FIELD::_support) + FIELD::_support->removeReference(); } diff --git a/src/MedClient/src/FIELDClient.hxx b/src/MedClient/src/FIELDClient.hxx index 7dfc16ead..a812f65ad 100644 --- a/src/MedClient/src/FIELDClient.hxx +++ b/src/MedClient/src/FIELDClient.hxx @@ -26,36 +26,20 @@ #include "SUPPORTClient.hxx" #include "ReceiverFactory.hxx" #include "SenderFactory.hxx" +#include "MEDMEM_TraitsForFields.hxx" +#include "MEDMEM_InterlacingTraits.hxx" #include CORBA_CLIENT_HEADER(MED) -template -struct MapCppFieldServ { - typedef T FieldPtrType; - typedef T FieldGlobalType; -}; - -template<> -struct MapCppFieldServ { - typedef SALOME_MED::FIELDINT_ptr FieldPtrType; - typedef SALOME_MED::FIELDINT FieldGlobalType; -}; - -template<> -struct MapCppFieldServ { - typedef SALOME_MED::FIELDDOUBLE_ptr FieldPtrType; - typedef SALOME_MED::FIELDDOUBLE FieldGlobalType; -}; - namespace MEDMEM{ -template -class FIELDClient : public MEDMEM::FIELD +template +class FIELDClient : public MEDMEM::FIELD { private: - typename MapCppFieldServ::FieldPtrType _fieldPtr; + typename FIELDI_TRAITS::SimpleFieldCorbaPtrType _fieldPtr; int _refCounter; public: - FIELDClient(typename MapCppFieldServ::FieldPtrType ptrCorba,MEDMEM::SUPPORT * S = NULL); + FIELDClient(typename FIELDI_TRAITS::SimpleFieldCorbaPtrType ptrCorba,MEDMEM::SUPPORT * S = NULL); ~FIELDClient(); private: void fillCopy(); diff --git a/src/MedClient/src/Makefile.in b/src/MedClient/src/Makefile.in index 07f8c272f..082cd052c 100644 --- a/src/MedClient/src/Makefile.in +++ b/src/MedClient/src/Makefile.in @@ -44,8 +44,6 @@ EXPORT_HEADERS = \ GROUPClient.hxx \ FIELDClient.hxx \ FIELDClient.cxx \ - FIELDDOUBLEClient.hxx \ - FIELDINTClient.hxx \ libMEDClient.i ifeq (@SWIG_VERSION@, 1.3.21) @@ -78,9 +76,7 @@ LIB_SRC = \ MESHClient.cxx \ SUPPORTClient.cxx \ FAMILYClient.cxx \ - GROUPClient.cxx \ - FIELDDOUBLEClient.cxx \ - FIELDINTClient.cxx + GROUPClient.cxx LIB_CLIENT_IDL= \ SALOME_Component.idl \ @@ -99,7 +95,7 @@ BIN_CLIENT_IDL = LDFLAGS= -L$(top_builddir)/lib/salome LDFLAGSFORBIN= -L$(top_builddir)/lib/salome -CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) $(PYTHON_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I$(srcdir)/../../MEDMEM_I CXXFLAGS+=-I${KERNEL_ROOT_DIR}/include/salome LDFLAGS+=-L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lMedCorba_Swigcmodule -lmedmem diff --git a/src/MedClient/src/SUPPORTClient.cxx b/src/MedClient/src/SUPPORTClient.cxx index e9b27a3e7..4a2ef7620 100644 --- a/src/MedClient/src/SUPPORTClient.cxx +++ b/src/MedClient/src/SUPPORTClient.cxx @@ -70,18 +70,10 @@ void SUPPORTClient::blankCopy() setEntity(all->entity); // modifs PN setNumberOfGeometricType(all->numberOfGeometricType); - convertCorbaArray(_geometricType, _numberOfGeometricType, - &all->types); - - //_name = IOR_Support->getName(); - //_description = IOR_Support->getDescription(); - //setAll(IOR_Support->isOnAllElements()); - //setEntity(IOR_Support->getEntity()); + convertCorbaArray2(_geometricType, _numberOfGeometricType, all->types); SCRUTE(_name); SCRUTE(_description); - //convertCorbaArray(_geometricType, _numberOfGeometricType, - // IOR_Support->getTypes()); int *nE = new int[_numberOfGeometricType]; int i; @@ -120,7 +112,7 @@ void SUPPORTClient::fillCopy() BEGIN_OF("SUPPORTClient::fillCopy"); if (!_complete_support) { - + if(!_isOnAllElts) { const int * index, * value; long n_index, n_value; @@ -132,7 +124,7 @@ void SUPPORTClient::fillCopy() SCRUTE(n_index); SCRUTE(n_value); setNumber(index, value,true); - + } _complete_support = true; } @@ -201,6 +193,22 @@ const int * SUPPORTClient::getNumberIndex() const throw (MEDEXCEPTION) return n; } +//============================================================================= +/*! + * + */ +//============================================================================= +int SUPPORTClient::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION) +{ + BEGIN_OF("SUPPORTClient::getValIndFromGlobalNumber()"); + + if (!_complete_support) (const_cast(this))->fillCopy(); + const int n = SUPPORT::getValIndFromGlobalNumber(number); + + END_OF("SUPPORTClient::getValIndFromGlobalNumber()"); + return n; +} + //============================================================================= /*! * diff --git a/src/MedClient/src/SUPPORTClient.hxx b/src/MedClient/src/SUPPORTClient.hxx index 30c65cd06..a49ee9731 100644 --- a/src/MedClient/src/SUPPORTClient.hxx +++ b/src/MedClient/src/SUPPORTClient.hxx @@ -55,6 +55,8 @@ public : const throw (MEDEXCEPTION); const int * getNumberIndex() const throw (MEDEXCEPTION); + int getValIndFromGlobalNumber(const int number) + const throw (MEDEXCEPTION); void addReference() const; void removeReference() const; }; diff --git a/src/MedClient/src/UtilClient.hxx b/src/MedClient/src/UtilClient.hxx index 6970a48bc..4db2c9f86 100644 --- a/src/MedClient/src/UtilClient.hxx +++ b/src/MedClient/src/UtilClient.hxx @@ -22,6 +22,7 @@ #include #include +#include "MEDMEM_PointerOf.hxx" namespace MEDMEM { template +inline void convertCorbaArray2 (TLocal& tab, Tint &nT, const TCorbaSeq s) +{ + Tint i, n = s.length(); + + nT = n; + tab.set(n); + for (i=0; i diff --git a/src/MedClient/src/libMEDClient.i b/src/MedClient/src/libMEDClient.i index 630769980..e5a017b27 100644 --- a/src/MedClient/src/libMEDClient.i +++ b/src/MedClient/src/libMEDClient.i @@ -22,11 +22,8 @@ %{ #include "MESHClient.hxx" #include "SUPPORTClient.hxx" -#include "FIELDDOUBLEClient.hxx" -#include "FIELDINTClient.hxx" +#include "FIELDClient.hxx" #include CORBA_CLIENT_HEADER(MED) -/* #define FIELDDOUBLEClient FIELDClient */ -/* #define FIELDINTClient FIELDClient */ using namespace MEDMEM; using namespace MED_EN; @@ -40,6 +37,7 @@ $1 = ($input != 0); } + class MESHClient : public MESH { public: @@ -72,34 +70,66 @@ class SUPPORTClient : public SUPPORT { }; -class FIELDDOUBLEClient : public FIELDDOUBLE { +template +class FIELDClient : public FIELD +{ public: - FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba, - MEDMEM::SUPPORT * S = NULL); + template + FIELDClient(U ptrCorba,MEDMEM::SUPPORT * S = NULL); + ~FIELDClient(); +}; + +%template (FIELDDOUBLEClient) FIELDClient; +%template (FIELDDOUBLENOINTERLACEClient) FIELDClient; +%template (FIELDINTClient) FIELDClient; +%template (FIELDINTNOINTERLACEClient) FIELDClient; + +%extend FIELDClient +{ + %template(FIELDDOUBLEClients) FIELDClient; +}; - ~FIELDDOUBLEClient(); +%extend FIELDClient +{ + %template(FIELDDOUBLENOINTERLACEClients) FIELDClient; }; -class FIELDINTClient : public FIELDINT { -public: - FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba, - MEDMEM::SUPPORT * S = NULL); +%extend FIELDClient +{ + %template(FIELDINTClients) FIELDClient; +}; - ~FIELDINTClient(); +%extend FIELDClient +{ + %template(FIELDINTNOINTERLACEClients) FIELDClient; }; -FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input); +FIELD * getDoublePointer(FIELDClient * input); + +FIELD *getDoubleNoInterlacePointer(FIELDClient * input); -FIELDINT * getIntPointer(FIELDINTClient * input); +FIELD * getIntPointer(FIELDClient * input); + +FIELD * getIntNoInterlacePointer(FIELDClient * input); %{ - FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input) + FIELD * getDoublePointer(FIELDClient * input) + { + return (FIELD *) input; + } + + FIELD *getDoubleNoInterlacePointer(FIELDClient * input) { - return (FIELDDOUBLE *) input; + return (FIELD *) input; } - FIELDINT * getIntPointer(FIELDINTClient * input) + FIELD * getIntPointer(FIELDClient * input) + { + return (FIELD *) input; + } + + FIELD * getIntNoInterlacePointer(FIELDClient * input) { - return (FIELDINT *) input; + return (FIELD *) input; } %} diff --git a/src/MedClient/src/medClient_test.py b/src/MedClient/src/medClient_test.py index e8a466fd1..f01a35780 100644 --- a/src/MedClient/src/medClient_test.py +++ b/src/MedClient/src/medClient_test.py @@ -330,7 +330,7 @@ for i in range(nbOfFields): nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) print " Values:",nbOf for k in range(nbOf): - valueI = fieldTyped.getValueI(MED_FULL_INTERLACE,k+1) + valueI = fieldTyped.getRow(k+1) print " *",valueI[:nbOfComp] diff --git a/src/MedClient/test/test2/Compo2.cxx b/src/MedClient/test/test2/Compo2.cxx index b6389d82d..9223c9bdd 100644 --- a/src/MedClient/test/test2/Compo2.cxx +++ b/src/MedClient/test/test2/Compo2.cxx @@ -81,7 +81,7 @@ void Compo2::Calcul3(const FIELD &F) { BEGIN_OF("void Compo2::Calcul3(const FIELD *)"); - const double *v = F.getValue(MED_FULL_INTERLACE); + const double *v = F.getValue(); long i, n = F.getSupport()->getNumberOfElements(MED_CELL); int j, m = F.getNumberOfComponents(); diff --git a/src/MedCorba_Swig/libMedCorba_Swig.i b/src/MedCorba_Swig/libMedCorba_Swig.i index 562cf2a53..7f7486f84 100644 --- a/src/MedCorba_Swig/libMedCorba_Swig.i +++ b/src/MedCorba_Swig/libMedCorba_Swig.i @@ -24,15 +24,12 @@ %{ #include "MEDMEM_convert.hxx" #include "MEDMEM_Family_i.hxx" -#include "MEDMEM_FieldDouble_i.hxx" #include "MEDMEM_Field_i.hxx" -#include "MEDMEM_FieldInt_i.hxx" +#include "MEDMEM_FieldTemplate_i.hxx" #include "MEDMEM_Group_i.hxx" #include "MEDMEM_Med_i.hxx" #include "MEDMEM_Mesh_i.hxx" #include "MEDMEM_Support_i.hxx" -// #include "MEDMEM_SWIG_FieldDouble.hxx" -// #include "MEDMEM_SWIG_FieldInt.hxx" using namespace MEDMEM; using namespace MED_EN; @@ -531,7 +528,7 @@ SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh); field->setDescription("Got From A Local One"); - FIELDDOUBLE_i * fieldimpl = new FIELDDOUBLE_i(field, ownCppPtr); + FIELDTEMPLATE_I *fieldimpl = new FIELDTEMPLATE_I(field, ownCppPtr); SALOME_MED::FIELDDOUBLE_ptr fieldcorba2 = fieldimpl->_this(); @@ -563,7 +560,7 @@ SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh); field->setDescription("Got From A Local One"); - FIELDINT_i * fieldimpl = new FIELDINT_i(field, ownCppPtr); + FIELDTEMPLATE_I * fieldimpl = new FIELDTEMPLATE_I(field, ownCppPtr); SALOME_MED::FIELDINT_ptr fieldcorba2 = fieldimpl->_this();