From b7d5c783f2d85cda6d4f781e2135608053bc9930 Mon Sep 17 00:00:00 2001 From: nadir Date: Thu, 14 Oct 2004 12:18:49 +0000 Subject: [PATCH] Final version V2_0_1 which works with Med File V2.1 and the KERNEL with AG addings. --- src/INTERPOLATION/MEDMEM_Interpolation.hxx | 378 ++++++++ .../MEDMEM_InterpolationHighLevelObjects.hxx | 453 +++++++++ ...DMEM_InterpolationHighLevelObjects.hxx.old | 104 ++ .../MEDMEM_InterpolationTools.hxx | 532 ++++++++++ src/INTERPOLATION/MEDMEM_Mapping.hxx | 258 +++++ src/INTERPOLATION/MEDMEM_MappingTools.hxx | 241 +++++ src/INTERPOLATION/MEDMEM_WrapperCells.hxx | 917 ++++++++++++++++++ .../MEDMEM_WrapperConnectivity.hxx | 61 ++ src/INTERPOLATION/MEDMEM_WrapperField.hxx | 207 ++++ src/INTERPOLATION/MEDMEM_WrapperMesh.hxx | 309 ++++++ src/INTERPOLATION/MEDMEM_WrapperNodes.hxx | 119 +++ src/INTERPOLATION/MEDMEM_dTree.hxx | 656 +++++++++++++ src/INTERPOLATION/MEDMEM_dTreeSommet.hxx | 59 ++ src/INTERPOLATION/Makefile.in | 102 ++ src/INTERPOLATION/UseCaseInterpolationts.cxx | 78 ++ .../UseCaseInterpolationwots.cxx | 43 + src/INTERPOLATION/UseCaseMapping.cxx | 50 + src/INTERPOLATION/UseCaseWrapper_Maillage.cxx | 36 + src/INTERPOLATION/UseCasedTree.cxx | 58 ++ src/INTERPOLATION/create_mesh_interpolation.c | 523 ++++++++++ .../test_MEDMEM_Interpolation.cxx | 56 ++ .../test_MEDMEM_InterpolationFlipBack.cxx | 252 +++++ ...st_MEDMEM_InterpolationFromMesh_toMesh.cxx | 56 ++ ...st_MEDMEM_InterpolationRecopieMaillage.cxx | 156 +++ ...EDMEM_InterpolationSansRecopieMaillage.cxx | 54 ++ .../test_MEDMEM_InterpolationTimeStep.cxx | 108 +++ src/MED/Makefile.in | 2 +- src/MED/Med_Gen_i.cxx | 50 +- src/MEDMEM/MEDMEM_Array.hxx | 129 ++- src/MEDMEM/MEDMEM_CellModel.cxx | 132 +-- src/MEDMEM/MEDMEM_CellModel.hxx | 6 +- src/MEDMEM/MEDMEM_Connectivity.cxx | 380 ++++---- src/MEDMEM/MEDMEM_Connectivity.hxx | 93 +- src/MEDMEM/MEDMEM_Coordinate.cxx | 30 +- src/MEDMEM/MEDMEM_Coordinate.hxx | 14 +- src/MEDMEM/MEDMEM_DriverFactory.cxx | 89 ++ src/MEDMEM/MEDMEM_DriverFactory.hxx | 63 ++ src/MEDMEM/MEDMEM_DriverTools.cxx | 1 + src/MEDMEM/MEDMEM_DriversDef.hxx | 18 +- src/MEDMEM/MEDMEM_Exception.cxx | 9 +- src/MEDMEM/MEDMEM_Exception.hxx | 2 +- src/MEDMEM/MEDMEM_Family.hxx | 18 +- src/MEDMEM/MEDMEM_Field.cxx | 20 +- src/MEDMEM/MEDMEM_Field.hxx | 132 +-- src/MEDMEM/MEDMEM_GibiMeshDriver.cxx | 8 +- src/MEDMEM/MEDMEM_Group.cxx | 2 +- src/MEDMEM/MEDMEM_Group.hxx | 6 +- src/MEDMEM/MEDMEM_Med.cxx | 53 +- src/MEDMEM/MEDMEM_Med.hxx | 32 +- src/MEDMEM/MEDMEM_MedFieldDriver.hxx | 185 ++-- src/MEDMEM/MEDMEM_MedMedDriver.cxx | 2 +- src/MEDMEM/MEDMEM_MedMeshDriver.cxx | 477 +++++---- src/MEDMEM/MEDMEM_Mesh.cxx | 97 +- src/MEDMEM/MEDMEM_Mesh.hxx | 138 +-- src/MEDMEM/MEDMEM_PointerOf.hxx | 35 +- src/MEDMEM/MEDMEM_SkyLineArray.cxx | 17 +- src/MEDMEM/MEDMEM_SkyLineArray.hxx | 2 +- src/MEDMEM/MEDMEM_Support.cxx | 4 +- src/MEDMEM/MEDMEM_Support.hxx | 6 +- src/MEDMEM/MEDMEM_VtkFieldDriver.hxx | 147 ++- src/MEDMEM/Makefile.in | 2 + src/MEDMEM/create_mesh_c2q4s2.c | 16 +- src/MEDMEM/create_mesh_c3h8q4.c | 20 +- src/MEDMEM_I/MEDMEM_FieldDouble_i.cxx | 60 +- src/MEDMEM_I/MEDMEM_FieldDouble_i.hxx | 9 +- src/MEDMEM_I/MEDMEM_FieldInt_i.cxx | 66 +- src/MEDMEM_I/MEDMEM_FieldInt_i.hxx | 9 +- src/MEDMEM_I/MEDMEM_FieldOf_i.hxx | 691 ------------- src/MEDMEM_I/MEDMEM_Field_i.cxx | 639 +++++++++++- src/MEDMEM_I/MEDMEM_Field_i.hxx | 139 +-- src/MEDMEM_I/MEDMEM_Group_i.cxx | 9 +- src/MEDMEM_I/MEDMEM_Med_i.cxx | 71 +- src/MEDMEM_I/MEDMEM_Mesh_i.cxx | 206 ++-- src/MEDMEM_I/MEDMEM_Mesh_i.hxx | 20 +- src/MEDMEM_I/MEDMEM_Support_i.cxx | 80 +- src/MEDMEM_I/MEDMEM_Support_i.hxx | 14 +- src/MEDMEM_I/Makefile.in | 5 +- src/MEDMEM_SWIG/libMEDMEM_Swig.i | 51 +- src/MEDMEM_SWIG/testMedMemGeneral.py | 77 +- src/Makefile.in | 2 +- src/MedClient/src/CONNECTIVITYClient.cxx | 9 +- src/MedClient/src/COORDINATEClient.cxx | 12 +- src/MedClient/src/FIELDClient.cxx | 106 +- src/MedClient/src/FIELDClient.hxx | 71 +- src/MedClient/src/FIELDDOUBLEClient.cxx | 26 + src/MedClient/src/FIELDDOUBLEClient.hxx | 15 + src/MedClient/src/FIELDINTClient.cxx | 26 + src/MedClient/src/FIELDINTClient.hxx | 15 + src/MedClient/src/MESHClient.cxx | 4 +- src/MedClient/src/Makefile.in | 9 +- src/MedClient/src/MakefileForTest | 52 + src/MedClient/src/MemorySpy.cxx | 96 ++ src/MedClient/src/MemorySpy.hxx | 25 + src/MedClient/src/README_medclient_test | 35 + src/MedClient/src/SUPPORTClient.cxx | 37 +- src/MedClient/src/SUPPORTClient.hxx | 2 + src/MedClient/src/TESTMEDCLIENT_Gen.idl | 18 + src/MedClient/src/TESTMEDCLIENT_Gen_i.cxx | 174 ++++ src/MedClient/src/TESTMEDCLIENT_Gen_i.hxx | 24 + src/MedClient/src/create_mesh_c2q4.c | 332 +++++++ src/MedClient/src/create_mesh_c2t3.c | 341 +++++++ src/MedClient/src/create_mesh_c3h8.c | 358 +++++++ src/MedClient/src/create_mesh_c3t4.c | 409 ++++++++ src/MedClient/src/libMEDClient.i | 43 +- src/MedClient/src/test_medclient.py | 27 + 105 files changed, 10397 insertions(+), 2320 deletions(-) create mode 100644 src/INTERPOLATION/MEDMEM_Interpolation.hxx create mode 100644 src/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx create mode 100644 src/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx.old create mode 100644 src/INTERPOLATION/MEDMEM_InterpolationTools.hxx create mode 100644 src/INTERPOLATION/MEDMEM_Mapping.hxx create mode 100644 src/INTERPOLATION/MEDMEM_MappingTools.hxx create mode 100644 src/INTERPOLATION/MEDMEM_WrapperCells.hxx create mode 100644 src/INTERPOLATION/MEDMEM_WrapperConnectivity.hxx create mode 100644 src/INTERPOLATION/MEDMEM_WrapperField.hxx create mode 100644 src/INTERPOLATION/MEDMEM_WrapperMesh.hxx create mode 100644 src/INTERPOLATION/MEDMEM_WrapperNodes.hxx create mode 100644 src/INTERPOLATION/MEDMEM_dTree.hxx create mode 100644 src/INTERPOLATION/MEDMEM_dTreeSommet.hxx create mode 100644 src/INTERPOLATION/Makefile.in create mode 100644 src/INTERPOLATION/UseCaseInterpolationts.cxx create mode 100644 src/INTERPOLATION/UseCaseInterpolationwots.cxx create mode 100644 src/INTERPOLATION/UseCaseMapping.cxx create mode 100644 src/INTERPOLATION/UseCaseWrapper_Maillage.cxx create mode 100644 src/INTERPOLATION/UseCasedTree.cxx create mode 100644 src/INTERPOLATION/create_mesh_interpolation.c create mode 100644 src/INTERPOLATION/test_MEDMEM_Interpolation.cxx create mode 100644 src/INTERPOLATION/test_MEDMEM_InterpolationFlipBack.cxx create mode 100644 src/INTERPOLATION/test_MEDMEM_InterpolationFromMesh_toMesh.cxx create mode 100644 src/INTERPOLATION/test_MEDMEM_InterpolationRecopieMaillage.cxx create mode 100644 src/INTERPOLATION/test_MEDMEM_InterpolationSansRecopieMaillage.cxx create mode 100644 src/INTERPOLATION/test_MEDMEM_InterpolationTimeStep.cxx create mode 100644 src/MEDMEM/MEDMEM_DriverFactory.cxx create mode 100644 src/MEDMEM/MEDMEM_DriverFactory.hxx delete mode 100644 src/MEDMEM_I/MEDMEM_FieldOf_i.hxx create mode 100644 src/MedClient/src/FIELDDOUBLEClient.cxx create mode 100644 src/MedClient/src/FIELDDOUBLEClient.hxx create mode 100644 src/MedClient/src/FIELDINTClient.cxx create mode 100644 src/MedClient/src/FIELDINTClient.hxx create mode 100644 src/MedClient/src/MakefileForTest create mode 100644 src/MedClient/src/MemorySpy.cxx create mode 100644 src/MedClient/src/MemorySpy.hxx create mode 100644 src/MedClient/src/README_medclient_test create mode 100644 src/MedClient/src/TESTMEDCLIENT_Gen.idl create mode 100755 src/MedClient/src/TESTMEDCLIENT_Gen_i.cxx create mode 100644 src/MedClient/src/TESTMEDCLIENT_Gen_i.hxx create mode 100644 src/MedClient/src/create_mesh_c2q4.c create mode 100644 src/MedClient/src/create_mesh_c2t3.c create mode 100644 src/MedClient/src/create_mesh_c3h8.c create mode 100644 src/MedClient/src/create_mesh_c3t4.c create mode 100644 src/MedClient/src/test_medclient.py diff --git a/src/INTERPOLATION/MEDMEM_Interpolation.hxx b/src/INTERPOLATION/MEDMEM_Interpolation.hxx new file mode 100644 index 000000000..d9aea1d85 --- /dev/null +++ b/src/INTERPOLATION/MEDMEM_Interpolation.hxx @@ -0,0 +1,378 @@ +# ifndef INTERPOLATION_HXX +# define INTERPOLATION_HXX + +//template < class T> class FIELD; +//template < int > class Wrapper_Nuage; +//template < int > class Wrapper_Noeud; +//template class dTree; + +#include +#include "utilities.h" +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" + +#include "MEDMEM_InterpolationHighLevelObjects.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Field.hxx" + +namespace MEDMEM { +class MESH; + +template class INTERPOLATION +{ +protected: + + FIELD * _fromField; + FIELD * _toField; + MESH * _fromMesh; + MESH * _toMesh; + + Meta_Wrapper * _fromWrapper; + Meta_Wrapper * _toWrapper; + + Meta_Mapping * _mapping; + +// only used when multi timestep are interpolated +// but always coherent + int _iType; + int _isConvexFromMesh; + +public : + + void init(); + + // Initialize INTERPOLATION in order to get : + // 1- the node number in the MESH which + // is the nearest from a given one ( use method : getNearestNode( double * node ) ); + // 2- the cell number (if exists) in the MESH which + // contains a specified node ( use method : getContainingCell ( double * node) ) + INTERPOLATION(const MESH & fromMesh ); + // Initialize INTERPOLATION in order to get : + // 1- the complete mapping ( use methode : getMapping() ) + // 2- the functionalities above + INTERPOLATION(const MESH & fromMesh,const MESH & toMesh ); + // Initialize INTERPOLATION in order to get the interpolation of on + // Moreover, all the others functionalities are so available + INTERPOLATION(const FIELD & fromField, const MESH & toMesh); + + ~INTERPOLATION( ); + + // Get the node number in the MESH which is the nearest from a given one + int getNearestNode ( double * node ); + // Get the cell number (if exists) in the MESH which contains a specified node + int getContainingCell ( double * node , int beginingCell=0, int flagIsConvexMesh=0 ); + // Get the complete mapping, defaultly, fromMesh is supposed to be non-convex, if it is false, set flagIsConvexMesh to 1 + vector getMapping ( int flagIsConvexMesh=0 ); + // Get the interpolated field toField + FIELD * interpolate( /*med_interpolation_type*/ int itype,int flagIsConvexFromMesh=0); + // reset the parameters in order not to redo the mapping (if the mesh are identical) + // and then get the interpoated field toField + // this method is specifictly used on multi-timestep (or order number) fields + // it has only to be used after the first step, the interpolation paramaters are the same for every step + FIELD * interpolateNextStep(const FIELD &nextFromField ,int & flagNewMapping); + +}; + +template void INTERPOLATION::init() { + + const char * LOC = "INTERPOLATION::init(): "; + + BEGIN_OF(LOC); + _fromField = ( FIELD * ) NULL; + _toField = ( FIELD * ) NULL; + _fromMesh = ( MESH * ) NULL; + _toMesh = ( MESH * ) NULL; + _fromWrapper = ( Meta_Wrapper * ) NULL; + _toWrapper = ( Meta_Wrapper * ) NULL; + _mapping = ( Meta_Mapping * ) NULL; + _iType = UNDEFINED ; + _isConvexFromMesh = UNDEFINED ; + END_OF(LOC); +} + + +template INTERPOLATION::INTERPOLATION(const MESH & fromMesh ) { + + const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh ) : "; + BEGIN_OF(LOC); + + init(); + + _fromMesh=const_cast (&fromMesh); + + if (! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ; + + int spaceDimension = _fromMesh->getSpaceDimension(); + if (spaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ; + + _fromWrapper = new Meta_Wrapper(_fromMesh->getNumberOfNodes(), + const_cast (_fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (_fromMesh->getConnectivityptr()) + ); + + _mapping = new Meta_Mapping (_fromWrapper); + + END_OF(LOC); +}; + +template INTERPOLATION::INTERPOLATION(const MESH & fromMesh,const MESH & toMesh ) { + + const char * LOC = "INTERPOLATION::INTERPOLATION(MESH * fromMesh,,const MESH & toMesh) : "; + BEGIN_OF(LOC); + + init(); + + _fromMesh = const_cast ( &fromMesh ); + _toMesh = const_cast ( &toMesh ); + + if (! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ; + if (! _toMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toMesh is a NULL pointer !")) ; + + int fromSpaceDimension = _fromMesh->getSpaceDimension(); + int toSpaceDimension = _toMesh->getSpaceDimension(); + + if (fromSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _fromMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ; + if ( toSpaceDimension != DIMENSION ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"The spaceDimension of mesh |" << _toMesh->getName() << "| is |" << spaceDimension << "| and should be |" << DIMENSION << "|" << endl)) ; + + _fromWrapper = new Meta_Wrapper(_fromMesh->getNumberOfNodes(), + const_cast (_fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (_fromMesh->getConnectivityptr()) + ); + + _toWrapper = new Meta_Wrapper(_toMesh->getNumberOfNodes(), + const_cast (_toMesh->getCoordinates(MED_FULL_INTERLACE)) + ); + + _mapping = new Meta_Mapping (_fromWrapper); + + END_OF(LOC); +}; + +template INTERPOLATION::INTERPOLATION(const FIELD & fromField,const MESH & toMesh) { + + const char * LOC = "INTERPOLATION(const FIELD & field,const MESH & toMesh) : "; + BEGIN_OF(LOC); + + init(); + + _toMesh = const_cast(&toMesh); + _fromField = const_cast *>(&fromField); + + if ( ! _toMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toMesh is a NULL pointer !")) ; + if ( ! _fromField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"field is a NULL pointer !")) ; + + _fromMesh = _fromField->getSupport()->getMesh(); + + if ( ! _fromMesh ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromMesh is a NULL pointer !")) ; + + _fromWrapper = new Meta_Wrapper(_fromMesh->getNumberOfNodes(), + const_cast (_fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (_fromMesh->getConnectivityptr()), + const_cast *>(_fromField) + ); + + + _toWrapper = new Meta_Wrapper(_toMesh->getNumberOfNodes(), + const_cast (_toMesh->getCoordinates(MED_FULL_INTERLACE)) + ); + + + _mapping = new Meta_Mapping (_fromWrapper); + + + END_OF(LOC); +}; + +template INTERPOLATION::~INTERPOLATION() +{ + if ( _fromWrapper ) delete _fromWrapper ; + if ( _toWrapper ) delete _toWrapper ; + if ( _mapping ) delete _mapping ; +}; + +template int INTERPOLATION::getNearestNode( double * node ) { + + const char * LOC = "INTERPOLATION::getNearestNode( double * node ) "; + + BEGIN_OF(LOC); + + if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ; + + return _mapping->Donne_dTree()->trouve_plus_proche_point(Wrapper_Noeud (node) ); + + END_OF(LOC); + +}; + +template int INTERPOLATION::getContainingCell ( double * node , int beginingCell, int flagIsConvexMesh ) { + + const char * LOC = "INTERPOLATION::getContainingCell( double * node ) "; + + BEGIN_OF(LOC); + + if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ; + + _isConvexFromMesh=flagIsConvexMesh; + + _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh); + + return _mapping->Trouve_Maille_Contenant_Noeud(node,beginingCell,flagIsConvexMesh); + + END_OF(LOC); + +}; + +template vector INTERPOLATION::getMapping ( int flagIsConvexMesh ) { + + const char * LOC = "INTERPOLATION::getMapping( ) "; + + BEGIN_OF(LOC); + + if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ; + if ( ! _toWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toWrapper is a NULL pointer !")) ; + + _isConvexFromMesh=flagIsConvexMesh; + + _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh); + + return _mapping->Get_Mapping(); + + END_OF(LOC); + +}; + +template FIELD * INTERPOLATION::interpolate(int itype,int flagIsConvexFromMesh) { + + const char * LOC = "INTERPOLATION::interpolate(int itype,int flagIsConvexFromMesh) "; + + BEGIN_OF(LOC); + + if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !")) ; + if ( ! _toWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toWrapper is a NULL pointer !")) ; + if ( ! _fromField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromField is a NULL pointer !")) ; + + _iType=itype; + + _isConvexFromMesh=flagIsConvexFromMesh; + + _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh); + + Wrapper_Nuage_Noeud * toNodes = _toWrapper->Get_Nuage_Noeuds(); + + Wrapper_MED_Field resultat; + + /* + cout<<"Mapping"<affiche(); + cout<<"Mailles"<Get_Maillage()->DONNE_POINTEUR_NUAGEMAILLE()->affiche(); + cout<<"Noeuds"<Get_Nuage_Noeuds()->affiche(); + */ + + switch (_iType) + { + case 0 : // INTERPOLATION P0 + cout<<"Avant ="<,DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes); + break; + case 1 : // INTERPOLATION P-Hybride (Interpole avec la fonction d'interpolation naturelle de la maille contenant le point) + resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_Hybride,DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes); + break; + case 2 : // INTERPOLATION (P/Q) 1 forcée (Interpole avec la fonction élément fini de la maille de degré 1 -meme si la maille est de degré supérieur-) + resultat=Meta_Interpolateur< Meta_Calcul_Interpolation_Hybride_P1, DIMENSION >(_mapping,_fromWrapper).Perform_Interpolation(toNodes); + break; + default : + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Interpolation type "<; + + _toField->setName ( _fromField->getName() ); + _toField->setDescription ( _fromField->getDescription() ); + _toField->setNumberOfComponents ( _fromField->getNumberOfComponents() ); + _toField->setNumberOfValues ( _toMesh ->getNumberOfNodes() ); + _toField->setComponentsNames ( _fromField->getComponentsNames() ); + _toField->setComponentsDescriptions ( _fromField->getComponentsDescriptions() ); + _toField->setMEDComponentsUnits ( _fromField->getMEDComponentsUnits() ); + _toField->setIterationNumber ( _fromField->getIterationNumber() ); + _toField->setTime ( _fromField->getTime() ); + _toField->setOrderNumber ( _fromField->getOrderNumber() ); + _toField->setValueType ( MED_EN::MED_REEL64 ); + + SUPPORT * mySupport(new SUPPORT(_toMesh,"support",MED_NODE)); + _toField->setSupport(mySupport); + + _toField->allocValue(_toField->getNumberOfComponents(),_toField->getNumberOfValues()); + + _toField->setValue(MED_FULL_INTERLACE,resultat.Get_Valeurs()); + + _toWrapper->Construit_Wrapper_Champ(_toField); + + return _toField; + + END_OF(LOC); + +}; + +template FIELD * INTERPOLATION::interpolateNextStep(const FIELD & nextFromField, int & flagNewMapping) { + + const char * LOC = "INTERPOLATION::interpolateNextStep(int itype,int flagIsConvexFromMesh) "; + + BEGIN_OF(LOC); + + if ( ! _mapping ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"mapping is a NULL pointer !" )); + if ( ! _toWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toWrapper is a NULL pointer !" )) ; + if ( ! _fromWrapper ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromWrapper is a NULL pointer !" )) ; + if ( ! _fromField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"fromField is a NULL pointer !" )) ; + + + if ( ! _toField ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"toField is a NULL pointer, wrong use of interpolateNextStep" )) ; + if ( _iType==UNDEFINED ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"_iType is not defined, wrong use of interpolateNextStep" )) ; + if ( _isConvexFromMesh==UNDEFINED ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"_isConvexFromMesh is not defined, wrong use of interpolateNextStep" )) ; + + // delete _toField; ???????????????????????????? + + // if the mesh are identical, the mapping is the same, if not, the mapping has to be re-calculated + if (nextFromField.getSupport()->getMesh()->getName()!=_fromMesh->getName()) + { + + flagNewMapping=1; + + delete _mapping; + delete _fromWrapper; + + _fromField = const_cast *>(&nextFromField); + + _fromMesh = _fromField->getSupport()->getMesh(); + + _fromWrapper = new Meta_Wrapper(_fromMesh->getNumberOfNodes(), + const_cast (_fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (_fromMesh->getConnectivityptr()), + const_cast *>(_fromField) + ); + _mapping = new Meta_Mapping (_fromWrapper); + + _mapping->Cree_Mapping(_toWrapper,_isConvexFromMesh); + + } + else + { + + flagNewMapping=0; + + _fromField = const_cast *>(&nextFromField); + _fromWrapper->Change_Champ(const_cast *>(_fromField)); + } + + return interpolate(_iType,_isConvexFromMesh); + +}; + +}; + +#endif + + diff --git a/src/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx b/src/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx new file mode 100644 index 000000000..6a50ea4fc --- /dev/null +++ b/src/INTERPOLATION/MEDMEM_InterpolationHighLevelObjects.hxx @@ -0,0 +1,453 @@ +#ifndef MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX +#define MEDMEM_INTERPOLATION_HIGHLEVEL_OBJECTS_HXX + +#include "MEDMEM_Connectivity.hxx" +#include "MEDMEM_WrapperConnectivity.hxx" +#include "MEDMEM_dTree.hxx" +#include "MEDMEM_WrapperNodes.hxx" +#include "MEDMEM_WrapperMesh.hxx" +#include "MEDMEM_WrapperCells.hxx" +#include "MEDMEM_Mapping.hxx" +#include "MEDMEM_WrapperField.hxx" +#include "MEDMEM_InterpolationTools.hxx" + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +template class Meta_Wrapper; + +/*********************************************************/ +/* */ +/* Meta_dTree */ +/* */ +/*********************************************************/ + +template class Meta_dTree : public dTree,Wrapper_Nuage_Noeud,DIMENSION> +{ +protected : + // PATCH + Wrapper_Nuage_Noeud * noeuds; + // FIN PATCH +public : + // PATCH + Meta_dTree():noeuds(NULL) {} + ~Meta_dTree() {if (noeuds) delete noeuds;} + Meta_dTree(int nbr_noeuds,double *coord):dTree,Wrapper_Nuage_Noeud,DIMENSION>(noeuds=new Wrapper_Nuage_Noeud(nbr_noeuds,coord)) {} + inline int trouve_plus_proche_point_bourrin(double *node); + // FIN PATCH + inline int trouve_plus_proche_point(double * node); +}; + +/*********************************************************/ +/* */ +/* Meta_Nuage_Maille */ +/* */ +/*********************************************************/ + + +class Meta_Nuage_Maille : public Wrapper_Nuage_Maille +{ +protected : + Wrapper_Med_Connectivity * connectivite_med; +public : + Meta_Nuage_Maille(CONNECTIVITY * connmed); + Meta_Nuage_Maille():connectivite_med(NULL) {} + ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;} +}; + +/*********************************************************/ +/* */ +/* Meta_Maillage */ +/* */ +/*********************************************************/ + + +typedef Wrapper_Maillage Meta_Maillage; + +/*********************************************************/ +/* */ +/* Meta_Mapping */ +/* */ +/*********************************************************/ + +template class Meta_Mapping : public Mapping,Wrapper_Noeud,DIMENSION> +{ +public : + Meta_Mapping(Meta_Wrapper * MW):Mapping,Wrapper_Noeud,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),NULL) {} + Meta_Mapping(Meta_Wrapper * MW,Meta_Wrapper * TWB):Mapping,Wrapper_Noeud,DIMENSION>(MW->Get_Maillage(),MW->Get_Nuage_Noeuds(),TWB->Get_Nuage_Noeuds()) {} + // PATCH + inline void Cree_Mapping(Meta_Wrapper * MWB, int flag_convexe) {Mapping,Wrapper_Noeud,DIMENSION>::Cree_Mapping(MWB->Get_Nuage_Noeuds(),flag_convexe);} + inline void Cree_Mapping(int flag_convexe) {Mapping,Wrapper_Noeud,DIMENSION>::Cree_Mapping(flag_convexe);} + inline vector & Get_Mapping() {return Mapping,Wrapper_Noeud,DIMENSION>::Get_Mapping();} + //FIN PATCH + inline int Trouve_Maille_Contenant_Noeud(double * node,int num_maille, int flag_convexe=0); +}; + +/*********************************************************/ +/* */ +/* Meta_Wrapper */ +/* */ +/*********************************************************/ + + +template class Meta_Wrapper +{ +protected : + Wrapper_Nuage_Noeud * noeuds ; + Meta_Nuage_Maille * mailles ; + Meta_Maillage * maillage ; + Wrapper_MED_Field * champ ; + + void init( ){noeuds=NULL;mailles=NULL;maillage=NULL;champ=NULL;} +public : + Meta_Wrapper():noeuds(NULL),mailles(NULL),maillage(NULL),champ(NULL){} + ~Meta_Wrapper(); + inline void Construit_Wrapper_Nuage_Noeud ( int nn, double * nodes ); + inline void Construit_Wrapper_Nuage_Maille ( CONNECTIVITY * connmed ); + inline void Construit_Wrapper_Maillage ( void ); + inline void Construit_Wrapper_Champ ( const FIELD * medfield ); + Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, int flag_maillage=1); + Meta_Wrapper(int nn,double *nodes); + // defaultly, the connectivity (neighbouhood and so like) is built, + // Set flag_mesh to 0 if you don't want these informations to be built + Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, const FIELD * c,int flag_mesh=1); + // fonctions d'acces sures + inline Wrapper_Nuage_Noeud * Get_Nuage_Noeuds ( void ); + inline Meta_Nuage_Maille * Get_Nuage_Mailles ( void ); + inline Meta_Maillage * Get_Maillage ( void ); + inline Wrapper_MED_Field * Get_Champ ( void ); + inline void Change_Champ ( const FIELD * medfield ); +}; + +/*********************************************************/ +/* */ +/* Meta_Calcul_Interpolation_Hybride */ +/* */ +/*********************************************************/ + +template class Meta_Calcul_Interpolation_Hybride : public Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille> +{ +public : + Meta_Calcul_Interpolation_Hybride(Meta_Wrapper * MW):Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {} + Valeur operator() (Wrapper_Noeud & node, int num_maille){return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>::operator()(node,num_maille);} + Valeur operator() (double * node, int num_maille) + { + static Wrapper_Noeud tmp; + tmp.positionne(node); + return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(tmp,num_maille); + } +}; + +/*********************************************************/ +/* */ +/* Meta_Calcul_Interpolation_Hybride_P1 */ +/* */ +/*********************************************************/ + +template class Meta_Calcul_Interpolation_Hybride_P1 : public Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille> +{ +public : + Meta_Calcul_Interpolation_Hybride_P1(Meta_Wrapper * MW) + { + + Wrapper_Nuage_Noeud * nn = MW->Get_Nuage_Noeuds(); + Meta_Nuage_Maille * nm = MW->Get_Nuage_Mailles(); + Wrapper_MED_Field * c = MW->Get_Champ(); + + mailles=nm; + + fonctions[MED_TRIA3 ]=new Calcul_Interpolation_Tria3 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_QUAD4 ]=new Calcul_Interpolation_Quad4 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_PENTA6 ]=new Calcul_Interpolation_Penta6 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 ,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(nn,nm,c); + fonctions[MED_TRIA6 ]=fonctions[MED_TRIA3 ]; + fonctions[MED_QUAD8 ]=fonctions[MED_QUAD4 ]; + fonctions[MED_TETRA10]=fonctions[MED_TETRA4 ]; + fonctions[MED_HEXA20 ]=fonctions[MED_HEXA8 ]; + fonctions[MED_PENTA15]=fonctions[MED_PENTA6 ]; + fonctions[MED_PYRA13 ]=fonctions[MED_PYRA5 ]; + } + Valeur operator() (Wrapper_Noeud & node, int num_maille){return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>::operator()(node,num_maille);} + Valeur operator() (double * node, int num_maille) + { + static Wrapper_Noeud tmp; + tmp.positionne(node); + return Calcul_Hybride,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(tmp,num_maille); + } +}; + +/*********************************************************/ +/* */ +/* Meta_Calcul_Interpolation_P0 */ +/* */ +/*********************************************************/ + +template class Meta_Calcul_Interpolation_P0 : public Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille> +{ +public : + Meta_Calcul_Interpolation_P0(Meta_Wrapper * MW):Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(MW->Get_Nuage_Noeuds(),MW->Get_Nuage_Mailles(),MW->Get_Champ()) {} + Valeur operator() (Wrapper_Noeud & node, int num_maille){return Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>::operator()(node,num_maille);} + Valeur operator() (double * node, int num_maille) + { + static Wrapper_Noeud tmp; + tmp.positionne(node); + return Calcul_Interpolation_P0,Wrapper_Nuage_Noeud,Wrapper_Noeud,Meta_Nuage_Maille>(tmp,num_maille); + } +}; + +/*********************************************************/ +/* */ +/* Meta_Interpolateur */ +/* */ +/*********************************************************/ + +template class Meta_Interpolateur +{ +protected : + FONCTEUR * fct; + Meta_Mapping * mapping; + Meta_Wrapper * fromWrapper; +public : + Meta_Interpolateur():fct(NULL),mapping(NULL),fromWrapper(NULL) {} + Meta_Interpolateur(Meta_Mapping * map, Meta_Wrapper * mw):mapping(map),fromWrapper(mw),fct(new FONCTEUR(mw)){} + ~Meta_Interpolateur() {if (fct) delete fct;} + Wrapper_MED_Field Perform_Interpolation(Wrapper_Nuage_Noeud * toNodes) + { + int i; + + int ni=0; + int ne=0; + + int nbr_composantes = fromWrapper->Get_Champ()->Get_Nbr_Composantes(); + int nbr_valeurs = toNodes->SIZE(); + + double * valeurs=new double[nbr_valeurs*nbr_composantes]; + + Wrapper_MED_Field resultat(nbr_valeurs,nbr_composantes,valeurs); + + int nlpp,nmc; + + for (i=0;i OK ! "< inline void Meta_Wrapper::Construit_Wrapper_Nuage_Maille ( CONNECTIVITY * connmed ) + { + if (connmed) mailles=new Meta_Nuage_Maille(connmed); + else + { + cerr<<"Meta_Wrapper : CONNECTIVITY vide passée en argument au constructeur"< inline void Meta_Wrapper::Construit_Wrapper_Maillage ( void ) + { + if (mailles==NULL) + { + cerr<<"Meta_Wrapper : Le nuage de maille n'a pas été initialisé !"<SIZE()); + } +template inline void Meta_Wrapper::Construit_Wrapper_Champ ( const FIELD * medfield ) + { + if (medfield) champ=new Wrapper_MED_Field(medfield); + else + { + cerr<<"Meta_Wrapper : FIELD MED vide passé en argument au constructeur"< inline void Meta_Wrapper::Change_Champ ( const FIELD * medfield ) + { + if (medfield) + { + if (champ) delete champ; + champ=new Wrapper_MED_Field(medfield); + } + else + { + cerr<<"Meta_Wrapper : FIELD MED vide passé en argument Change_Champ"< Meta_Wrapper::Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, int flag_maillage) + { + init(); + Construit_Wrapper_Nuage_Noeud(nn,nodes); + Construit_Wrapper_Nuage_Maille(connmed); + if (flag_maillage) Construit_Wrapper_Maillage(); + } +template Meta_Wrapper::Meta_Wrapper(int nn,double *nodes,CONNECTIVITY *connmed, const FIELD * c,int flag_maillage) + { + init(); + Construit_Wrapper_Nuage_Noeud(nn,nodes); + Construit_Wrapper_Nuage_Maille(connmed); + if (flag_maillage) Construit_Wrapper_Maillage(); + Construit_Wrapper_Champ(c); + } +template Meta_Wrapper::Meta_Wrapper(int nn,double *nodes) + { + init(); + Construit_Wrapper_Nuage_Noeud(nn,nodes); + } +template inline Wrapper_Nuage_Noeud * Meta_Wrapper::Get_Nuage_Noeuds ( void ) + { + if (noeuds) return noeuds; + else + { + cerr<<"Meta_Wrapper : Nuage noeuds demandé alors qu'il n'est pas construit !"< inline Meta_Nuage_Maille * Meta_Wrapper::Get_Nuage_Mailles ( void ) + { + if (mailles) return mailles ; + else + { + cerr<<"Meta_Wrapper : Nuage mailles demandé alors qu'il n'est pas construit !"< inline Meta_Maillage * Meta_Wrapper::Get_Maillage ( void ) + { + if (maillage) return maillage ; + else + { + cerr<<"Meta_Wrapper : Connectivitée maillage demandée alors qu'elle n'est pas construite !"< inline Wrapper_MED_Field * Meta_Wrapper::Get_Champ ( void ) + { + if (champ) return champ; + else + { + cerr<<"Meta_Wrapper : Champ demandé alors qu'il n'est pas construit !"< class Meta_dTree : public dTree,Wrapper_Nuage_Noeud,DIMENSION> +{ +protected : + Wrapper_Nuage_Noeud * nuagetmp; +public : + Meta_dTree(int nn,double * fullinterlace); + ~Meta_dTree() {if ((etat==DTREE_RACINE)&&(nuagetmp)) delete nuagetmp;} + inline int trouve_plus_proche_point(double *node); +}; + +class Meta_Nuage_Maille : public Wrapper_Nuage_Maille +{ +protected : + Wrapper_Med_Connectivity * connectivite_med; +public : + Meta_Nuage_Maille(CONNECTIVITY * connmed); + Meta_Nuage_Maille():Wrapper_Nuage_Maille(connectivite_med=new Wrapper_Med_Connectivity) {} + ~Meta_Nuage_Maille() {if (connectivite_med) delete connectivite_med;} +}; + + +typedef Wrapper_Maillage Meta_Maillage; + +template class Meta_Mapping : public Mapping,Wrapper_Noeud,DIMENSION> +{ +protected : + Wrapper_Nuage_Noeud * wrapping_nuage_source; + Wrapper_Nuage_Noeud * wrapping_nuage_cible; +public : + Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc); + ~Meta_Mapping() {if (wrapping_nuage_source) delete wrapping_nuage_source;if (wrapping_nuage_cible) delete wrapping_nuage_cible;} + inline int Trouve_Maille_Contenant_Noeud(double * node,int num_maille, int flag_convexe=0); + double donne_valeur_interpolee_P1(double * node,vector vals); +}; + +// CODE + +template Meta_dTree::Meta_dTree(int nn,double * fullinterlace) +:dTree,Wrapper_Nuage_Noeud,DIMENSION> +(nuagetmp=new Wrapper_Nuage_Noeud(nn,fullinterlace)) + { + } + +template inline int Meta_dTree::trouve_plus_proche_point(double *node) + { + static Wrapper_Noeud nodetmp; + nodetmp.positionne(node); + return dTree,Wrapper_Nuage_Noeud,DIMENSION>::trouve_plus_proche_point(Wrapper_Noeud(nodetmp)); + } + +//* +Meta_Nuage_Maille::Meta_Nuage_Maille(CONNECTIVITY * conmed):Wrapper_Nuage_Maille(connectivite_med=new Wrapper_Med_Connectivity(conmed)) + { + } +//*/ + +template Meta_Mapping::Meta_Mapping(Meta_Maillage * mb,double * noeudssource,int ns,double * noeudscible,int nc) +:Mapping,Wrapper_Noeud,DIMENSION> +(mb, +wrapping_nuage_source=new Wrapper_Nuage_Noeud(ns,noeudssource), +wrapping_nuage_cible=new Wrapper_Nuage_Noeud(nc,noeudscible)) + { + } + +template inline int Meta_Mapping::Trouve_Maille_Contenant_Noeud(double * node,int num_maille,int flag_convexe) + { + int interdit=num_maille; + int max_loop=100; + int nme=0; + static Wrapper_Noeud nodetmp; + nodetmp.positionne(node); + return Mapping,Wrapper_Noeud,DIMENSION>::Trouve_Maille_Contenant_Point_Mth_Co(nodetmp,num_maille,interdit,max_loop,nme,flag_convexe); + } +template double Meta_Mapping::donne_valeur_interpolee_P1(double * node,vector vals) + { + int num_maille_contenant=Trouve_Maille_Contenant_Noeud(node,0); + double valeur_interpol=0; + vector valeurs=CB->Calcule_Coord_Baryc(num_maille_contenant,node); + int i; + int num_som; + for (i=0;i +#define _PARAM_ CHAMP,VALEURCHAMP,NUAGENOEUD,NOEUD,NUAGEMAILLE + +// ces macros définissent pour une face carrée plane la fonction projection sur cette face, non normalisée, la numérotation est dans le cas d'un hexaedre +#define face2367(x,y,z) ((x6*(-y2 + y3) + x3*(y2 - y6) + x2*(-y3 + y6))*z - x6*y3*z2 + x3*y6*z2 + x6*y2*z3 - x2*y6*z3 - x3*y2*z6 + x2*y3*z6 + y*(x6*(z2 - z3) + x2*(z3 - z6) + x3*(-z2 + z6)) + x*(y6*(-z2 + z3) + y3*(z2 - z6) + y2*(-z3 + z6))) +#define face4567(x,y,z) ((x6*(-y4 + y5) + x5*(y4 - y6) + x4*(-y5 + y6))*z - x6*y5*z4 + x5*y6*z4 + x6*y4*z5 - x4*y6*z5 - x5*y4*z6 + x4*y5*z6 + y*(x6*(z4 - z5) + x4*(z5 - z6) + x5*(-z4 + z6)) + x*(y6*(-z4 + z5) + y5*(z4 - z6) + y4*(-z5 + z6))) +#define face1256(x,y,z) ((x5*(-y1 + y2) + x2*(y1 - y5) + x1*(-y2 + y5))*z - x5*y2*z1 + x2*y5*z1 + x5*y1*z2 - x1*y5*z2 - x2*y1*z5 + x1*y2*z5 + y*(x5*(z1 - z2) + x1*(z2 - z5) + x2*(-z1 + z5)) + x*(y5*(-z1 + z2) + y2*(z1 - z5) + y1*(-z2 + z5))) +#define face0347(x,y,z) ((x4*(-y0 + y3) + x3*(y0 - y4) + x0*(-y3 + y4))*z - x4*y3*z0 + x3*y4*z0 + x4*y0*z3 - x0*y4*z3 - x3*y0*z4 + x0*y3*z4 + y*(x4*(z0 - z3) + x0*(z3 - z4) + x3*(-z0 + z4)) + x*(y4*(-z0 + z3) + y3*(z0 - z4) + y0*(-z3 + z4))) +#define face0145(x,y,z) ((x4*(-y0 + y1) + x1*(y0 - y4) + x0*(-y1 + y4))*z - x4*y1*z0 + x1*y4*z0 + x4*y0*z1 - x0*y4*z1 - x1*y0*z4 + x0*y1*z4 + y*(x4*(z0 - z1) + x0*(z1 - z4) + x1*(-z0 + z4)) + x*(y4*(-z0 + z1) + y1*(z0 - z4) + y0*(-z1 + z4))) +#define face0123(x,y,z) ((x2*(-y0 + y1) + x1*(y0 - y2) + x0*(-y1 + y2))*z - x2*y1*z0 + x1*y2*z0 + x2*y0*z1 - x0*y2*z1 - x1*y0*z2 + x0*y1*z2 + y*(x2*(z0 - z1) + x0*(z1 - z2) + x1*(-z0 + z2)) + x*(y2*(-z0 + z1) + y1*(z0 - z2) + y0*(-z1 + z2))) +// des macros définissent pour une face triangulaire orientée vers l'extérieur de la maille la fonction de projection, non normalisée ( =(12^13).1M ) +#define face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z) ( ((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1))*(x-x1)+((z2-z1)*(x3-x1)-(x2-x1)*(z3-z1))*(y-y1)+((x2-x1)*(y3-y1)-(y2-y1)*(x3-x1))*(z-z1) ) +#define projection(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0,x,y,z) (face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z)/face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0)) + +// DECLARATION + +_TEMPLATE_ class Calcul_Interpolation +{ +protected : + NUAGENOEUD * noeuds; + NUAGEMAILLE * mailles; + CHAMP * champ; +public : + Calcul_Interpolation():noeuds(NULL),mailles(NULL),champ(NULL) {} + Calcul_Interpolation(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):noeuds(nn),mailles(nm),champ(c) {} + ~Calcul_Interpolation() {} + virtual VALEURCHAMP operator() (const NOEUD & n, int num_maille) {cerr<<"APPEL OPERATOR() DE LA CLASSE MERE CALCUL_INTERPOLATION => EXIT(-1)"< *> fonctions; +public : + Calcul_Hybride():mailles(NULL) {} + Calcul_Hybride(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c); + ~Calcul_Hybride() {} + VALEURCHAMP operator() (const NOEUD & n, int num_maille); +}; + +//CODE + +_TEMPLATE_ Calcul_Hybride<_PARAM_>::Calcul_Hybride(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):mailles(nm) + { + fonctions[MED_TRIA3 ]=new Calcul_Interpolation_Tria3 <_PARAM_>(nn,nm,c); + fonctions[MED_TRIA6 ]=new Calcul_Interpolation_Tria6 <_PARAM_>(nn,nm,c); + fonctions[MED_QUAD4 ]=new Calcul_Interpolation_Quad4 <_PARAM_>(nn,nm,c); + fonctions[MED_QUAD8 ]=new Calcul_Interpolation_Quad8 <_PARAM_>(nn,nm,c); + fonctions[MED_TETRA4 ]=new Calcul_Interpolation_Tetra4 <_PARAM_>(nn,nm,c); + fonctions[MED_TETRA10]=new Calcul_Interpolation_Tetra10<_PARAM_>(nn,nm,c); + fonctions[MED_HEXA8 ]=new Calcul_Interpolation_Hexa8 <_PARAM_>(nn,nm,c); + fonctions[MED_HEXA20 ]=new Calcul_Interpolation_Hexa20 <_PARAM_>(nn,nm,c); + fonctions[MED_PENTA6 ]=new Calcul_Interpolation_Penta6 <_PARAM_>(nn,nm,c); + fonctions[MED_PENTA15]=new Calcul_Interpolation_Penta15<_PARAM_>(nn,nm,c); + fonctions[MED_PYRA5 ]=new Calcul_Interpolation_Pyra5 <_PARAM_>(nn,nm,c); + fonctions[MED_PYRA13 ]=new Calcul_Interpolation_Pyra13 <_PARAM_>(nn,nm,c); + } + +_TEMPLATE_ VALEURCHAMP Calcul_Hybride<_PARAM_>::operator() (const NOEUD & n, int num_maille) + { + return fonctions[(*mailles)[num_maille].DONNE_TYPE_MED_MAILLE()]->operator()(n,num_maille); + } + +_TEMPLATE_ class Calcul_Interpolation_P0 : public Calcul_Interpolation<_PARAM_> +{ +public : Calcul_Interpolation_P0(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + return (*champ)[num_maille]; + } +}; +_TEMPLATE_ class Calcul_Interpolation_Tria3 : public Calcul_Interpolation<_PARAM_> +{ +public : Calcul_Interpolation_Tria3(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + int num0=(*mailles)[num_maille][0]; + int num1=(*mailles)[num_maille][1]; + int num2=(*mailles)[num_maille][2]; + + double x0=(*noeuds)[num0][0]; + double y0=(*noeuds)[num0][1]; + double x1=(*noeuds)[num1][0]; + double y1=(*noeuds)[num1][1]; + double x2=(*noeuds)[num2][0]; + double y2=(*noeuds)[num2][1]; + + VALEURCHAMP v0=(*champ)[num0]; + VALEURCHAMP v1=(*champ)[num1]; + VALEURCHAMP v2=(*champ)[num2]; + + double x=n[0]; + double y=n[1]; + + double lambda0=(y1-y2)*x+(x2-x1)*y+(x1*y2-x2*y1); + double lambda1=(y2-y0)*x+(x0-x2)*y+(x2*y0-x0*y2); + double lambda2=(y0-y1)*x+(x1-x0)*y+(x0*y1-x1*y0); + + double delta = (x2-x1)*y0+(x0-x2)*y1+(x1-x0)*y2; + + VALEURCHAMP retour(v0.SIZE()); + + retour=(1/delta)*(lambda0*v0+lambda1*v1+lambda2*v2); + + return retour; // + } +}; +_TEMPLATE_ class Calcul_Interpolation_Tria6 : public Calcul_Interpolation<_PARAM_> +{ +public : Calcul_Interpolation_Tria6(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + // ON SUPPOSE IMPLICITEMENT QUE LES NOEUDS SUPPLEMENTAIRES SONT BIEN DES NOEUDS MILIEUX + int num0 =(*mailles)[num_maille][0]; + int num1 =(*mailles)[num_maille][1]; + int num2 =(*mailles)[num_maille][2]; + int num01=(*mailles)[num_maille][3]; + int num12=(*mailles)[num_maille][4]; + int num20=(*mailles)[num_maille][5]; + + double x0=(*noeuds)[num0][0]; + double y0=(*noeuds)[num0][1]; + double x1=(*noeuds)[num1][0]; + double y1=(*noeuds)[num1][1]; + double x2=(*noeuds)[num2][0]; + double y2=(*noeuds)[num2][1]; + + VALEURCHAMP v0=(*champ)[num0]; + VALEURCHAMP v1=(*champ)[num1]; + VALEURCHAMP v2=(*champ)[num2]; + VALEURCHAMP v01=(*champ)[num01]; + VALEURCHAMP v12=(*champ)[num12]; + VALEURCHAMP v20=(*champ)[num20]; + + double x=n[0]; + double y=n[1]; + + double lambda0=(y1-y2)*x+(x2-x1)*y+(x1*y2-x2*y1); + double lambda1=(y2-y0)*x+(x0-x2)*y+(x2*y0-x0*y2); + double lambda2=(y0-y1)*x+(x1-x0)*y+(x0*y1-x1*y0); + + double delta = (x2-x1)*y0+(x0-x2)*y1+(x1-x0)*y2; + + + // VALEURCHAMP retour(v0.SIZE()); // + + return 2*(lambda0*lambda0*v0+ + lambda1*lambda1*v1+ + lambda2*lambda2*v2+ + 2*(lambda0*lambda1*v01+ + lambda1*lambda2*v12+ + lambda2*lambda0*v20))/(delta*delta)+ + (lambda0*v0+lambda1*v1+lambda2*v2)/(-delta); + + // return retour; // + } +}; +_TEMPLATE_ class Calcul_Interpolation_Quad4 : public Calcul_Interpolation<_PARAM_> +{ +public : Calcul_Interpolation_Quad4(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + int num0=(*mailles)[num_maille][0]; + int num1=(*mailles)[num_maille][1]; + int num2=(*mailles)[num_maille][2]; + int num3=(*mailles)[num_maille][3]; + + double x0=(*noeuds)[num0][0]; + double y0=(*noeuds)[num0][1]; + double x1=(*noeuds)[num1][0]; + double y1=(*noeuds)[num1][1]; + double x2=(*noeuds)[num2][0]; + double y2=(*noeuds)[num2][1]; + double x3=(*noeuds)[num3][0]; + double y3=(*noeuds)[num3][1]; + + VALEURCHAMP v0=(*champ)[num0]; + VALEURCHAMP v1=(*champ)[num1]; + VALEURCHAMP v2=(*champ)[num2]; + VALEURCHAMP v3=(*champ)[num3]; + + double x=n[0]; + double y=n[1]; + + + double mu0=-((x3*(y1-y2)+x1*(y2-y3)+x2*(y3-y1))*x*y+(x2*y2*(y1-y3)+x3*(-y1+y2)*y3+x1*y1*(y3-y2))*x+(x2*x3*(y2-y3)+x1*(x2*(y1-y2)+x3*(y3-y1)))*y+(x2*x3*y1*(y3-y2)+x1*(x3*y2*(y1-y3)+x2*(y2-y1)*y3))); + double mu1=(x0*(y2-y3)+x2*(y3-y0)+x3*(y0-y2))*x*y+(x3*y3*(y2-y0)+x0*(-y2+y3)*y0+x2*y2*(y0-y3))*x+(x3*x0*(y3-y0)+x2*(x3*(y2-y3)+x0*(y0-y2)))*y+(x2*x0*y2*(y0-y2)+x2*(x0*y2*(y2-y0)+x3*(y3-y2)*y0)); + double mu2=-((x1*(y3-y0)+x3*(y0-y1)+x0*(y1-y3))*x*y+(x0*y0*(y3-y1)+x1*(-y3+y0)*y1+x3*y3*(y1-y0))*x+(x0*x1*(y0-y1)+x3*(x0*(y3-y0)+x1*(y1-y3)))*y+(x3*x1*y3*(y1-y2)+x3*(x1*y2*(y3-y1)+x0*(y0-y3)*y1))); + double mu3=(x2*(y0-y1)+x0*(y1-y2)+x1*(y2-y0))*x*y+(x1*y1*(y0-y2)+x2*(-y0+y1)*y2+x0*y0*(y2-y1))*x+(x1*x2*(y1-y2)+x0*(x1*(y0-y1)+x2*(y2-y0)))*y+(x0*x2*y0*(y2-y2)+x0*(x2*y2*(y0-y2)+x1*(y1-y0)*y2)); + + double delta=(y0-y2)*(y1-y3)*(x0*x2+x1*x3)-(x1*x2+x0*x3)*(y1-y2)*(y0-y3)-(x0*x1+x2*x3)*(y0-y1)*(y2-y3); + + /* + cout<<" ### Pour ( "< +{ +public : Calcul_Interpolation_Tetra4(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + int num0=(*mailles)[num_maille][0]; + int num1=(*mailles)[num_maille][1]; + int num2=(*mailles)[num_maille][2]; + int num3=(*mailles)[num_maille][3]; + + double x0=(*noeuds)[num0][0]; + double y0=(*noeuds)[num0][1]; + double z0=(*noeuds)[num0][2]; + double x1=(*noeuds)[num1][0]; + double y1=(*noeuds)[num1][1]; + double z1=(*noeuds)[num1][2]; + double x2=(*noeuds)[num2][0]; + double y2=(*noeuds)[num2][1]; + double z2=(*noeuds)[num2][2]; + double x3=(*noeuds)[num3][0]; + double y3=(*noeuds)[num3][1]; + double z3=(*noeuds)[num3][2]; + + VALEURCHAMP v0=(*champ)[num0]; + VALEURCHAMP v1=(*champ)[num1]; + VALEURCHAMP v2=(*champ)[num2]; + VALEURCHAMP v3=(*champ)[num3]; + + double x=n[0]; + double y=n[1]; + double z=n[2]; + + double lambda0=face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z)/face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0); + double lambda1=face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x,y,z)/face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x1,y1,z1); + double lambda2=face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x,y,z)/face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x2,y2,z2); + double lambda3=face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x,y,z)/face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x3,y3,z3); + + VALEURCHAMP retour(v0.SIZE()); // + + retour=(lambda0*v0+lambda1*v1+lambda2*v2+lambda3*v3); + + return retour; // + } +}; +_TEMPLATE_ class Calcul_Interpolation_Tetra10 : public Calcul_Interpolation<_PARAM_> +{ +public : Calcul_Interpolation_Tetra10(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + // ON SUPPOSE IMPLICITEMENT QUE LES NOEUDS SUPPLEMENTAIRES SONT BIEN DES NOEUDS MILIEUX + int num0 =(*mailles)[num_maille][0]; + int num1 =(*mailles)[num_maille][1]; + int num2 =(*mailles)[num_maille][2]; + int num3 =(*mailles)[num_maille][3]; + int num01=(*mailles)[num_maille][4]; + int num02=(*mailles)[num_maille][6]; + int num03=(*mailles)[num_maille][7]; + int num12=(*mailles)[num_maille][5]; + int num13=(*mailles)[num_maille][8]; + int num23=(*mailles)[num_maille][9]; + + double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2]; + double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2]; + double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2]; + double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2]; + + VALEURCHAMP v0=(*champ)[num0]; + VALEURCHAMP v1=(*champ)[num1]; + VALEURCHAMP v2=(*champ)[num2]; + VALEURCHAMP v3=(*champ)[num3]; + VALEURCHAMP v01=(*champ)[num01]; + VALEURCHAMP v02=(*champ)[num02]; + VALEURCHAMP v03=(*champ)[num03]; + VALEURCHAMP v12=(*champ)[num12]; + VALEURCHAMP v13=(*champ)[num13]; + VALEURCHAMP v23=(*champ)[num23]; + + double x=n[0]; + double y=n[1]; + double z=n[2]; + + double lambda0=face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x,y,z)/face(x1,y1,z1,x2,y2,z2,x3,y3,z3,x0,y0,z0); + double lambda1=face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x,y,z)/face(x0,y0,z0,x2,y2,z2,x3,y3,z3,x1,y1,z1); + double lambda2=face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x,y,z)/face(x1,y1,z1,x0,y0,z0,x3,y3,z3,x2,y2,z2); + double lambda3=face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x,y,z)/face(x1,y1,z1,x2,y2,z2,x0,y0,z0,x3,y3,z3); + + /* + cout<<" ### Pour ( "< +{ +public : Calcul_Interpolation_Penta6(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + int num0=(*mailles)[num_maille][0]; + int num1=(*mailles)[num_maille][1]; + int num2=(*mailles)[num_maille][2]; + int num3=(*mailles)[num_maille][3]; + int num4=(*mailles)[num_maille][4]; + int num5=(*mailles)[num_maille][5]; + + double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2]; + double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2]; + double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2]; + double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2]; + double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2]; + double x5=(*noeuds)[num5][0];double y5=(*noeuds)[num5][1];double z5=(*noeuds)[num5][2]; + + VALEURCHAMP v0=(*champ)[num0]; + VALEURCHAMP v1=(*champ)[num1]; + VALEURCHAMP v2=(*champ)[num2]; + VALEURCHAMP v3=(*champ)[num3]; + VALEURCHAMP v4=(*champ)[num4]; + VALEURCHAMP v5=(*champ)[num5]; + + double x=n[0]; + double y=n[1]; + double z=n[2]; + + double mu0=face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x,y,z)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x,y,z)/(face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x0,y0,z0)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x0,y0,z0)); + double mu1=face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x,y,z)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x,y,z)/(face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x1,y1,z1)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x1,y1,z1)); + double mu2=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x2,y2,z2)*face(x3,y3,z3,x4,y4,z4,x5,y5,z5,x2,y2,z2)); + double mu3=face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x,y,z)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/(face(x1,y1,z1,x2,y2,z2,x5,y5,z5,x3,y3,z3)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x3,y3,z3)); + double mu4=face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x,y,z)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/(face(x0,y0,z0,x2,y2,z2,x5,y5,z5,x4,y4,z4)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x4,y4,z4)); + double mu5=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x5,y5,z5)*face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x5,y5,z5)); + + VALEURCHAMP retour(v0.SIZE()); // + + retour=(mu0*v0+mu1*v1+mu2*v2+mu3*v3+mu4*v4+mu5*v5); + + return retour; // + } +}; +_TEMPLATE_ class Calcul_Interpolation_Penta15 : public Calcul_Interpolation<_PARAM_> +{ +public : Calcul_Interpolation_Penta15(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + cerr<<"Interpolation Pe2 pasencore implémentée"< +{ +public : Calcul_Interpolation_Pyra5(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + // NON TESTE + int num0=(*mailles)[num_maille][0]; + int num1=(*mailles)[num_maille][1]; + int num2=(*mailles)[num_maille][2]; + int num3=(*mailles)[num_maille][3]; + int num4=(*mailles)[num_maille][4]; + + double x0=(*noeuds)[num0][0];double y0=(*noeuds)[num0][1];double z0=(*noeuds)[num0][2]; + double x1=(*noeuds)[num1][0];double y1=(*noeuds)[num1][1];double z1=(*noeuds)[num1][2]; + double x2=(*noeuds)[num2][0];double y2=(*noeuds)[num2][1];double z2=(*noeuds)[num2][2]; + double x3=(*noeuds)[num3][0];double y3=(*noeuds)[num3][1];double z3=(*noeuds)[num3][2]; + double x4=(*noeuds)[num4][0];double y4=(*noeuds)[num4][1];double z4=(*noeuds)[num4][2]; + + VALEURCHAMP v0=(*champ)[num0]; + VALEURCHAMP v1=(*champ)[num1]; + VALEURCHAMP v2=(*champ)[num2]; + VALEURCHAMP v3=(*champ)[num3]; + VALEURCHAMP v4=(*champ)[num4]; + + double x=n[0]; + double y=n[1]; + double z=n[2]; + + double mu0=face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x,y,z)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x,y,z)/(face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x0,y0,z0)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x0,y0,z0)); + double mu1=face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x,y,z)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x,y,z)/(face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x1,y1,z1)*face(x2,y2,z2,x3,y3,z3,x4,y4,z4,x1,y1,z1)); + double mu2=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x2,y2,z2)*face(x0,y0,z0,x3,y3,z3,x4,y4,z4,x2,y2,z2)); + double mu3=face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x,y,z)*face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x,y,z)/(face(x0,y0,z0,x1,y1,z1,x4,y4,z4,x3,y3,z3)*face(x1,y1,z1,x2,y2,z2,x4,y4,z4,x3,y3,z3)); + double mu4=face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x,y,z)/face(x0,y0,z0,x1,y1,z1,x2,y2,z2,x4,y4,z4); + + VALEURCHAMP retour(v0.SIZE()); // + + retour=(mu0*v0+mu1*v1+mu2*v2+mu3*v3+mu4*v4); + + return retour; // + } +}; +_TEMPLATE_ class Calcul_Interpolation_Pyra13 : public Calcul_Interpolation<_PARAM_> +{ +public : Calcul_Interpolation_Pyra13(NUAGENOEUD * nn,NUAGEMAILLE * nm,CHAMP * c):Calcul_Interpolation<_PARAM_>(nn,nm,c) {} +public : VALEURCHAMP operator() (const NOEUD & n, int num_maille) + { + cerr<<"Interpolation Py2 pasencore implémentée"< +#define _MAPPING_ Mapping + + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Classe Mapping */ +/* */ +/*********************************************************/ + +// ATTENTION LE NUAGE DE NOEUD EST SUPPOSE NON REDONDANT ET AUCUNE VERIFICATION N'EST FAITE ! + +template class Mapping +{ +protected : + MAILLAGE * maillage_back; + NUAGEMAILLE * mailles_back; + NUAGENOEUD * noeuds_back; + NUAGENOEUD * noeuds_front; + Coordonnees_Barycentriques * CB; + dTree * my_dTree; + vector resultat_mapping; + vector point_le_plus_proche; + +public : + + Mapping():maillage_back(NULL),mailles_back(NULL),noeuds_back(NULL),noeuds_front(NULL),CB(NULL),my_dTree(NULL) {} + Mapping(MAILLAGE * mb,NUAGENOEUD * nb,NUAGENOEUD * nf); // le dTree est crée à l'initialisation, par contre, le mapping lui meme doit etre invoqué + ~Mapping() {if (CB) delete CB;if (my_dTree) delete my_dTree;} + dTree * Donne_dTree() {return my_dTree;} + int Donne_Directions(int num_maille,const NOEUD &n,int etat_face[NBR_FACES_MAX]); + // Méthode interne de localisation + int Trouve_Maille_Contenant_Point_Mth_Co(const NOEUD &n,int num_maille,int num_maille_interdit,int max_loop,int &nbr_mailles_examinees,int flag_convexe); + void Cree_Mapping(int flag_convexe=0); // SUPPOSE NON CONVEXE PAR DEFAUT + void Cree_Mapping(NUAGENOEUD * nf, int flag_convexe=0); // SUPPOSE NON CONVEXE PAR DEFAUT + inline int operator[](int i) const {return resultat_mapping[i];} // Renvoie la valeur mappé, si le mapping a été fait, sinon, n'importe quoi + inline vector & Get_Mapping() {return resultat_mapping;} // Renvoie le vector contenant le mapping + inline int Get_Noeud_Le_Plus_Proche(int i) const {return point_le_plus_proche[i];} // Invoque la méthode de d-Tree qui donne le noeud le plus proche + inline int Exist_dTree() const {return (my_dTree);} // Teste si le dTree existe + void affiche() + { + for (int i=0;iSIZE(); + int num_maille_depart; + int nma=0; + resultat_mapping = vector(nbr_noeuds,UNDEFINED); + point_le_plus_proche = vector(nbr_noeuds,UNDEFINED); + + // noeuds_back->affiche(); + + for (i=0;itrouve_plus_proche_point((*noeuds_front)[i]); + num_maille_depart=maillage_back->DONNE_PREMIERE_MAILLE_CONTENANT(point_le_plus_proche[i]); + resultat_mapping[i]=Trouve_Maille_Contenant_Point_Mth_Co((*noeuds_front)[i],num_maille_depart,num_maille_depart,NBR_MAX_MAILLES_EXAMINEES,nma,flag_convexe); + } + } + + else + { + cout<<"Le mapping semble déja existé, interrogation sur l'existant"<DONNE_POINTEUR_NUAGEMAILLE(); + + CB=new Coordonnees_Barycentriques(mailles_back,noeuds_back); + + // TEST REDONDANCE + /* + int nnb=noeuds_back->SIZE(); + if (nnb<20000) + { + cout<<"MAPPING : VERIFICATION REDONDANCES DANS NUAGE NOEUD BACK"<affiche(); + int i,j; + vector redondance(nnb,0); + for (i=0;i(noeuds_back); + + } +// Renvoie : +// 1 si le point est intérieur +// -1 si le point est extérieur à la maille via uniquement des faces qui ne sont pas au bord +// -2 si le point est extérieur à la maille par au moins une face de bord +// Et modifie etat_face de telle sorte que : +// etat_face[i] = -1 s'il n'existe pas de voisin via la face i +// etat_face[i] = 0 si le point est intérieur via la face i et que le voisin i existe +// etat_face[i] = 1 si le point est extérieur via la face i et que le voisin i existe +_TEMPLATE_ int _MAPPING_::Donne_Directions(int num_maille,const NOEUD &n,int etat_face[NBR_FACES_MAX]) + { + vector ef=CB->Donne_Pseudo_Coord_Baryc(num_maille,n); + int etat_int=VRAI; + int etat_ext_bord=FAUX; + int tf,tv,tb; + int nbr_faces=(*mailles_back)[num_maille].DONNE_NBR_FACES(); + for (int i=0;iDONNE_VOISIN_DE_MAILLE(num_maille,i)==UNDEFINED); + tb=(maillage_back->EST_AU_BORD_FACE_DE_MAILLE(num_maille,i)); + if (tf) + { + etat_int=FAUX; + if (tb) etat_ext_bord=VRAI; + } + if (tv) etat_face[i]=-1; + else + { + if (tf) etat_face[i]=1; + else etat_face[i]=0; + } + } + if (etat_int) return 1; + if (etat_ext_bord) return -2; + return -1; + } +_TEMPLATE_ int _MAPPING_::Trouve_Maille_Contenant_Point_Mth_Co(const NOEUD &n,int num_maille,int num_maille_interdit,int max_loop,int &nbr_mailles_examinees,int flag_convexe) + { + + int etat_face[NBR_FACES_MAX]; + int i,tmp,nbr_rnd; + int indirection[NBR_FACES_MAX]; + int ind_reel; + int num_reel; + int new_num=UNDEFINED; + + int test=Donne_Directions(num_maille,n,etat_face); + + int nbr_faces=maillage_back->DONNE_NBR_FACES_MAILLE(num_maille); + + for (i=0;iDONNE_VOISIN_DE_MAILLE(num_maille,ind_reel); + if ((etat_face[ind_reel]==1)&&(num_reel!=num_maille_interdit)) + { + new_num=num_reel; + } + } + for (i=0;(iDONNE_VOISIN_DE_MAILLE(num_maille,ind_reel); + if ((etat_face[ind_reel]==0)&&(num_reel!=num_maille_interdit)) + { + new_num=num_reel; + } + } + if (new_num==UNDEFINED) + { + new_num=num_maille_interdit; + } + num_maille_interdit=num_maille; + num_maille=new_num; + new_num=UNDEFINED; + test=Donne_Directions(num_maille,n,etat_face); + } + return UNDEFINED; + } + +#undef _TEMPLATE_ +#undef _MAPPING_ + +#endif diff --git a/src/INTERPOLATION/MEDMEM_MappingTools.hxx b/src/INTERPOLATION/MEDMEM_MappingTools.hxx new file mode 100644 index 000000000..095ef8ac1 --- /dev/null +++ b/src/INTERPOLATION/MEDMEM_MappingTools.hxx @@ -0,0 +1,241 @@ +#ifndef COORDONNEES_BARYCENTRIQUES_HPP +#define COORDONNEES_BARYCENTRIQUES_HPP + +#define _TEMPLATE_SPE_ template +#define _COORDBARYC_ Coordonnees_Barycentriques +#define _COORDBARY_2D_ Coordonnees_Barycentriques +#define _COORDBARY_3D_ Coordonnees_Barycentriques + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Classe Coordonnees_Barycentriques */ +/* */ +/*********************************************************/ + +// C'est la définition de la classe générique template qui n'est utilisée qu'à travers ses spécialisations +// vu que le nombre de spécialisations a faire est petit (nombre de dimensions utilisée, 3 pour MED) +// et vu que l'acces a ces classes doit etre rapide, car ce sont des classes de calcul +// la technique de spécialisation, plus lourde, mais plus rapide, a été préférée aux techniques d'héritage + +template class Coordonnees_Barycentriques +{ +// TEMPLATE GENERIQUE VIDE OBLIGE DE PASSER PAR UNE SPECIALISATION +}; + +/*********************************************************/ +/* */ +/* Spécialisation 2D */ +/* */ +/*********************************************************/ + +_TEMPLATE_SPE_ class _COORDBARY_2D_ +{ +protected : + NUAGEMAILLE * mailles; + NUAGENOEUD * sommets; + + vector etat_coord_baryc; + vector< vector< vector > > coord_baryc; + +public : + + Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {} + Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n); + ~Coordonnees_Barycentriques() {} + // donne les pseudos coordonnées barycentriques de M dans ma maille de numéro global num_maille dans mailles + // la pseudo coordonnées barycentrique par rapport a une face est la distance normalisée a cette face, + // dans le cas d'une face triangulaire, c'est la coordonnées ba + vector Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M); + vector Calcule_Base_Coord_Baryc(const vector &simplexe_base); + vector Calcule_Coord_Baryc(int num_maille, const NOEUD & M); +}; + +/*********************************************************/ +/* */ +/* Spécialisation 3D */ +/* */ +/*********************************************************/ + + +_TEMPLATE_SPE_ class _COORDBARY_3D_ +{ +protected : + NUAGEMAILLE * mailles; + NUAGENOEUD * sommets; + + vector etat_coord_baryc; + vector< vector< vector > > coord_baryc; + +public : + + Coordonnees_Barycentriques():mailles(NULL),sommets(NULL) {} + Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n); + ~Coordonnees_Barycentriques() {} + vector Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M); + vector Calcule_Base_Coord_Baryc(const vector &simplexe_base); + vector Calcule_Coord_Baryc(int num_maille, const NOEUD & M); +}; + +////////////////////////////////////////////////////////////////// +/// /// +/// CODE /// +/// /// +////////////////////////////////////////////////////////////////// + +_TEMPLATE_SPE_ _COORDBARY_2D_::Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n):mailles(m),sommets(n) + { + cout<<"Creation des Coordonnées Barycentriques : "<SIZE(); + etat_coord_baryc=vector(nbr_mailles,FAUX); + coord_baryc=vector< vector< vector > >(nbr_mailles); + cout<<"OK ! "< _COORDBARY_2D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M) + { + int i,j,nbr_faces; + if (etat_coord_baryc[num_maille]==FAUX) + { + nbr_faces=(*mailles).DONNE_NBR_FACES(); + + coord_baryc[num_maille]=vector< vector >(nbr_faces); + + for (i=0;i simplexe_base=(*mailles).DONNE_SIMPLEXE_BASE(i); + coord_baryc[num_maille][i]=Calcule_Base_Coord_Baryc(simplexe_base); + etat_coord_baryc[num_maille]=VRAI; + } + } + return Calcule_Coord_Baryc(num_maille,M); + } + +_TEMPLATE_SPE_ vector _COORDBARY_2D_::Calcule_Base_Coord_Baryc(const vector &simplexe_base) + { + const vector &ref=simplexe_base; + vector retour(3); + int i,j; + + double x0=(*sommets)[ref[0]][0]; + double y0=(*sommets)[ref[0]][1]; + double x1=(*sommets)[ref[1]][0]; + double y1=(*sommets)[ref[1]][1]; + double x2=(*sommets)[ref[2]][0]; + double y2=(*sommets)[ref[2]][1]; + + double delta=(x1*y2-x2*y1)+(x2*y0-x0*y2)+(x0*y1-x1*y0); + + retour[0]=(y1-y2)/delta; + retour[1]=(x2-x1)/delta; + retour[2]=(x1*y2-x2*y1)/delta; + + return retour; + } + +_TEMPLATE_SPE_ vector _COORDBARY_2D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M) + { + int i,j; + vector coord_baryc_M(3,0); + for (i=0;i<3;i++) + { + for (j=0;j<2;j++) coord_baryc_M[i]+=coord_baryc[num_maille][i][j]*M[j]; + coord_baryc_M[i]+=coord_baryc[num_maille][i][2]; + } + return coord_baryc_M; + } + +_TEMPLATE_SPE_ _COORDBARY_3D_::Coordonnees_Barycentriques(NUAGEMAILLE * m, NUAGENOEUD *n):mailles(m),sommets(n) + { + cout<<"Creation des Coordonnées Barycentriques : "<SIZE(); + etat_coord_baryc=vector(nbr_mailles,FAUX); + coord_baryc=vector< vector< vector > >(nbr_mailles); + cout<<"OK ! "< _COORDBARY_3D_::Donne_Pseudo_Coord_Baryc(int num_maille,const NOEUD &M) + { + int i,j,nbr_faces; + if (etat_coord_baryc[num_maille]==FAUX) + { + nbr_faces=(*mailles)[num_maille].DONNE_NBR_FACES(); + + coord_baryc[num_maille]=vector< vector >(nbr_faces); + + type_retour simplexe_base; + + for (i=0;i(&simplexe_base.quoi[0],&simplexe_base.quoi[simplexe_base.combien])); + etat_coord_baryc[num_maille]=VRAI; + } + } + return Calcule_Coord_Baryc(num_maille,M); + } + + +_TEMPLATE_SPE_ vector _COORDBARY_3D_::Calcule_Base_Coord_Baryc(const vector &simplexe_base) + { + const vector &ref=simplexe_base; + vector retour(4); + int i,j; + + double x0=(*sommets)[ref[0]][0]; + double y0=(*sommets)[ref[0]][1]; + double z0=(*sommets)[ref[0]][2]; + double x1=(*sommets)[ref[1]][0]; + double y1=(*sommets)[ref[1]][1]; + double z1=(*sommets)[ref[1]][2]; + double x2=(*sommets)[ref[2]][0]; + double y2=(*sommets)[ref[2]][1]; + double z2=(*sommets)[ref[2]][2]; + double x3=(*sommets)[ref[3]][0]; + double y3=(*sommets)[ref[3]][1]; + double z3=(*sommets)[ref[3]][2]; + + double delta1=((y2-y1)*(z3-z1)-(z2-z1)*(y3-y1)); + double delta2=((x3-x1)*(z2-z1)-(x2-x1)*(z3-z1)); + double delta3=((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1)); + + double delta=delta1*(x0-x1)+delta2*(y0-y1)+delta3*(z0-z1); + + retour[0]=delta1/delta; + retour[1]=delta2/delta; + retour[2]=delta3/delta; + retour[3]=-(delta1*x1+delta2*y1+delta3*z1)/delta; + + return retour; + } + +_TEMPLATE_SPE_ vector _COORDBARY_3D_::Calcule_Coord_Baryc(int num_maille, const NOEUD & M) + { + int i,j; + int nbr_faces=coord_baryc[num_maille].size(); + vector coord_baryc_M(nbr_faces,0); + for (i=0;i +#undef _COORDBARYC_ +// Coordonnees_Barycentriques +#undef _COORDBARY_2D_ +// Coordonnees_Barycentriques +#undef _COORDBARY_3D_ +// Coordonnees_Barycentriques + +#endif diff --git a/src/INTERPOLATION/MEDMEM_WrapperCells.hxx b/src/INTERPOLATION/MEDMEM_WrapperCells.hxx new file mode 100644 index 000000000..2818cbcc8 --- /dev/null +++ b/src/INTERPOLATION/MEDMEM_WrapperCells.hxx @@ -0,0 +1,917 @@ +#ifndef WRAPPERS_CELLS_HXX +#define WRAPPERS_CELLS_HXX + +#include "stdio.h" +#include "stdlib.h" + +#include + +#include +#include + +#ifndef FAUX +#define FAUX 0 +#endif + +#ifndef VRAI +#define VRAI 1 +#endif + +#ifndef UNDEFINED +#define UNDEFINED -1 +#endif + +#include "MEDMEM_define.hxx" + +#define MAXNBR 10 + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Equivalence num modele local => MED */ +/* */ +/*********************************************************/ + +#define NBR_MODELES_MAILLES_DEFINIS 15 +static int Equivalence_Local_MED[NBR_MODELES_MAILLES_DEFINIS] = { MED_POINT1 , + MED_SEG2 , MED_SEG3, + MED_TRIA3 , MED_TRIA6 , MED_QUAD4 , MED_QUAD8 , + MED_TETRA4 , MED_TETRA10 , MED_HEXA8 , MED_HEXA20 , MED_PYRA5 , MED_PYRA13 , MED_PENTA6 , MED_PENTA15 }; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Base */ +/* */ +/*********************************************************/ + +// classe mere des connectivités cannoniques +// N'a aucune méthode virtuelle pour éviter les pertes de temps +// Ce sont les constructeurs des classes dérivées qui renseignent les attributs spécifiques +// un simplexe de base est constitué par un sommet de la maille qui n'est pas contenu dans la face démandée et par trois points de cette face +// Ce simplexe est utilisé dans le calcul des fonctions barycentriques +// LES MAILLES SONT DONC ET PAR CONSEQUENT DES MAILLES A FACES PLANES +// Une face est une face P1, c'est a dire contenant uniquement les sommets, par les noeuds milieux +// Ces faces sont utilisées pour le calcul de connexité + + +class Connectivite_Canonique_Base +{ +protected : + int type ; + int nbr_noeuds ; + int nbr_faces ; + vector premier_noeud ; + vector< vector > simplexe_base ; + vector< vector > face ; +public : + inline int DONNE_NBR_NOEUDS() const { return nbr_noeuds; } + inline int DONNE_NBR_FACES() const { return nbr_faces; } + inline const vector & DONNE_SIMPLEXE_BASE(int num_face) const { return simplexe_base[num_face]; } + inline const vector & DONNE_FACE(int num_face) const { return face[num_face]; } + inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const { return premier_noeud[num_face]; } + friend class Wrapper_Maille; +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_* */ +/* */ +/*********************************************************/ + +// définies dans la partie CODE +// les constructeurs construisent tous les tableaux de connectivités nécessaires en fonction du MODELE MED + +//class Connectivite_Canonique_Point1 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Seg2 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Seg3 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Tria3 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Tria6 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Quad4 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Quad8 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Tetra4 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Tetra10 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Hexa8 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Hexa20 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Pyra5 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Pyra13 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Penta6 : public Connectivite_Canonique_Base; +//class Connectivite_Canonique_Penta15 : public Connectivite_Canonique_Base; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Generale */ +/* */ +/*********************************************************/ + +// Cette classe contient toutes les connectivités canoniques, elle est utilisée dans Wrapper_Nuage_Maille + +class Connectivite_Generale +{ +protected : + vector AllConn; +public : + Connectivite_Generale(); + ~Connectivite_Generale(); + // Renvoie la connectivite locale de la maille de numero local de modele i, dont l'equivalent MED est Equivalence_Local_MED[i] + Connectivite_Canonique_Base * operator[](int i) const {return AllConn[i];} +}; + +/*********************************************************/ +/* */ +/* Structure type_retour */ +/* */ +/*********************************************************/ + +// c'est une structure de type petit tableau statique, pour accelerer les acces et eviter les allocations dynamiques + +struct type_retour + { + int quoi[MAXNBR]; + int combien; + }; + +/*********************************************************/ +/* */ +/* Fonction Comparaison_Informe(...) */ +/* */ +/*********************************************************/ + +// renvoie vrai si v1 et v2 contiennent la meme chose et sont de meme tailles, faux sinon + +inline int Comparaison_Informe(const type_retour &v1,const type_retour &v2); + +/*********************************************************/ +/* */ +/* Classe Wrapper_Maille */ +/* */ +/*********************************************************/ + +// c'est le wrapper maille sur int[] +// cette classe n'est pas dérivée, tous les types de mailles sont stockées sous cette forme +// la variable qui définit les type est la Connectivité_Canonique_Base, qui est toujours polymorphée en un type spécifique + + +class Wrapper_Maille +{ +protected : + + // la référence du premier sommet + int * sommets; + // la connectivité canonique, toujours polymorphée + Connectivite_Canonique_Base * modele; + +public : + Wrapper_Maille():sommets(NULL) {} + ~Wrapper_Maille() {} + + // sorte de transtypeur, cette méthode prend une référence vers un premier sommet et un modele canonique et renvoie *this en tant que wrapper sur ces données + inline const Wrapper_Maille & positionne(int * pos, Connectivite_Canonique_Base * mod){sommets=pos;modele=mod;return *this;} + // méthodes de la politique (les numéros renvoyés sont des numéros GLOBAUX, calculés à partir de l'indirection fournie par la connectivité canonique + // par contre les numéros de face fournis sont des numéros locaux + // renvoie le numéro global du sommet de numéro local i + inline int operator[](int i) const {return sommets[i];} + inline int DONNE_NBR_NOEUDS() const; + inline int DONNE_NBR_FACES() const; + inline void DONNE_SIMPLEXE_BASE(int num_face,type_retour & simplexe) const; + inline void DONNE_FACE(int num_face,type_retour & face) const; + inline int DONNE_PREMIER_NOEUD_DE_FACE(int num_face) const; + // pour une face, donne, s'il existe, le numéro local de face équivalente, -1 sinon + inline int DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(const type_retour & sommets_face) const; + // donne le numéro local de modele + inline int DONNE_TYPE_MAILLE() const; + // donne le numéro MED de modele + inline int DONNE_TYPE_MED_MAILLE() const; +}; + + +/*********************************************************/ +/* */ +/* Classe Wrapper_Nuage_Maille */ +/* */ +/*********************************************************/ + +// Classe de Wrapping sur un nuage de maille donné sous forme SKYLINE +// voir la classe Wrapper_Med_Connectivity dans MEDMEM_Wrapper_Connectivity.hxx pour la politique de classe + +template class Wrapper_Nuage_Maille +{ +protected : + // pointeur sur une forme skyline + FORME_SKYLINE * mailles; + // toutes les connectivités canoniques + Connectivite_Generale ConnGen; + int nbr_mailles; + // ATTENTION, c'est le type en numero local de modele, pour éviter une map, le numéro de modele MED correponsdant est donné par Equivalence_Local_MED + vector types; + // pointeur dans mailles du premier sommet de chaque maille (évite les calculs du au nombres éventuellement différents de sommets par maille) + vector< int * > premier_pointeur; + // maille_courante, est un Wrapper_Maille déja instancié utilisé par l'opérateur [] pour accelerer les acces + Wrapper_Maille maille_courante; +public : + Wrapper_Nuage_Maille():mailles(NULL) {} + // le constructeur renseigne types et premier_pointeur, instantie ConnGenn et positionne maille_courante sur la premiere maille + Wrapper_Nuage_Maille(FORME_SKYLINE * fs); + ~Wrapper_Nuage_Maille() {} + // Méthodes de la politique + // positionne maille_courante sur la maille de numéro global i et renvoie maille_courante + inline const Wrapper_Maille & operator[](int i); + inline int SIZE() {return nbr_mailles;} + void affiche(); +}; + +////////////////////////////////////////////////////////////////// +/// /// +/// CODE /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Fonction Comparaison_Informe(...) */ +/* */ +/*********************************************************/ + +// effectue le test (v1 et v2 ont meme taille)&&(chaque élément de v1 est dans v2) +// c'est une égalité forte si on est sur que v1 et v2 n'ont pas de doublets, +// ce qui est le cas pour les mailles et les simplexes + +int Comparaison_Informe(const type_retour &v1,const type_retour &v2) + { + int t1=v1.combien; + int t2=v2.combien; + if (t1!=t2) return FAUX; + int i1,i2; + int test; + for (i1=0;i1DONNE_NBR_NOEUDS(); + } +inline int Wrapper_Maille::DONNE_NBR_FACES() const + { + return modele->DONNE_NBR_FACES(); + } +inline void Wrapper_Maille::DONNE_SIMPLEXE_BASE(int num_face,type_retour & simplexe) const + { + const vector & simplexelocal=modele->DONNE_SIMPLEXE_BASE(num_face); + simplexe.combien=simplexelocal.size(); + for (int i=0;i & facelocal=modele->DONNE_FACE(num_face); + face.combien=facelocal.size(); + for (int i=0;iDONNE_PREMIER_NOEUD_DE_FACE(num_face)]; + } +inline int Wrapper_Maille::DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(const type_retour & sommets_face) const + { + type_retour face_loc; + int num_face; + int taille_face_exam; + int test=FAUX; + for (num_face=0;num_facetype; + } +inline int Wrapper_Maille::DONNE_TYPE_MED_MAILLE() const + { + return Equivalence_Local_MED[modele->type]; + } + + +/*********************************************************/ +/* */ +/* Classe Wrapper_Nuage_Maille */ +/* */ +/*********************************************************/ + +template Wrapper_Nuage_Maille::Wrapper_Nuage_Maille(FORME_SKYLINE * fs):mailles(fs) + { + int i; + map Equivalence_MED_Local; + // calcule la map de convertion des types med en numéro local, pour accelerer l'acces + for (i=0;iSIZE(); + types.resize(nbr_mailles); + premier_pointeur.resize(nbr_mailles); + for (i=0;iDONNE_TYPE_MAILLE(i)]; + premier_pointeur[i]=mailles->DONNE_PREMIER_POINTEUR(i); + } + maille_courante.positionne(premier_pointeur[0],ConnGen[types[0]]); + } +template const Wrapper_Maille & Wrapper_Nuage_Maille::operator[](int i) + { + return maille_courante.positionne(premier_pointeur[i],ConnGen[types[i]]); + } +template void Wrapper_Nuage_Maille::affiche() + { + int i,j; + for (i=0;i(0); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + } + ~Connectivite_Canonique_Point1() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Seg2 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Seg2 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Seg2() + { + + type=1; + + int pn[2] = {0,1}; + int sb[4] = {1,0,0,1}; + int fa[2] = {0,1}; + int po[3] = {0,1,2}; + + nbr_noeuds = 2; + nbr_faces = 2; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[2*i],&sb[2*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Seg2() {} +}; +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Seg3 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Seg3 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Seg3() + { + + type=2; + + int pn[2] = {0,1}; + int sb[4] = {1,0,0,1}; + int fa[2] = {0,1}; + int po[3] = {0,1,2}; + + nbr_noeuds = 3; + nbr_faces = 2; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[2*i],&sb[2*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Seg3() {} +}; + + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Tria3 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Tria3 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Tria3() + { + + type=3; + + int pn[3] = {0,1,2}; + int sb[9] = {2,0,1,0,1,2,1,2,0}; + int fa[6] = {0,1,1,2,2,0}; + int po[4] = {0,2,4,6}; + nbr_noeuds = 3; + nbr_faces = 3; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[3*i],&sb[3*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Tria3() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Tria6 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Tria6 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Tria6() + { + + type=4; + + int pn[3] = {0,1,2}; + int sb[9] = {2,0,1,0,1,2,1,2,0}; + int fa[6] = {0,1,1,2,2,0}; + int po[4] = {0,2,4,6}; + nbr_noeuds = 6; + nbr_faces = 3; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[3*i],&sb[3*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Tria6() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Quad4 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Quad4 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Quad4() + { + + type=5; + + int pn[4] = {0,1,2,3}; + int sb[12] = {2,0,1,3,1,2,0,2,3,1,0,2}; + int fa[8] = {0,1,1,2,2,3,3,0}; + int po[5] = {0,2,4,6,8}; + nbr_noeuds = 4; + nbr_faces = 4; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[3*i],&sb[3*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Quad4() {} +}; + + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Quad8 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Quad8 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Quad8() + { + + type=6; + + int pn[4] = {0,1,2,3}; + int sb[12] = {2,0,1,3,1,2,0,2,3,1,0,2}; + int fa[8] = {0,1,1,2,2,3,3,0}; + int po[5] = {0,2,4,6,8}; + nbr_noeuds = 8; + nbr_faces = 4; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[3*i],&sb[3*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Quad8() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Tetra4 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Tetra4 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Tetra4() + { + + type=7; + + int pn[4] = {0,0,1,2}; + int sb[16] = {3,0,1,2,2,0,3,1,0,1,3,2,1,2,3,0}; + int fa[12] = {0,1,2,0,3,1,1,3,2,2,3,0}; + int po[5] = {0,3,6,9,12}; + nbr_noeuds = 4; + nbr_faces = 4; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Tetra4() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Tetra10 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Tetra10 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Tetra10() + { + + type=8; + + int pn[4] = {0,0,1,2}; + int sb[16] = {3,0,1,2,2,0,3,1,0,1,3,2,1,2,3,0}; + int fa[12] = { 0,1,2, 0,3,1, 1,3,2, 2,3,0}; + int po[5] = {0,3,6,9,12}; + + nbr_noeuds = 10; + nbr_faces = 4; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Tetra10() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Hexa8 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Hexa8 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Hexa8() + { + + type=9; + + int pn[6] = {0,4,0,1,2,3}; + int sb[24] = {5,0,1,2,0,7,6,5,3,0,4,5,4,1,5,6,1,2,6,3,2,3,7,0}; + int fa[24] = {0,1,2,3,4,5,6,7,0,4,5,1,1,5,6,2,2,6,7,3,3,7,4,0}; + int po[7] = {0,4,8,12,16,20,24}; + nbr_noeuds = 8; + nbr_faces = 6; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Hexa8() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Hexa20 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Hexa20 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Hexa20() + { + + type=10; + + int pn[6] = {0,4,0,1,2,3}; + int sb[24] = {5,0,1,2,0,7,6,5,3,0,4,5,4,1,5,6,1,2,6,3,2,3,7,0}; + int fa[24] = {0,1,2,3,4,5,6,7,0,4,5,1,1,5,6,2,2,6,7,3,3,7,4,0}; + int po[7] = {0,4,8,12,16,20,24}; + nbr_noeuds = 20; + nbr_faces = 6; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Hexa20() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Pyra5 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Pyra5 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Pyra5() + { + + type=11; + + int pn[5] = {0,0,1,2,3}; + int sb[20] = {4,0,1,2,3,0,4,1,0,1,4,2,1,2,4,3,2,0,3,4}; + int fa[16] = {0,1,2,3,0,4,1,1,4,2,2,4,3,3,4,0}; + int po[6] = {0,4,7,10,13,16}; + nbr_noeuds = 5; + nbr_faces = 5; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Pyra5() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Pyra13 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Pyra13 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Pyra13() + { + + type=12; + + int pn[5] = {0,0,1,2,3}; + int sb[20] = {4,0,1,2,3,0,4,1,0,1,4,2,1,2,4,3,2,0,3,4}; + int fa[16] = {0,1,2,3,0,4,1,1,4,2,2,4,3,3,4,0}; + int po[6] = {0,4,7,10,13,16}; + nbr_noeuds = 13; + nbr_faces = 5; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Pyra13() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Penta6 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Penta6 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Penta6() + { + + type=13; + + int pn[5] = {0,3,0,1,2}; + int sb[20] = {3,0,1,2,2,3,4,5,5,0,3,1,0,1,4,2,1,2,5,0}; + int fa[18] = {0,1,2,3,4,5,0,3,4,1,1,4,5,2,2,5,3,1}; + int po[6] = {0,3,6,10,14,18}; + nbr_noeuds = 6; + nbr_faces = 5; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Penta6() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Canonique_Penta15 */ +/* */ +/*********************************************************/ + +class Connectivite_Canonique_Penta15 : public Connectivite_Canonique_Base +{ +public : + Connectivite_Canonique_Penta15() + { + + type=14; + + int pn[5] = {0,3,0,1,2}; + int sb[20] = {3,0,1,2,2,3,4,5,5,0,3,1,0,1,4,2,1,2,5,0}; + int fa[18] = {0,1,2,3,4,5,0,3,4,1,1,4,5,2,2,5,3,1}; + int po[6] = {0,3,6,10,14,18}; + nbr_noeuds = 15; + nbr_faces = 5; + + + premier_noeud = vector(&pn[0],&pn[nbr_faces]); + + simplexe_base = vector< vector >(nbr_faces); + face = vector< vector >(nbr_faces); + + int i; + + for (i=0;i(&sb[4*i],&sb[4*(i+1)]); + for (i=0;i(&fa[po[i]],&fa[po[i+1]]); + + } + ~Connectivite_Canonique_Penta15() {} +}; + +/*********************************************************/ +/* */ +/* Classe Connectivite_Generale */ +/* */ +/*********************************************************/ + +inline Connectivite_Generale::Connectivite_Generale():AllConn(NBR_MODELES_MAILLES_DEFINIS) + { + // l'ordre est important, il dépend de la relation entre numéro local et modele et numéro MED + AllConn[ 0]=new Connectivite_Canonique_Point1 (); + AllConn[ 1]=new Connectivite_Canonique_Seg2 (); + AllConn[ 2]=new Connectivite_Canonique_Seg3 (); + AllConn[ 3]=new Connectivite_Canonique_Tria3 (); + AllConn[ 4]=new Connectivite_Canonique_Tria6 (); + AllConn[ 5]=new Connectivite_Canonique_Quad4 (); + AllConn[ 6]=new Connectivite_Canonique_Quad8 (); + AllConn[ 7]=new Connectivite_Canonique_Tetra4 (); + AllConn[ 8]=new Connectivite_Canonique_Tetra10 (); + AllConn[ 9]=new Connectivite_Canonique_Hexa8 (); + AllConn[10]=new Connectivite_Canonique_Hexa20 (); + AllConn[11]=new Connectivite_Canonique_Pyra5 (); + AllConn[12]=new Connectivite_Canonique_Pyra13 (); + AllConn[13]=new Connectivite_Canonique_Penta6 (); + AllConn[14]=new Connectivite_Canonique_Penta15 (); + } +inline Connectivite_Generale::~Connectivite_Generale() + { + for (int i=0;i + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS ET CODE /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Wrapper_Med_Connectivity */ +/* */ +/*********************************************************/ + +// obligé de faire de la recopie car MED n'utilise pas la numérotation standart C + +class Wrapper_Med_Connectivity +{ +protected : + int * mailles; + int nbr_mailles; + vector types; + vector< int* > premier_pointeur; + +public : + ~Wrapper_Med_Connectivity() {if (mailles) delete [] mailles;} + Wrapper_Med_Connectivity():mailles(NULL) {} + Wrapper_Med_Connectivity(CONNECTIVITY * maillesmed) + { + const med_int * tab_sommets_mailles=maillesmed->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS); + const med_int * med_connectivite=maillesmed->getConnectivityIndex(MED_FULL_INTERLACE,MED_CELL); + const med_int * med_index=maillesmed->getValueIndex(MED_FULL_INTERLACE); + nbr_mailles=maillesmed->getNumberOf(MED_CELL,MED_ALL_ELEMENTS); + int size=med_index[nbr_mailles]-med_index[0]; + types.resize(nbr_mailles); + premier_pointeur.resize(nbr_mailles); + mailles=new int[size]; + int i; + for (i=0;igetElementType(MED_CELL,i+1); // A VERIFIER : le +1 + premier_pointeur[i]=&mailles[med_index[i]-1]; // A VERIFIER : la formule + } + } + // Méthodes de la politique + inline int SIZE() {return nbr_mailles;} + inline int DONNE_TYPE_MAILLE(int i) {return types[i];} + inline int * DONNE_PREMIER_POINTEUR(int i) {return premier_pointeur[i];} +}; + + +#endif diff --git a/src/INTERPOLATION/MEDMEM_WrapperField.hxx b/src/INTERPOLATION/MEDMEM_WrapperField.hxx new file mode 100644 index 000000000..1f0a2bf1a --- /dev/null +++ b/src/INTERPOLATION/MEDMEM_WrapperField.hxx @@ -0,0 +1,207 @@ +#ifndef MEDMEM_WRAPPER_FIELD_HXX +#define MEDMEM_WRAPPER_FIELD_HXX + +#include "MEDMEM_Field.hxx" + +#include + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS ET CODE /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Template Arithmétiques de Valdhuizen */ +/* */ +/*********************************************************/ + +// permet de faire des opérations algébriques sur des Wrappers_MED_Field sans faire d'allocations inutiles +// voir les articles de Valdhuizen pour la compréhension du processus + +template class Valeur; + +struct Plus +{ +public : + static double apply(double a,double b) {return a+b;} +}; + +struct Multiply +{ +public : + static double apply(double a,double b) {return a*b;} +}; + + +template struct X +{ + Left left; + Right right; + X(Left l,Right r):left(l),right(r){} + double operator[](int i) + { + return Op::apply(left[i],right[i]); + } +}; + +template struct X +{ + double left; + Right right; + X(double l,Right r):left(l),right(r){} + double operator[](int i) + { + return Multiply::apply(left,right[i]); + } +}; + +template X< Valeur,Plus,Valeur > operator+(Valeur v1,Valeur v2) +{ +return X< Valeur,Plus,Valeur >(v1,v2); +} + +template X< double,Multiply,Valeur > operator*(TYPE sca,Valeur v) +{ +return X< TYPE,Multiply,Valeur >(sca,v); +} + +template X< Valeur,Plus,X > operator+(Valeur v,X expression) +{ +return X< Valeur,Plus,X >(v,expression); +} + +template X< X,Plus,Valeur > operator+(X expression,Valeur v) +{ +return X< X,Plus,Valeur >(expression,v); +} + +template X< X,Plus, X > operator+(X el, X er ) +{ +return X< X,Plus,X >(el,er); +} + +template X< double,Multiply,X > operator*(double sca,X expression) +{ +return X< double,Multiply,X >(sca,expression); +} + +template X< double,Multiply,X > operator/(X l,double x) +{ +return X< double,Multiply,X >(((double) 1/x),l); +} + +/*********************************************************/ +/* */ +/* Classe Valeur */ +/* */ +/*********************************************************/ + +// Problèmes : les constructeurs par copie ne sont pas satisfaisants +// Valeur est symboliquement l'argument d'une classe formelle Vecteur +// elle peut etre un réel ou un pointeur sur réel, simulant un vecteur de vecteur + +template class Valeur +{ +protected : + TYPE * valeurs; + int nbr_valeurs; + int a_detruire; +public : + Valeur():valeurs(NULL),a_detruire(0){} + Valeur(TYPE * val,int nv):valeurs(val),nbr_valeurs(nv),a_detruire(0){} // A VERIFIER + Valeur(int n):nbr_valeurs(n),a_detruire(1) + { + valeurs=new TYPE[nbr_valeurs]; + } + template Valeur(X expression) + { + for (int i=0;i void operator=(X expression) + { + for (int i=0;i ostream &operator<<(ostream &os,Valeur v) + { + os<<"("< MEDMEMOIRE + +class Wrapper_MED_Field +{ +protected : + int nbr_valeurs; + int nbr_composantes; + double * valeurs; +public : + Wrapper_MED_Field():valeurs(NULL){} + Wrapper_MED_Field(int nv, int nc, double * v):nbr_valeurs(nv),nbr_composantes(nc),valeurs(v) + { + } + Wrapper_MED_Field(const FIELD * medfield) + { + nbr_valeurs=medfield->getNumberOfValues(); + nbr_composantes=medfield->getNumberOfComponents(); + valeurs=const_cast(medfield->getValue(MED_FULL_INTERLACE)); + } + ~Wrapper_MED_Field(){} + inline Valeur operator[](int i) + { + return Valeur(&valeurs[nbr_composantes*i],nbr_composantes); + } + double * Get_Valeurs() {return valeurs;} + inline int Get_Nbr_Valeurs() const {return nbr_valeurs;} + inline int Get_Nbr_Composantes() const {return nbr_composantes;} + friend ostream & operator<<(ostream &os, Wrapper_MED_Field); +}; + +inline ostream & operator<<(ostream &os, Wrapper_MED_Field wmf) +{ +for (int i=0;i + +#ifndef UNDEFINED +#define UNDEFINED -1 +#endif + +#ifndef FAUX +#define FAUX 0 +#endif + +#ifndef VRAI +#define VRAI 1 +#endif + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Wrapper_Maillage */ +/* */ +/*********************************************************/ + +// cette classe est à la fois un wrapper sur un nuage de maille et une classe d'algorithme +// elle s'occupe de construire les liens de connexités minimums du nuage de maille +// pour le transformer en maillage suffisament riche pour etre utilisé par les algorithmes de connexités +// et autres méthodes nécessitant des informations de connexité sur un maillage + +// la version utilisée dans MEDMEMOIRE est dé-templatifiée dans MEDMEM_InterpolationHighLevelObject.hxx + +template class Wrapper_Maillage +{ +protected : + // référence vers le nuage de maille, + // voir la classe Wrapper_Nuage_Maille dans MEDMEM_WrapperCells.hxx pour la politique + NUAGEMAILLE * mailles; + + int nbr_noeuds; + + // liste des numéros globaux de faces contenues dans une maille + vector< vector > faces_contenues; + // liste des numéros globaux de mailles qui contiennent un noeud + vector< vector > mailles_contenant_noeud; + // liste des numéros globaux de mailles voisines d'une maille donnée via une face + // l'ordre du voisin dans la liste implique par quelle face dans le tableau faces_contenues il est voisin + vector< vector > voisins_de_maille; + + // liste des numéros globaux de faces qui sont au bord du maillage + // Ce sont les faces qui n'ont qu'une seule maille de rattachement + vector face_au_bord; + // liste des numéros globaux de mailles qui sont au bord + // ce sont les mailles qui ont une face sans voisin + vector maille_au_bord; + + // Méthode privée + // construit le tableau mailles_contenant_noeud + void Construit_Contenant_Noeud(); + +public : + + Wrapper_Maillage():mailles(NULL) {} + // Construit les Connectivités du maillage à la construction + Wrapper_Maillage(NUAGEMAILLE * fs, int nn); + ~Wrapper_Maillage() {} + + // Méthodes de la politique + inline int DONNE_NBR_FACES_MAILLE(int num_maille); + inline int DONNE_VOISIN_DE_MAILLE(int num_maille,int num_face) const; + inline int EST_AU_BORD_FACE_DE_MAILLE(int num_maille,int num_face) const; + inline int DONNE_NBR_FACES(int num_maille) const; + inline int DONNE_PREMIERE_MAILLE_CONTENANT(int num_noeud) const; + inline NUAGEMAILLE * DONNE_POINTEUR_NUAGEMAILLE(); + +}; + +////////////////////////////////////////////////////////////////// +/// /// +/// CODE /// +/// /// +////////////////////////////////////////////////////////////////// + +template int Wrapper_Maillage::DONNE_PREMIERE_MAILLE_CONTENANT(int num_noeud) const + { + return mailles_contenant_noeud[num_noeud][0]; + } +template int Wrapper_Maillage::DONNE_VOISIN_DE_MAILLE(int num_maille,int num_face) const + { + return voisins_de_maille[num_maille][num_face]; + } +template int Wrapper_Maillage::EST_AU_BORD_FACE_DE_MAILLE(int num_maille,int num_face) const + { + return face_au_bord[faces_contenues[num_maille][num_face]]; + } +template int Wrapper_Maillage::DONNE_NBR_FACES_MAILLE(int num_maille) + { + return (*mailles)[num_maille].DONNE_NBR_FACES(); + } +template NUAGEMAILLE * Wrapper_Maillage::DONNE_POINTEUR_NUAGEMAILLE() + { + return mailles; + } +template void Wrapper_Maillage::Construit_Contenant_Noeud() + { + int nbr_noeuds_maille; + int num,num_noeud,num_maille; + + mailles_contenant_noeud.resize(nbr_noeuds); + + // parcours le tableau des mailles, puis les sommets de chaque maille + // et utilise un push_back pour renseigner mailles_contenant_noeud + + for (num_maille=0;num_mailleSIZE();num_maille++) + { + nbr_noeuds_maille=(*mailles)[num_maille].DONNE_NBR_NOEUDS(); + for (num_noeud=0;num_noeud Wrapper_Maillage::Wrapper_Maillage(NUAGEMAILLE * fs,int nn) + { + + if (fs) mailles=fs; + else + { + cerr<<"Wrapper_Maillage : Nuage mailles vide passé en argument"<SIZE(); + int nbr_formants=0; + int approx_nbr_formants=0; + int tmp; + int num_loc; + + nbr_noeuds=nn; + + voisins_de_maille.resize(nbr_mailles); + faces_contenues.resize(nbr_mailles); + maille_au_bord.resize(nbr_mailles,UNDEFINED); + + type_retour sommets_face; + + Construit_Contenant_Noeud(); + + // mise a taille des tableaux et calcul d'une approximation du nombre de faces + // on postule que le nombre de faces réel est le dixieme de la somme du nombre de faces par maille sur toutes les mailles + // on calcule cette approximation pour éviter les allocations fréquentes dues aux push_back pour des petits tableaux + + for (num_maille=0;num_maille(tmp,UNDEFINED); + faces_contenues[num_maille]=vector(tmp,UNDEFINED); + approx_nbr_formants+=tmp; + } + + face_au_bord.reserve(approx_nbr_formants/10); + + // algorithme principal + + // REMARQUE : les faces sont numérotées mais ne sont pas construites ni stockées + + int flag_interm; + + // on parcourt en premier lieu le nuage de maille (linéaire, en Nombre de Maille) + + for (num_maille=0;num_maillenum_maille) + { + flag_interm=1; + + // pour cette maille secondaire on regarde si elle contient la face primaire + // (borné, par 8*4=32) + + num_loc=(*mailles)[num_maille_sec].DONNE_NUM_LOC_FACE_EGALE_A_FORMANT(sommets_face); + if (num_loc>UNDEFINED) + { + + // et dans ce cas, la maille secondaire est voisine de la maille primaire, on met à jour les tableaux + // si on voulait construire le tableau des faces, c'est ici qu'il faudrait le faire -1- + + // MESSAGE("La maille "< class Wrapper_Noeud +{ +protected : + double * coordonnees; +public : + Wrapper_Noeud():coordonnees(NULL) + { + } + Wrapper_Noeud(double * coord):coordonnees(coord) + { + } + ~Wrapper_Noeud() + { + } + void positionne(double *place) + { + coordonnees=place; + } + const double & operator[] (int i) const + { + return coordonnees[i]; + } + double operator[] (int i) + { + return coordonnees[i]; + } + friend double DistanceInf(const Wrapper_Noeud &A,const Wrapper_Noeud &B) + { + double max=0; + double tmp; + for (int i=0;imax) max=tmp; + } + return max; + } + friend double DistanceL2(const Wrapper_Noeud &A,const Wrapper_Noeud &B) + { + double tmp,somme=0; + for (int i=0;i &A,const Wrapper_Noeud &B) + { + for (int i=0;i &A) + { + os<<"( "< class Wrapper_Nuage_Noeud + { + protected : + int nbr_noeuds; + double * noeuds; + Wrapper_Noeud show; + public : + Wrapper_Nuage_Noeud():nbr_noeuds(0),noeuds(NULL) {} + Wrapper_Nuage_Noeud(int nn, double *n):nbr_noeuds(nn),noeuds(n),show(noeuds) {} + ~Wrapper_Nuage_Noeud() {} + Wrapper_Noeud & operator [] (int i) + { + show.positionne((double *) &noeuds[DIMENSION*i]); + return show; + } + int size() const {return nbr_noeuds;} + int SIZE() const {return nbr_noeuds;} + void affiche() + { + int i,j; + for (i=0;i +#define _DTREE_ dTree + +////////////////////////////////////////////////////////////////// +/// /// +/// DECLARATIONS /// +/// /// +////////////////////////////////////////////////////////////////// + +/*********************************************************/ +/* */ +/* Calcul Statique de Puissance */ +/* */ +/*********************************************************/ + +// Permet de Calculer 2^n de façon statique + +template < int DIMENSION > struct DeuxPuissance + { + enum { valeur = 2 * DeuxPuissance::valeur } ; + }; + +template <> struct DeuxPuissance<0> + { + enum { valeur = 1 } ; + }; + +/*********************************************************/ +/* */ +/* DTREE */ +/* */ +/*********************************************************/ + +// Construit un d-Tree sur un nuage de noeud et pour un noeud donné donne lequel des noeuds du nuage est le plus proche + +// # Bugs connus : +// - Problemes avec points sur les faces des hypercubes ? +// - Plantage sauvage si le point est plus loin de l'hypercube père que le diametre Linf de celui-ci. +// # Politique de classe : +// - NOEUD : voir dans MEDMEM_WrapperNodes.hxx la classe Wrapper_Noeud<..> +// - NUAGENOEUD : typiquement, c'est vector en rédefinissant NUAGENOEUD<...>::SIZE()=vector<...>::size() +// Remarques : +// - NBR_NOEUDS_PAR_CASE ne doit pas être modifié sauf peut-être dans le cas où l'utilisateur veut utiliser des d-Tree parallèles +// ou utilise des nuages de noeud trop grands + +template class dTree +{ +protected : + // types + typedef _DTREE_ * Ptr_dTree; + // Static Const + static const int nbr_descendants=DeuxPuissance::valeur; + // champs + NUAGENOEUD * nuage; + Ptr_dTree descendant[nbr_descendants]; + // numéro des noeuds contenus + vector * noeud_contenu; + int etat; + int niveau; + dTree * pere; + // extrémités de l'hypercube du dTree + Sommet_dTree coord_max; + Sommet_dTree coord_min; +public : + + void init(); + dTree(); + // Ce constructeur est le seul constructeur utilisateur, il construit le père puis tous les descendants + dTree(NUAGENOEUD *n); + // Ce Constructeur est utilisé par le précédent, pour un pere donné, avec deux extrémités données, + // il instantie un dTree sans en calculer les noeuds contenus + dTree(const Sommet_dTree &A,const Sommet_dTree &B,dTree *mypere); + dTree(const dTree &F); + ~dTree(); + // Renvoie les numéros de noeuds contenus dans le dTree + void Get_Noeuds_Filtre(vector &tmp); + // renvoie les extrémités + Sommet_dTree Get_Max() const; + Sommet_dTree Get_Min() const; + // renvoie vrai si P est dans le dTree + int is_in_dTree(NOEUD P) const; + // calcule la distance topologique locale de P au dTree + double calcule_distance(NOEUD P) const; + dTree & operator = (const dTree & F); + // retourne le sommet du dTree codé par l'entier selecteur (voir explications dans le code) + Sommet_dTree donne_sommet(int selecteur) const; + int a_des_fils() const; + // renvoi une reference sur le dTree terminal descendant de this contenant P + dTree * trouve_dTree_contenant(NOEUD P) const; + // renvoie le point le plus proche de P dans this par la méthode exhaustive brutale + int trouve_plus_proche_point_bourrin(NOEUD P) const; + // renvoie le point le plus proche de p dans this par la méthode dtree + int trouve_plus_proche_point(NOEUD P) const; + // renvoie un numéro de point contenu dans this + int trouve_un_point() const; + // méthode récursive utilisée par trouve_plus_proche_point + int tppp_rec(NOEUD P,double &delta,int &flag) const; + // dit si P est d-proche de l'hypercube de this + int Localise_Point(NOEUD P,double d) const; + // utilisé par le constructeur pour créer tout la filiation du dTree + void cree_filiation(); + // méthodes de mesure + int Get_Nbr_Descendants_Non_Vides() const; + int Get_Nbr_Descendants_Vides() const; + int Get_Profondeur_Max() const; +}; + + +////////////////////////////////////////////////////////////////// +/// /// +/// CODE /// +/// /// +////////////////////////////////////////////////////////////////// + +_TEMPLATE_ void _DTREE_::init() + { + int i; + nuage=NULL; + noeud_contenu=NULL; + etat=DTREE_FANTOME; + for (i=0;i(nuage->size()); + niveau=0; + + // calcule les extrémités du dTree pere + for (i=0;isize();i++) + { + (*noeud_contenu)[i]=i; + for (j=0;jcoord_max[j]) coord_max[j]=(*nuage)[i][j]; + if ((*nuage)[i][j] &A,const Sommet_dTree &B,dTree *mypere) + { + if (mypere!=NULL) + { + + int i,j; + double tmp; + + init(); + + pere=mypere; + nuage=pere->nuage; + niveau=pere->niveau+1; + + etat=DTREE_COURANT; + + noeud_contenu=new vector; + noeud_contenu->reserve((pere->noeud_contenu->size())/nbr_descendants); + + for (i=0;iB[i]) + { + coord_max[i]=A[i]; + coord_min[i]=B[i]; + } + else + { + coord_min[i]=A[i]; + coord_max[i]=B[i]; + } + } + } + else + { + cerr<<"DTREE : Construction de descendance sans père !"< &tmp) + { + int i; + switch (etat) + { + case DTREE_RACINE : int pourlefunlecompilolesttropcon; + case DTREE_COURANT : + for (i=0;iGet_Noeuds_Filtre(tmp); + case DTREE_TERMINAL : + if (noeud_contenu->size()>0) + { + for (i=0;i _DTREE_::Get_Max() const + { + return coord_max; + } +_TEMPLATE_ Sommet_dTree _DTREE_::Get_Min() const + { + return coord_min; + } +_TEMPLATE_ int _DTREE_::is_in_dTree(NOEUD P) const + { + int test; + for (int i=0;itmp) min=tmp; + tmp=fabs(coord_min[i]-P[i]); + if (min>tmp) min=tmp; + } + return min; + } +_TEMPLATE_ _DTREE_ & _DTREE_::operator = (const _DTREE_ & F) + { + // Pas Super Top Moumoute ... Recopie de pointeurs et pas de contenus, merdique + int i,j; + init(); + for (i=0;i _DTREE_::donne_sommet(int selecteur) const + { + Sommet_dTree p; + int i; + int residu=selecteur; + int reste; + for (i=0;i B(coord_min,coord_max); + int i; + if ((etat==DTREE_RACINE)&&(!is_in_dTree(P))) return NULL; // Le noeud est extérieur a l'dTree + else if (etat==DTREE_TERMINAL) return (dTree *) this; // Le noeud est dans *this qui est terminal + + for (i=0;i A=donne_sommet(i); + int test,j; + for (j=0;j=P[j])&&(P[j]>=B[j])); + if (!test) break; + } + + if (test) return descendant[i]->trouve_dTree_contenant(P); // Propagation + } + } +// si de le dTree n'est pas TERMINAL, scanne tous les points du nuage du pere pour trouver le point le plus proche +// sinon scanne uniquement les points contenus dans le dTree +_TEMPLATE_ int _DTREE_::trouve_plus_proche_point_bourrin(NOEUD P) const + { + int i; + int num_sol=0; + double min; + double tmp; + if (etat!=DTREE_TERMINAL) + { + min=DistanceL2(P,(*nuage)[0]); + for (i=1;isize();i++) + { + tmp=DistanceL2(P,(*nuage)[i]); + if (tmpsize()!=0) + { + num_sol=(*noeud_contenu)[0]; + min=DistanceL2(P,(*nuage)[num_sol]); + for (i=1;isize();i++) + { + tmp=DistanceL2(P,(*nuage)[(*noeud_contenu)[i]]); + if (tmppere!=NULL) + { + delta=DistanceInf((ref->pere->coord_max),(ref->pere->coord_min)); + } + else + { + cerr<<"DTREE : TROUVE PLUS PROCHE POINT : l'octree contenant le noeud n'a pas de pere !"<size()>0) return (*(noeud_contenu))[0]; + } + else + { + int i; + for (i=0;itrouve_un_point(); + } + } + } +// partie recursive de trouve_plus_proche_point +// change le flag en 1 si un point plus proche est trouvé +// adapte automatiquement la distance delta de filtrage +_TEMPLATE_ int _DTREE_::tppp_rec(NOEUD P,double &delta,int &flag) const + { + if (Localise_Point(P,delta)==0) + { + + // La distance du point à l'octree est plus grande que delta + + return DTREE_FANTOME; + } + int num_Ptmp; + double dtmp; + if (etat==DTREE_TERMINAL) + { + if (noeud_contenu->size()>0) + { + num_Ptmp=trouve_plus_proche_point_bourrin(P); + dtmp=DistanceL2((*nuage)[num_Ptmp],P); + if (dtmp<=delta) + { + + // Le point le plus proche minimise delta, c'est un bon candidat, on l'envoie ! + + delta=dtmp; + flag=1; + return num_Ptmp; + } + + // Le point le plus proche ne minimise pas delta + + // ===========> peut etre rajouter exit(-1); ?????????? + return DTREE_FANTOME; + } + else + { + + // L'octree qui contient P ne contient aucun point + + return DTREE_FANTOME; + } + } + int i; + int num_sol=DTREE_FANTOME; + for (i=0;itppp_rec(P,delta,flag); + if ((num_Ptmp!=DTREE_FANTOME)&&(flag==1)) + { + + // On a trouvé un point qui minimise delta dans une branche + + num_sol=num_Ptmp; + } + } + // A ce stade, on a trouvé un point qui minimise tous les deltas, c'est donc le point le plus proche + // REMARQUE : cette affirmation est à la base de l'algorithme par dTree mais est loin d'étre évidente + + return num_sol; + } + +// renvoie 1 si la distance L inf du noeud a l'octree est plus petite que d, 0 sinon +_TEMPLATE_ int _DTREE_::Localise_Point(NOEUD P,double d) const + { + int i; + for (i=0;icoord_max[i]+d) return 0; + if (P[i]niveau+1; + } + else + { + niveau=0; + } + + if (noeud_contenu->size()<=NBR_NOEUDS_PAR_CASE) + { + etat=DTREE_TERMINAL; + } + else + { + int i,num_loc,test; + + Sommet_dTree centre(coord_max,coord_min); + + for (i=0;isize();num_loc++) + { + int indice=(*noeud_contenu)[num_loc]; + NOEUD & courant=(*nuage)[indice]; + test=1; + for (i=0;(test)&&(iis_in_dTree(courant)) + { + descendant[i]->noeud_contenu->push_back(indice); + test=0; + } + } + } + + delete noeud_contenu; + noeud_contenu=NULL; + + for (i=0;icree_filiation(); + } + } +_TEMPLATE_ int _DTREE_::Get_Nbr_Descendants_Non_Vides() const + { + int i; + int ndnv=0; + switch (etat) + { + case DTREE_RACINE : int pourlefunlecompilolesttropcon; + case DTREE_COURANT : + for (i=0;iGet_Nbr_Descendants_Non_Vides(); + return ndnv; + case DTREE_TERMINAL : + if (noeud_contenu->size()>0) return 1; + else return 0; + default : + cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<Get_Nbr_Descendants_Vides(); + return ndnv; + case DTREE_TERMINAL : + if (noeud_contenu->size()==0) return 1; + else return 0; + default : + cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"<Get_Profondeur_Max(); + if (tmp>prof) prof=tmp; + } + return prof; + case DTREE_TERMINAL : return niveau; + default : + cerr<<"dTree Non Valide dans Get_Nbr_Descendants_Non_Vides"< class Sommet_dTree +{ +protected : + double coord[DIMENSION]; +public : + Sommet_dTree() + { + } + Sommet_dTree(double *c) + { + for (int i=0;i &A,const Sommet_dTree &B) + { + double max=0; + double tmp; + for (int i=0;imax) max=tmp; + } + return max; + } +}; + +#endif diff --git a/src/INTERPOLATION/Makefile.in b/src/INTERPOLATION/Makefile.in new file mode 100644 index 000000000..5d1842801 --- /dev/null +++ b/src/INTERPOLATION/Makefile.in @@ -0,0 +1,102 @@ +# MED MEDMEM : MED files in memory +# +# Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Module : MED + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:$(srcdir):$(srcdir)/tests + +MACHINE=PCLINUX + +@COMMENCE@ + + +EXPORT_PYSCRIPTS = \ + + +EXPORT_HEADERS = \ +MEDMEM_dTree.hxx\ +MEDMEM_dTreeSommet.hxx\ +MEDMEM_InterpolationHighLevelObjects.hxx\ +MEDMEM_Interpolation.hxx\ +MEDMEM_InterpolationTools.hxx\ +MEDMEM_Mapping.hxx\ +MEDMEM_MappingTools.hxx\ +MEDMEM_WrapperCells.hxx\ +MEDMEM_WrapperConnectivity.hxx\ +MEDMEM_WrapperField.hxx\ +MEDMEM_WrapperMesh.hxx\ +MEDMEM_WrapperNodes.hxx + + +# Libraries targets + +LIB= +LIB_SRC = + + +# Executables targets +BIN = +BIN_SRC = +BIN_SERVER_IDL = +BIN_CLIENT_IDL = + +TEST_PROGS = \ +test_MEDMEM_InterpolationFlipBack\ +test_MEDMEM_InterpolationFromMesh_toMesh\ +test_MEDMEM_InterpolationRecopieMaillage\ +test_MEDMEM_InterpolationSansRecopieMaillage\ +test_MEDMEM_InterpolationTimeStep\ +UseCasedTree\ +UseCaseInterpolationts\ +UseCaseInterpolationwots\ +UseCaseMapping\ +UseCaseWrapper_Maillage + + + + +CPPFLAGS+=-U_DEBUG_ $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I../ +CXXFLAGS+=-U_DEBUG_ -ftemplate-depth-42 -I${KERNEL_ROOT_DIR}/include/salome +#LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSalomeLoggerServer -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lSALOMELocalTrace -L${KERNEL_ROOT_DIR}/lib/salome + +#LDFLAGSFORBIN+=$(MED2_LIBS) $(HDF5_LIBS) -L../.libs -lmedmem -lSalomeLoggerServer -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGSFORBIN+=$(MED2_LIBS) $(HDF5_LIBS) -L../.libs -lmedmem -lSALOMELocalTrace -L${KERNEL_ROOT_DIR}/lib/salome + +LIBSFORBIN= + +LDFLAGS= + +LIBS= + +# build create_mesh : +bin: create_mesh_interpolation + +create_mesh_interpolation: %: %.c + $(CC) $(CFLAGS) $(CPPFLAGS) -o $@ $(MED2_LIBS) $(HDF5_LIBS) $< + +@CONCLUDE@ diff --git a/src/INTERPOLATION/UseCaseInterpolationts.cxx b/src/INTERPOLATION/UseCaseInterpolationts.cxx new file mode 100644 index 000000000..288cd72de --- /dev/null +++ b/src/INTERPOLATION/UseCaseInterpolationts.cxx @@ -0,0 +1,78 @@ +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" + +#include "MEDMEM_Med.hxx" +#include "MEDMEM_Field.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Interpolation.hxx" + +#include + +#include "stdio.h" + +main () { + + const char * fromFileName = "ResultatSyrthes.med"; + const char * toFileName = "MaillageAster.med"; + const char * resultFileName = "ResultatInterpolation.med"; + + const char * fromFieldName = "THERDEP_TEMP____________________"; + + const char * fromMeshName = "MA"; + const char * toMeshName = "MAILLAGE_IDEAS"; + int handle; + + try { + + + MED fromMED(MED_DRIVER,fromFileName); + + fromMED.updateSupport(); + + MESH toMesh(MED_DRIVER,toFileName,toMeshName); + + deque pasDeTemps=fromMED.getFieldIteration (fromFieldName); + + deque::const_iterator currentStep; + + INTERPOLATION<3> * myInter ; + FIELD * toField ; + int flagNewMapping = 1; + + for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++) + { + FIELD_ * fromField_ = fromMED.getField(fromFieldName,(*currentStep).dt,(*currentStep).it) ; + + FIELD * fromField = dynamic_cast *>(fromField_); + + fromField->getSupport()->getMesh()->read(); + + fromField->read(); + + if (currentStep==pasDeTemps.begin()) + { + myInter = new INTERPOLATION<3>(*fromField,toMesh) ; + + toField = myInter->interpolate(1,1); + } + else + { + toField = myInter->interpolateNextStep(*fromField,flagNewMapping); + } + + toField->addDriver(MED_DRIVER,resultFileName,toField->getName()); + + toField->write(); + + if (flagNewMapping==1) + { + handle = toMesh.addDriver(MED_DRIVER,resultFileName,toMesh.getName()) ; + + toMesh.write(handle); + } + } + + } catch (MEDEXCEPTION& ex){ + MESSAGE(ex.what()) ; + } +} diff --git a/src/INTERPOLATION/UseCaseInterpolationwots.cxx b/src/INTERPOLATION/UseCaseInterpolationwots.cxx new file mode 100644 index 000000000..67a3b790c --- /dev/null +++ b/src/INTERPOLATION/UseCaseInterpolationwots.cxx @@ -0,0 +1,43 @@ +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" + +#include "MEDMEM_Field.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Interpolation.hxx" + +#include "stdio.h" + +using namespace MEDMEM; + +main () { + + const char * fromFileName = "fromMesh.med"; + const char * toFileName = "toMesh.med"; + const char * fieldName = "fieldnodedouble"; + + const char * fromMeshName = "fromMesh"; + const char * toMeshName = "toMesh"; + + const int flagConvex = 1; + const int interpolationType = 1; + + try { + + MESH fromMesh (MED_DRIVER,fromFileName,fromMeshName); + SUPPORT fromSupport (&fromMesh,"XsupportX",MED_NODE); + FIELD fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName); + MESH toMesh (MED_DRIVER,toFileName,toMeshName); + + INTERPOLATION<3> myInter (fromField,toMesh); + + FIELD * toField = myInter.interpolate(interpolationType,flagConvex); + + toField->addDriver(MED_DRIVER,toFileName,toField->getName()) ; + + toField->write(); + + + } catch (MEDEXCEPTION& ex){ + MESSAGE(ex.what()) ; + } +} diff --git a/src/INTERPOLATION/UseCaseMapping.cxx b/src/INTERPOLATION/UseCaseMapping.cxx new file mode 100644 index 000000000..0c98da028 --- /dev/null +++ b/src/INTERPOLATION/UseCaseMapping.cxx @@ -0,0 +1,50 @@ +#include "stdio.h" +#include "stdlib.h" + +#include + +#include "MEDMEM_InterpolationHighLevelObjects.hxx" + +int main (void) +{ +int i; + +const int DIMENSION = 3; + +const int isConvexFromMesh = 1; + +const char * fromFileName = "fromMesh.med"; +const char * fromMeshName = "fromMesh"; + +MESH * fromMesh = new MESH(MED_DRIVER,fromFileName,fromMeshName); + +const char * toFileName = "toMesh.med"; +const char * toMeshName = "toMesh"; + +MESH * toMesh = new MESH(MED_DRIVER,toFileName,toMeshName); + +Meta_Wrapper * fromWrapper = new Meta_Wrapper + ( + fromMesh->getNumberOfNodes(), + const_cast (fromMesh->getCoordinates(MED_FULL_INTERLACE)), + const_cast (fromMesh->getConnectivityptr()) + ); + +Meta_Wrapper * toWrapper = new Meta_Wrapper + ( + toMesh->getNumberOfNodes(), + const_cast (toMesh->getCoordinates(MED_FULL_INTERLACE)) + ); + +Meta_Mapping * mapping = new Meta_Mapping (fromWrapper,toWrapper); + +mapping->Cree_Mapping(isConvexFromMesh); + +vector vectormapping = mapping->Get_Mapping(); + +for (i=0;i + +#include "MEDMEM_InterpolationHighLevelObjects.hxx" + +int main (void) +{ +int i,j; + +const char * fromFileName = "fromMesh.med"; +const char * fromMeshName = "fromMesh"; + +MESH fromMesh(MED_DRIVER,fromFileName,fromMeshName); + +Meta_Nuage_Maille * nuagemailles = new Meta_Nuage_Maille(const_cast (fromMesh.getConnectivityptr())); + +int nbr_noeuds = fromMesh.getNumberOfNodes(); + +Meta_Maillage * maillage = new Meta_Maillage(nuagemailles,nbr_noeuds); + +int nbr_mailles = maillage->DONNE_POINTEUR_NUAGEMAILLE()->SIZE(); + +int nbr_faces; + +for (i=0;iDONNE_NBR_FACES_MAILLE(i); + for (j=0;jDONNE_VOISIN_DE_MAILLE(i,j)<<"]-("<EST_AU_BORD_FACE_DE_MAILLE(i,j)<<") "< + +#include "MEDMEM_InterpolationHighLevelObjects.hxx" + +#define affiche(NOEUD) cout< +#include + +#define MED_NOPG 1 /* -> pas de point de Gauss */ +#define MED_NOPFL "" /* -> pas de profils utilisateur */ +#define MED_NOPFLi " " /* Variable Interne */ +#define MED_NOPF 0 /* -> pas de profils pour _MEDdataseNnumEcrire */ +#define MED_NOPDT -1 /* rem: pas de pas de temps negatifs */ +#define MED_NONOR -1 /* rem: pas de n°ordre negatif */ +#define MED_DIM1 1 /* PAS */ + +#define MED_ALL 0 + +/*****************************************************************************************************/ + +void affiche_noeuds(med_float * nodes,int nnpl) + { + int nbr_nodes=nnpl*nnpl*nnpl; + int i; + + for (i=0;i=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);} + if (3*num_noeud+1>=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);} + if (3*num_noeud+2>=3*nbr_nodes) {printf("%d : OUT OF RANGE REQUEST\n",num_noeud);exit(-1);} + + coord_nodes[3*num_noeud ]= (double) (i+flag)/diviseur; + coord_nodes[3*num_noeud+1]= (double) (j+flag)/diviseur; + coord_nodes[3*num_noeud+2]= (double) (k+flag)/diviseur; + } + + affiche_noeuds(coord_nodes,nnpl); + + } +void cree_num_nodes(med_int * num_nodes,int nnpl) + { + int nbr_nodes=nnpl*nnpl*nnpl; + int i; + /*num_nodes=(med_int *) malloc(nbr_nodes*sizeof(med_int));*/ + for (i=0;i=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + if (8*num_hexa8+1>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + if (8*num_hexa8+2>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + if (8*num_hexa8+3>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + if (8*num_hexa8+4>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + if (8*num_hexa8+5>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + if (8*num_hexa8+6>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + if (8*num_hexa8+7>=8*nbr_hexa8) {printf("%d : OUT OF RANGE REQUEST\n",num_hexa8);exit(-1);} + + conn_hexa8[8*num_hexa8 ] = num_nodes[ i0+nnpl*j1+nnpl*nnpl*k1 ]; + conn_hexa8[8*num_hexa8+1] = num_nodes[ i0+nnpl*j0+nnpl*nnpl*k1 ]; + conn_hexa8[8*num_hexa8+2] = num_nodes[ i1+nnpl*j0+nnpl*nnpl*k1 ]; + conn_hexa8[8*num_hexa8+3] = num_nodes[ i1+nnpl*j1+nnpl*nnpl*k1 ]; + conn_hexa8[8*num_hexa8+4] = num_nodes[ i0+nnpl*j1+nnpl*nnpl*k0 ]; + conn_hexa8[8*num_hexa8+5] = num_nodes[ i0+nnpl*j0+nnpl*nnpl*k0 ]; + conn_hexa8[8*num_hexa8+6] = num_nodes[ i1+nnpl*j0+nnpl*nnpl*k0 ]; + conn_hexa8[8*num_hexa8+7] = num_nodes[ i1+nnpl*j1+nnpl*nnpl*k0 ]; + + + } + + for (num_hexa8=0;num_hexa8 0 + - les numeros de familles des elements sont < 0 + - rien d'imposer sur les noms de familles + */ + +/* la famille 0 */ + if (ret == 0) + { + strcpy(nomfam,"FAMILLE_0"); + numfam = 0; + ret = MEDfamCr(fromfid,frommaa,nomfam,numfam,&attide,&attval,attdes,0,gro,0); + } + printf("MEDfamCr : %d \n",ret); +/*****************************************************************************************************/ + + if (ret == 0) + { + strcpy(nomfam,"FAMILLE_0"); + numfam = 0; + ret = MEDfamCr(tofid,tomaa,nomfam,numfam,&attide,&attval,attdes,0,gro,0); + } + printf("MEDfamCr : %d \n",ret); + +/*****************************************************************************************************/ +/* Les champs */ + + if (ret == 0) + { + ret = MEDchampCr(fromfid,champnode,MED_REEL64,champnode_comp,champnode_unit,1); + printf("MEDchampCr : %d \n",ret); + if (ret == 0) + { + ret = MEDchampEcr(fromfid, frommaa, champnode, (unsigned char *)fieldnodedouble, + MED_FULL_INTERLACE, fromnnoe, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, + 0, MED_NOPDT," ", 0. , MED_NONOR); + printf("MEDchampEcr : %d \n",ret); + } + } + + if (ret == 0) + { + ret = MEDchampCr(fromfid,champcell,MED_REEL64,champcell_comp,champcell_unit,3); + printf("MEDchampCr : %d \n",ret); + if (ret == 0) + { + ret = MEDchampEcr(fromfid, frommaa, champcell, (unsigned char *)fieldcelldoublevector, + MED_FULL_INTERLACE, fromnhexa8, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR); + printf("MEDchampEcr : %d \n",ret); + } + } + + if (ret == 0) + { + ret = MEDchampCr(fromfid,champcellscalar,MED_REEL64,champcellscalar_comp,champcellscalar_unit,1); + printf("MEDchampCr : %d \n",ret); + if (ret == 0) + { + ret = MEDchampEcr(fromfid, frommaa, champcellscalar, (unsigned char *)fieldcelldouble, + MED_FULL_INTERLACE, fromnhexa8, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR); + printf("MEDchampEcr : %d \n",ret); + } + } + + if (ret == 0) + { + ret = MEDchampCr(fromfid,champnodevector,MED_REEL64,champnodevector_comp,champnodevector_unit,3); + printf("MEDchampCr : %d \n",ret); + if (ret == 0) + { + ret = MEDchampEcr(fromfid, frommaa, champnodevector, (unsigned char *)fieldnodedoublevector, + MED_FULL_INTERLACE, fromnnoe, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, + 0, MED_NOPDT," ", 0. , MED_NONOR); + printf("MEDchampEcr : %d \n",ret); + } + } + + +/***************************************************************************/ +ret = MEDfermer(fromfid); +printf("MEDfermer : %d\n",ret); +/***************************************************************************/ +ret = MEDfermer(tofid); +printf("MEDfermer : %d\n",ret); + +return 0; +} + diff --git a/src/INTERPOLATION/test_MEDMEM_Interpolation.cxx b/src/INTERPOLATION/test_MEDMEM_Interpolation.cxx new file mode 100644 index 000000000..5d8112d8e --- /dev/null +++ b/src/INTERPOLATION/test_MEDMEM_Interpolation.cxx @@ -0,0 +1,56 @@ +#include "MEDMEM_Exception.hxx" +#include "MEDMEM_define.hxx" + +#include "MEDMEM_Field.hxx" +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_Interpolation.hxx" + +#include "stdio.h" + +main () { + + const char * fromFileName = "fromMesh.med"; + const char * toFileName = "toMesh.med"; + //const char * fieldName = "fieldcelldoublevector"; + const char * fieldName = "fieldnodedouble"; + + const char * fromMeshName = "fromMesh"; + const char * toMeshName = "toMesh"; + + try { + + cout<<"Lecture du Maillage Source : "< fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName); cout<<"OK !"< myInter (fromField,toMesh); + + //FIELD * toField = myInter.interpolate(0,1); + FIELD * toField = myInter.interpolate(1,1); + + cout<<"Creation du driver"<addDriver(MED_DRIVER,toFileName,toField->getName()) ; + + cout<<"toField->getName() = "<getName() <getDescription() = "<getDescription() <getNumberOfComponents() = "<getNumberOfComponents() <getNumberOfValues() = "<getNumberOfValues() <getComponentsNames() = "<getComponentsNames() <getComponentsDescriptions() = "<getComponentsDescriptions()<getMEDComponentsUnits() = "<getMEDComponentsUnits() <getIterationNumber() = "<getIterationNumber() <getTime() = "<getTime() <getOrderNumber() = "<getOrderNumber() <getValueType() = "<getValueType() <write(); + + cout<<"Fin"< + +#include "stdio.h" + +using namespace MEDMEM; + +// pour gestion timings +#include "time.h" + +#define RUN(procedure) {double t0,t1;cout<<"# =============> TEMPS D'EXECUTION A PARTIR D'ICI "< TEMPS D'EXECUTION : "< v) + { + double tmp=0; + int i; + for (i=0;i v1,Valeur v2) + { + double tmp=0; + int i; + for (i=0;i * firstField, FIELD * secondField) + { + Wrapper_MED_Field first ( firstField); + Wrapper_MED_Field second (secondField); + int nbr_valeurs_first = first.Get_Nbr_Valeurs(); + int nbr_valeurs_second = second.Get_Nbr_Valeurs(); + + double max1 = 0; + double max2 = 0; + + double min1 = ABS(first[0]); + double min2 = ABS(second[0]); + + int imax1,imax2; + + double tmp; + + int i; + + //cout<>tyty; + + if (nbr_valeurs_first!=nbr_valeurs_second) + { + cerr<<"Les champs à soustraire n'ont pas le meme nombre de valeurs"< pasDeTemps=fromMED.getFieldIteration (fromFieldName); + cout<<"OK !"<::const_iterator currentStep; + + INTERPOLATION<3> * interFromTo ; + INTERPOLATION<3> * interToFrom ; + FIELD * toField ; + FIELD * toToField ; + int flagNewMappingFromTo = 0; + int flagNewMappingToFrom = 0; + + for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++) + { + cout< * fromField = dynamic_cast *>(fromField_); + cout<<"OK !"<getSupport()->getMesh()->read()); + } + + MESH * fromMesh = fromField->getSupport()->getMesh(); + + cout<read()); + cout<<"OK !"<(*fromField,toMesh)); + cout<<"OK !"<interpolate(1,1)); + cout<<"OK !"<(*toField,*fromMesh)); + cout<<"OK !"<interpolate(1,1)); + cout<<"OK !"<interpolateNextStep(*fromField,flagNewMappingFromTo)); + cout<<"OK !"<interpolateNextStep(*toField,flagNewMappingToFrom)); + cout<<"OK !"<addDriver(MED_DRIVER,resultFileName,toToField->getName()); + cout<<"OK !"<write(); + cout<<"OK !"<addDriver(MED_DRIVER,resultFileName,fromMesh->getName()) ; + cout<<"OK !"<write(handle); + cout<<"OK !"< fromField (&fromSupport,MED_DRIVER,fromFileName,fieldName); cout<<"OK !"< myInter (fromField,toMesh); + + //FIELD * toField = myInter.interpolate(0,1); + FIELD * toField = myInter.interpolate(1,1); + + cout<<"Creation du driver"<addDriver(MED_DRIVER,toFileName,toField->getName()) ; + + cout<<"toField->getName() = "<getName() <getDescription() = "<getDescription() <getNumberOfComponents() = "<getNumberOfComponents() <getNumberOfValues() = "<getNumberOfValues() <getComponentsNames() = "<getComponentsNames() <getComponentsDescriptions() = "<getComponentsDescriptions()<getMEDComponentsUnits() = "<getMEDComponentsUnits() <getIterationNumber() = "<getIterationNumber() <getTime() = "<getTime() <getOrderNumber() = "<getOrderNumber() <getValueType() = "<getValueType() <write(); + + cout<<"Fin"< + +#include "stdio.h" + + + +// pour gestion timings +#include "time.h" + +#define RUN(procedure) {double t0,t1;cout<<"# =============> TEMPS D'EXECUTION A PARTIR D'ICI "< TEMPS D'EXECUTION : "< pasDeTemps=fromMED.getFieldIteration (fromFieldName); + cout<<"OK !"<::const_iterator currentStep; + + INTERPOLATION<3> * myInter ; + FIELD * toField ; + int flagNewMapping = 1; + + for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++) + { + cout< * fromField = dynamic_cast *>(fromField_); + cout<<"OK !"<getSupport()->getMesh()->read()); + } + + cout<read()); + cout<<"OK !"<(*fromField,toMesh)); + cout<<"OK !"<interpolate(1,1)); + cout<<"OK !"<interpolateNextStep(*fromField,flagNewMapping)); + cout<<"OK !"<addDriver(MED_DRIVER,resultFileName,toField->getName()); + cout<<"OK !"<write(); + cout<<"OK !"< + +#include "stdio.h" + +main () { + + const char * fromFileName = "ResultatSyrthes.med"; + const char * toFileName = "MaillageAster.med"; +// const char * resultFileName = "ResultatInterpolation.med"; + + const char * fromFieldName = "THERDEP_TEMP____________________"; + + const char * fromMeshName = "MA"; + const char * toMeshName = "MAILLAGE_IDEAS"; + + try { + + string flag="================[MAIN MESSAGES]================> "; + + cout< pasDeTemps=fromMED.getFieldIteration (fromFieldName) ; cout<<"OK !"< * fromField = dynamic_cast *>(fromField_) ; cout<<"OK !"<getSupport()->getMesh()->read(); + + cout<read() ; cout<<"OK !"< myInter (*fromField,toMesh) ; cout<<"OK !"< * toField = myInter.interpolate(1,1) ; cout<<"OK !"<addDriver(MED_DRIVER,toFileName,toField->getName()) ; cout<<"OK !"<addDriver(MED_DRIVER,resultFileName,toField->getName()) ; cout<<"OK !"<write() ; cout<<"OK !"< + +#include "stdio.h" + +main () { + + const char * fromFileName = "ResultatSyrthes.med"; + const char * toFileName = "MaillageAster.med"; + const char * resultFileName = "ResultatInterpolation.med"; + + const char * fromFieldName = "THERDEP_TEMP____________________"; + + const char * fromMeshName = "MA"; + const char * toMeshName = "MAILLAGE_IDEAS"; + int handle; + + try { + + string flag="================[MAIN MESSAGES]================> "; + + cout< pasDeTemps=fromMED.getFieldIteration (fromFieldName); + cout<<"OK !"<::const_iterator currentStep; + + INTERPOLATION<3> * myInter ; + FIELD * toField ; + int flagNewMapping = 1; + + for (currentStep=pasDeTemps.begin();currentStep!=pasDeTemps.end();currentStep++) + { + cout< * fromField = dynamic_cast *>(fromField_); + cout<<"OK !"<getSupport()->getMesh()->read(); + + cout<read(); + cout<<"OK !"<(*fromField,toMesh) ; + cout<<"OK !"<interpolate(1,1); + cout<<"OK !"<interpolateNextStep(*fromField,flagNewMapping); + cout<<"OK !"<addDriver(MED_DRIVER,resultFileName,toField->getName()); + cout<<"OK !"<write(); + cout<<"OK !"<_this() ; // if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR) ; - if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ; +// if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ; // create ::MED object, read all and add in study ! myMedI->init(myStudy,MED_DRIVER,fileName) ; } @@ -209,7 +211,9 @@ SALOME_MED::MED_ptr Med_Gen_i::readStructFile (const char* fileName, THROW_SALOME_CORBA_EXCEPTION("Unable to open File "\ ,SALOME::BAD_PARAM); } - return SALOME_MED::MED::_duplicate(myMedIOR) ; + + endService("Med_Gen_i::readStructFile"); + return myMedIOR; } //============================================================================= @@ -222,7 +226,9 @@ void Med_Gen_i::readStructFileWithFieldType (const char* fileName, const char* studyName) throw (SALOME::SALOME_Exception) { - BEGIN_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)"); + beginService("Med_Gen_i::readStructFileWithFieldType"); + + BEGIN_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)"); SCRUTE(fileName); SALOMEDS::Study_var myStudy = studyName2Study(studyName) ; @@ -246,6 +252,7 @@ throw (SALOME::SALOME_Exception) ,SALOME::BAD_PARAM); } + endService("Med_Gen_i::readStructFileWithFieldType"); END_OF("Med_Gen_i::readStructFileWithFieldType (const char* fileName,const char* studyName)"); @@ -261,10 +268,11 @@ SALOME_MED::MESH_ptr Med_Gen_i::readMeshInFile(const char* fileName, const char* meshName) throw (SALOME::SALOME_Exception) { + beginService("Med_Gen_i::readMeshInFile"); SCRUTE(fileName); SALOMEDS::Study_var myStudy = studyName2Study(studyName) ; - if (!_duringLoad) addInStudy(myStudy) ; +// if (!_duringLoad) addInStudy(myStudy) ; // Creation du maillage @@ -301,10 +309,12 @@ throw (SALOME::SALOME_Exception) try { // add the mesh object in study - if (!_duringLoad) meshi->addInStudy(myStudy,mesh); +// if (!_duringLoad) meshi->addInStudy(myStudy,mesh); } catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {} - return SALOME_MED::MESH::_duplicate(mesh); + + endService("Med_Gen_i::readMeshInFile"); + return mesh; } //============================================================================= /*! @@ -318,6 +328,7 @@ SALOME_MED::FIELD_ptr Med_Gen_i::readFieldInFile(const char* fileName, CORBA::Long iter) throw (SALOME::SALOME_Exception) { + beginService("Med_Gen_i::readFieldInFile"); SCRUTE(fileName); string myStudyName(studyName); @@ -373,7 +384,7 @@ throw (SALOME::SALOME_Exception) // Creation du champ - FIELD_ * myField= new FIELD_() ; + FIELD_ * myField; MED * mymed = new MED(MED_DRIVER,fileName) ; try { @@ -407,7 +418,6 @@ throw (SALOME::SALOME_Exception) }; SUPPORT * fieldSupport; - SALOME_MED::SUPPORT_ptr mySupportIOR; try { fieldSupport=(SUPPORT *)myField->getSupport() ; @@ -417,8 +427,6 @@ throw (SALOME::SALOME_Exception) myMesh->read(); SCRUTE(myMesh->getName()); fieldSupport->update(); - SUPPORT_i * mySupportI = new SUPPORT_i(fieldSupport); - mySupportIOR=mySupportI->_this(); } catch (const exception & ex) { @@ -435,11 +443,11 @@ throw (SALOME::SALOME_Exception) try { ((FIELD*)myField)->read() ; - FIELDINT_i * myFieldIntI = new FIELDINT_i(mySupportIOR,(FIELD*)myField); - POA_SALOME_MED::FIELD_tie * myFieldTie = new POA_SALOME_MED::FIELD_tie(myFieldIntI); - SALOME_MED::FIELD_ptr myFieldIOR = myFieldTie->_this() ; - if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ; - return SALOME_MED::FIELD::_duplicate(myFieldIOR); + FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); + SALOME_MED::FIELD_ptr myFieldIOR = myFieldIntI->_this(); +// if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ; + endService("Med_Gen_i::readFieldInFile"); + return myFieldIOR; } catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {} catch (const exception & ex) @@ -455,11 +463,11 @@ throw (SALOME::SALOME_Exception) try { ((FIELD*)myField)->read() ; - FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i(mySupportIOR,(FIELD*)myField); - POA_SALOME_MED::FIELD_tie * myFieldTie = new POA_SALOME_MED::FIELD_tie(myFieldDoubleI); - SALOME_MED::FIELD_ptr myFieldIOR = myFieldTie->_this() ; - if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ; - return SALOME_MED::FIELD::_duplicate(myFieldIOR); + FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); + SALOME_MED::FIELD_ptr myFieldIOR = myFieldDoubleI->_this() ; +// if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ; + endService("Med_Gen_i::readFieldInFile"); + return myFieldIOR; } catch (const SALOMEDS::StudyBuilder::LockProtection & lp) {} catch (const exception & ex) diff --git a/src/MEDMEM/MEDMEM_Array.hxx b/src/MEDMEM/MEDMEM_Array.hxx index 896a664cc..e0d55c4a8 100644 --- a/src/MEDMEM/MEDMEM_Array.hxx +++ b/src/MEDMEM/MEDMEM_Array.hxx @@ -10,31 +10,31 @@ using namespace MED_EN; /*! A template class to generate an array of any particular type (int, long, - float, double) for our purpose in the MED++ library./n/n + float, double) for our purpose in the MED++ library.\n\n Arrays can be stored in MED_FULL_INTERLACE mode (ie : x1,y1,z1,x2,y2,z2...) or - in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn)./n The alternate + in MED_NO_INTERLACE mode ( x1,x2,..xn, y1, y2 ..,yn,z1,...,zn).\n The alternate representation mode is calculate ONLY when it is usefull. We assure coherency for minor data modifications (element, line or column) if you use set methods. But, if you get a pointer and modify the array, no automatical coherency is possible. - You can use calculateOther to force a recalculation and insure the coherency./n - No recalculation is done, when the entire array is modified./n + You can use calculateOther to force a recalculation and insure the coherency.\n + No recalculation is done, when the entire array is modified.\n Theses arrays are "Med like" arrays; lower bound equals 1. (first element is element 1, - first coordinate is coordinate 1). /n + first coordinate is coordinate 1). \n - Available constructors are :/n + Available constructors are :\n - - default constructor (not very usefull)/n - - constructor asking for array dimensions and mode (does memory allocation for you)/n + - default constructor (not very usefull)\n + - constructor asking for array dimensions and mode (does memory allocation for you)\n - constructor asking for array dimensions, mode and values (doesn't do memory allocation - but copies pointers only.)/n - - a copy constructor which copies only pointers./n + but copies pointers only.)\n + - a copy constructor which copies only pointers.\n (be aware of coherency) - - a copy constructor which copies data (deepcopy)./n - - assignement operator is also available and only copies pointers (and not data)./n/n + - a copy constructor which copies data (deepcopy).\n + - assignement operator is also available and only copies pointers (and not data).\n\n Attribute "pointers" aren't standard pointers but class PointerOf objects in order to simplify - memory management./n + memory management.\n A simple test program (testUArray) allows to test this class. */ @@ -69,11 +69,13 @@ public : MEDARRAY (const med_int ld_values, const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE); MEDARRAY (T* values, const med_int ld_values, - const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE); + const med_int length_values, const medModeSwitch mode=MED_FULL_INTERLACE,bool shallowCopy=false, bool ownershipOfValues=false); MEDARRAY (MEDARRAY const &m); MEDARRAY (MEDARRAY const &m, bool copyOther); MEDARRAY & operator = (const MEDARRAY & m); + MEDARRAY & shallowCopy(const MEDARRAY & m); + inline med_int getLeadingValue() const; inline med_int getLengthValue() const; @@ -126,7 +128,7 @@ template inline MEDARRAY::~MEDARRAY() You don't have to know the T values when calling this construtor but you have to call "set" method to initialize them later. You also can get the pointer to the memory zone (with "get" method), - and work with it./n + and work with it.\n The desallocation of T array is not your responsability. \n\n Throws MEDEXCEPTION if T array length is < 1*/ @@ -180,7 +182,9 @@ template MEDARRAY::MEDARRAY(const med_int ld_values, template MEDARRAY::MEDARRAY( T*values, const med_int ld_values, const med_int length_values, - const medModeSwitch mode): + const medModeSwitch mode, + bool shallowCopy, + bool ownershipOfValues): _ldValues(ld_values), _lengthValues(length_values), _mode(mode), @@ -198,16 +202,41 @@ template MEDARRAY::MEDARRAY( T*values, } if ( _mode == MED_FULL_INTERLACE) { - _valuesFull.set(_ldValues*length_values,values); - _valuesDefault.set((T*)_valuesFull); + if(shallowCopy) + { + if(ownershipOfValues) + { + _valuesFull.setShallowAndOwnership((const T*)values); + } + else + { + _valuesFull.set((const T*)values); + } + } + else + { + _valuesFull.set(_ldValues*length_values,values); + } + _valuesDefault.set((T*)_valuesFull); } else { ASSERT (_mode == MED_NO_INTERLACE); - _valuesNo.set(_ldValues*length_values,values); + if(shallowCopy) + { + if(ownershipOfValues) + { + _valuesNo.setShallowAndOwnership((const T*)values); + } + else + { + _valuesNo.set((const T*)values); + } + } + else + _valuesNo.set(_ldValues*length_values,values); _valuesDefault.set((T*)_valuesNo); } - ASSERT( (T*)_valuesDefault != NULL); SCRUTE((T*)_valuesDefault); SCRUTE((T*)_valuesOther); @@ -219,8 +248,8 @@ template MEDARRAY::MEDARRAY( T*values, // ------------------ - /*! This constructor allocates a new medarray and does a copy of pointers/n - It DOES NOT copy the memory . The two objects will share the same data./n + /*! This constructor allocates a new medarray and does a copy of pointers\n + It DOES NOT copy the memory . The two objects will share the same data.\n (for copying data, use constructor MEDARRAY(MEDARRAY const & m,bool copyOther). */ template MEDARRAY::MEDARRAY(MEDARRAY const & m ): _ldValues(m._ldValues), @@ -241,11 +270,11 @@ template MEDARRAY::MEDARRAY(MEDARRAY const & m ): } /*! This constructor allocates a new array and does a copy of values - included in the m arrays./n + included in the m arrays.\n If the boolean is setted to true, both representations (in full mode - and no interlace mode) will be copied./n - Otherwise, only _valuesDefault will be copied./n - Desallocation of the arrays is not your reponsability./n/n + and no interlace mode) will be copied.\n + Otherwise, only _valuesDefault will be copied.\n + Desallocation of the arrays is not your reponsability.\n\n Throws MEDEXCEPTION if _valuesOther is null and copyOther equals true*/ template MEDARRAY::MEDARRAY(MEDARRAY const & p,bool copyOther ): _ldValues(p._ldValues), @@ -292,9 +321,9 @@ template MEDARRAY::MEDARRAY(MEDARRAY const & p,bool copyOther ): // ------------------ -// /*! This operator does a copy of pointers/n +// /*! This operator does a copy of pointers\n // It DOES NOT copy of the memory. -// The two objects will share data./n */ +// The two objects will share data.\n */ template MEDARRAY & MEDARRAY::operator = (const MEDARRAY & m) { @@ -337,6 +366,28 @@ template MEDARRAY & MEDARRAY::operator = (const MEDARRAY & m) return *this; } +/*! Idem operator= but performs only shallow copy (just copy of pointers) of arrays contains in _valuesFull and _valuesNo \n + WARNING the MEDARRAY returned HAS THE OWNERSHIP OF THE ARRAY !!!! */ + +template MEDARRAY & MEDARRAY::shallowCopy(const MEDARRAY & m) +{ + _ldValues=m._ldValues; + _lengthValues=m._lengthValues; + _mode=m._mode; + if ((const T*) m._valuesFull !=NULL) + _valuesFull.setShallowAndOwnership((const T*) m._valuesFull); + if ((const T*) m._valuesNo !=NULL) + _valuesNo.setShallowAndOwnership((const T*) m._valuesNo); + if (_mode == MED_FULL_INTERLACE) { + _valuesDefault.set((T*) _valuesFull); + _valuesOther.set((T*) _valuesNo); + } else { + _valuesDefault.set((T*) _valuesNo); + _valuesOther.set((T*) _valuesFull); + } + return *this; +} + // ------------------ /*! returns _ldValues. (for example, space dimension for coordinates array)*/ @@ -388,9 +439,9 @@ template const T* MEDARRAY::get(const medModeSwitch mode) // ------------------ /*! returns a pointer to ith element of the array. - (ith line in a MED_FULL_INTERLACE representation )/n + (ith line in a MED_FULL_INTERLACE representation )\n Be aware : if _mode is MED_NO_INTERLACE, the entire - array will be recalculate in MED_FULL_INTERLACE representation./n*/ + array will be recalculate in MED_FULL_INTERLACE representation.\n*/ template const T* MEDARRAY::getRow(const med_int i) { @@ -426,11 +477,11 @@ template const T* MEDARRAY::getRow(const med_int i) } // ------------------ - /*! this method is similar to getRow method./n + /*! this method is similar to getRow method.\n It returns a pointer to jth line of the array in a MED_NO-INTERLACE representation - (for example, 2nd coordinates)./n + (for example, 2nd coordinates).\n Be aware : if _mode is MED_FULL_INTERLACE, the entire - array will be recalculate in MED_NO_INTERLACE representation./n*/ + array will be recalculate in MED_NO_INTERLACE representation.\n*/ template const T* MEDARRAY::getColumn(const med_int j) { @@ -502,7 +553,7 @@ template const T MEDARRAY::getIJ(const med_int i,const med_int j) // ------------------ - /*! returns the default mode (_mode)/n + /*! returns the default mode (_mode)\n (internal use : needed by write method) */ template inline medModeSwitch MEDARRAY::getMode() const { @@ -585,7 +636,7 @@ template void MEDARRAY::clearOtherMode() // ------------------ /*! Sets ith element to T* values\n - if they both exist, both _valuesFull and _valuesNo arrays will be updated./n + if they both exist, both _valuesFull and _valuesNo arrays will be updated.\n Throws exception if i < 1 or i > _lengthValues */ template void MEDARRAY::setI(const med_int i, const T* value) { @@ -625,7 +676,7 @@ template void MEDARRAY::setI(const med_int i, const T* value) // ------------------ /*! Sets ith element to T* values\n - if they both exist, both _valuesFull and _valuesNo arrays will be updated./n + if they both exist, both _valuesFull and _valuesNo arrays will be updated.\n Throws exception if i < 1 or i > _lengthValues */ template void MEDARRAY::setJ(const med_int j, const T* value) { @@ -662,8 +713,8 @@ template void MEDARRAY::setJ(const med_int j, const T* value) // ------------------ - /*! Sets value of Jth coordinate of Ith element to T value./n - Maintains coherency./n + /*! Sets value of Jth coordinate of Ith element to T value.\n + Maintains coherency.\n Throws exception if we don't have 1<=i<=_lengthValues and 1<=j<=_ldValues */ template void MEDARRAY::setIJ(const med_int i, const med_int j, const T value) @@ -696,7 +747,7 @@ template void MEDARRAY::setIJ(const med_int i, const med_int j, con } /*! Calculates the other mode of representation : MED_FULL_INTERLACE - if __mode = MED_NO_INTERLACE and vice versa./n + if __mode = MED_NO_INTERLACE and vice versa.\n Throws exception if no value are setted */ template void MEDARRAY::calculateOther() { diff --git a/src/MEDMEM/MEDMEM_CellModel.cxx b/src/MEDMEM/MEDMEM_CellModel.cxx index 5f272ef6b..ab00a7051 100644 --- a/src/MEDMEM/MEDMEM_CellModel.cxx +++ b/src/MEDMEM/MEDMEM_CellModel.cxx @@ -43,13 +43,13 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=2 ; - _numberOfNodeOfEachConstituent=new (int*)[1] ; - _numberOfNodeOfEachConstituent[0]=new (int)[2] ; + _numberOfNodeOfEachConstituent=new int*[1] ; + _numberOfNodeOfEachConstituent[0]=new int[2] ; _numberOfNodeOfEachConstituent[0][0]=1 ; _numberOfNodeOfEachConstituent[0][1]=1 ; - _constituents = new (int**)[1] ; - _constituents[0] = new (int*)[2] ; + _constituents = new int**[1] ; + _constituents[0] = new int*[2] ; _constituents[0][0] = new int[1] ; _constituents[0][0][0] = 1 ; _constituents[0][1] = new int[1] ; @@ -72,14 +72,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=3 ; - _numberOfNodeOfEachConstituent=new (int*)[1] ; - _numberOfNodeOfEachConstituent[0]=new (int)[3] ; + _numberOfNodeOfEachConstituent=new int*[1] ; + _numberOfNodeOfEachConstituent[0]=new int[3] ; _numberOfNodeOfEachConstituent[0][0]=1 ; _numberOfNodeOfEachConstituent[0][1]=1 ; _numberOfNodeOfEachConstituent[0][2]=1 ; - _constituents = new (int**)[1] ; - _constituents[0] = new (int*)[3] ; + _constituents = new int**[1] ; + _constituents[0] = new int*[3] ; _constituents[0][0] = new int[1] ; _constituents[0][0][0] = 1 ; _constituents[0][1] = new int[1] ; @@ -105,8 +105,8 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=3 ; - _numberOfNodeOfEachConstituent=new (int*)[1] ; - _numberOfNodeOfEachConstituent[0]=new (int)[3] ; + _numberOfNodeOfEachConstituent=new int*[1] ; + _numberOfNodeOfEachConstituent[0]=new int[3] ; _numberOfNodeOfEachConstituent[0][0]=2 ; _numberOfNodeOfEachConstituent[0][1]=2 ; _numberOfNodeOfEachConstituent[0][2]=2 ; @@ -120,7 +120,7 @@ CELLMODEL::CELLMODEL(medGeometryElement t) int* _edge3=new int[2]; _edge3[0]=3; _edge3[1]=1; - int ** tmpConstituents1 = new (int*)[3]; + int ** tmpConstituents1 = new int*[3]; tmpConstituents1[0]=_edge1 ; tmpConstituents1[1]=_edge2 ; tmpConstituents1[2]=_edge3 ; @@ -153,8 +153,8 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=3 ; - _numberOfNodeOfEachConstituent=new (int*)[1] ; - _numberOfNodeOfEachConstituent[0]=new (int)[3] ; + _numberOfNodeOfEachConstituent=new int*[1] ; + _numberOfNodeOfEachConstituent[0]=new int[3] ; _numberOfNodeOfEachConstituent[0][0]=3 ; _numberOfNodeOfEachConstituent[0][1]=3 ; _numberOfNodeOfEachConstituent[0][2]=3 ; @@ -171,7 +171,7 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _edge3[0]=3; _edge3[1]=1; _edge3[2]=6; - int ** tmpConstituents1 = new (int*)[3]; + int ** tmpConstituents1 = new int*[3]; tmpConstituents1[0]=_edge1 ; tmpConstituents1[1]=_edge2 ; tmpConstituents1[2]=_edge3 ; @@ -206,8 +206,8 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=4 ; - _numberOfNodeOfEachConstituent=new (int*)[1] ; - _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent=new int*[1] ; + _numberOfNodeOfEachConstituent[0]=new int[4] ; _numberOfNodeOfEachConstituent[0][0]=2 ; _numberOfNodeOfEachConstituent[0][1]=2 ; _numberOfNodeOfEachConstituent[0][2]=2 ; @@ -225,7 +225,7 @@ CELLMODEL::CELLMODEL(medGeometryElement t) int* _edge4=new int[2]; _edge4[0]=4; _edge4[1]=1; - int ** tmpConstituents1 = new (int*)[4]; + int ** tmpConstituents1 = new int*[4]; tmpConstituents1[0]=_edge1 ; tmpConstituents1[1]=_edge2 ; tmpConstituents1[2]=_edge3 ; @@ -260,8 +260,8 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituentsDimension=1 ; _numberOfConstituents=new int[1] ; _numberOfConstituents[0]=4 ; - _numberOfNodeOfEachConstituent=new (int*)[1] ; - _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent=new int*[1] ; + _numberOfNodeOfEachConstituent[0]=new int[4] ; _numberOfNodeOfEachConstituent[0][0]=3 ; _numberOfNodeOfEachConstituent[0][1]=3 ; _numberOfNodeOfEachConstituent[0][2]=3 ; @@ -283,7 +283,7 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _edge4[0]=4; _edge4[1]=1; _edge4[2]=8; - int ** tmpConstituents1 = new (int*)[4]; + int ** tmpConstituents1 = new int*[4]; tmpConstituents1[0]=_edge1 ; tmpConstituents1[1]=_edge2 ; tmpConstituents1[2]=_edge3 ; @@ -323,13 +323,13 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=4 ; _numberOfConstituents[1]=6 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[4] ; _numberOfNodeOfEachConstituent[0][0]=3 ; _numberOfNodeOfEachConstituent[0][1]=3 ; _numberOfNodeOfEachConstituent[0][2]=3 ; _numberOfNodeOfEachConstituent[0][3]=3 ; - _numberOfNodeOfEachConstituent[1]=new (int)[6] ; + _numberOfNodeOfEachConstituent[1]=new int[6] ; _numberOfNodeOfEachConstituent[1][0]=2 ; _numberOfNodeOfEachConstituent[1][1]=2 ; _numberOfNodeOfEachConstituent[1][2]=2 ; @@ -371,12 +371,12 @@ CELLMODEL::CELLMODEL(medGeometryElement t) int* _edge6=new int[2]; _edge6[0]=3; _edge6[1]=4; - int ** tmpConstituents1 = new (int*)[4]; + int ** tmpConstituents1 = new int*[4]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; - int ** tmpConstituents2 = new (int*)[6]; + int ** tmpConstituents2 = new int*[6]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -413,13 +413,13 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=4 ; _numberOfConstituents[1]=6 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[4] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[4] ; _numberOfNodeOfEachConstituent[0][0]=6 ; _numberOfNodeOfEachConstituent[0][1]=6 ; _numberOfNodeOfEachConstituent[0][2]=6 ; _numberOfNodeOfEachConstituent[0][3]=6 ; - _numberOfNodeOfEachConstituent[1]=new (int)[6] ; + _numberOfNodeOfEachConstituent[1]=new int[6] ; _numberOfNodeOfEachConstituent[1][0]=3 ; _numberOfNodeOfEachConstituent[1][1]=3 ; _numberOfNodeOfEachConstituent[1][2]=3 ; @@ -479,12 +479,12 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _edge6[0]=3; _edge6[1]=4; _edge6[2]=10; - int ** tmpConstituents1 = new (int*)[4]; + int ** tmpConstituents1 = new int*[4]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; - int ** tmpConstituents2 = new (int*)[6]; + int ** tmpConstituents2 = new int*[6]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -521,15 +521,15 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=6 ; _numberOfConstituents[1]=12 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[6] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[6] ; _numberOfNodeOfEachConstituent[0][0]=4 ; _numberOfNodeOfEachConstituent[0][1]=4 ; _numberOfNodeOfEachConstituent[0][2]=4 ; _numberOfNodeOfEachConstituent[0][3]=4 ; _numberOfNodeOfEachConstituent[0][4]=4 ; _numberOfNodeOfEachConstituent[0][5]=4 ; - _numberOfNodeOfEachConstituent[1]=new (int)[12] ; + _numberOfNodeOfEachConstituent[1]=new int[12] ; _numberOfNodeOfEachConstituent[1][0]=2 ; _numberOfNodeOfEachConstituent[1][1]=2 ; _numberOfNodeOfEachConstituent[1][2]=2 ; @@ -609,14 +609,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _face6[1]=8; _face6[2]=5; _face6[3]=1; - int ** tmpConstituents1 = new (int*)[6]; + int ** tmpConstituents1 = new int*[6]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; tmpConstituents1[4]=_face5 ; tmpConstituents1[5]=_face6 ; - int ** tmpConstituents2 = new (int*)[12]; + int ** tmpConstituents2 = new int*[12]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -667,15 +667,15 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=6 ; _numberOfConstituents[1]=12 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[6] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[6] ; _numberOfNodeOfEachConstituent[0][0]=8 ; _numberOfNodeOfEachConstituent[0][1]=8 ; _numberOfNodeOfEachConstituent[0][2]=8 ; _numberOfNodeOfEachConstituent[0][3]=8 ; _numberOfNodeOfEachConstituent[0][4]=8 ; _numberOfNodeOfEachConstituent[0][5]=8 ; - _numberOfNodeOfEachConstituent[1]=new (int)[12] ; + _numberOfNodeOfEachConstituent[1]=new int[12] ; _numberOfNodeOfEachConstituent[1][0]=3 ; _numberOfNodeOfEachConstituent[1][1]=3 ; _numberOfNodeOfEachConstituent[1][2]=3 ; @@ -791,14 +791,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _face6[5]=16; _face6[6]=17; _face6[7]=12; - int ** tmpConstituents1 = new (int*)[6]; + int ** tmpConstituents1 = new int*[6]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; tmpConstituents1[4]=_face5 ; tmpConstituents1[5]=_face6 ; - int ** tmpConstituents2 = new (int*)[12]; + int ** tmpConstituents2 = new int*[12]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -850,14 +850,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; _numberOfConstituents[1]=9 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[5] ; _numberOfNodeOfEachConstituent[0][0]=3 ; _numberOfNodeOfEachConstituent[0][1]=3 ; _numberOfNodeOfEachConstituent[0][2]=4 ; _numberOfNodeOfEachConstituent[0][3]=4 ; _numberOfNodeOfEachConstituent[0][4]=4 ; - _numberOfNodeOfEachConstituent[1]=new (int)[9] ; + _numberOfNodeOfEachConstituent[1]=new int[9] ; _numberOfNodeOfEachConstituent[1][0]=2 ; _numberOfNodeOfEachConstituent[1][1]=2 ; _numberOfNodeOfEachConstituent[1][2]=2 ; @@ -918,13 +918,13 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _face5[1]=6; _face5[2]=4; _face5[3]=1; - int ** tmpConstituents1 = new (int*)[5]; + int ** tmpConstituents1 = new int*[5]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new (int*)[9]; + int ** tmpConstituents2 = new int*[9]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -968,14 +968,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; _numberOfConstituents[1]=9 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[5] ; _numberOfNodeOfEachConstituent[0][0]=6 ; _numberOfNodeOfEachConstituent[0][1]=6 ; _numberOfNodeOfEachConstituent[0][2]=8 ; _numberOfNodeOfEachConstituent[0][3]=8 ; _numberOfNodeOfEachConstituent[0][4]=8 ; - _numberOfNodeOfEachConstituent[1]=new (int)[9] ; + _numberOfNodeOfEachConstituent[1]=new int[9] ; _numberOfNodeOfEachConstituent[1][0]=3 ; _numberOfNodeOfEachConstituent[1][1]=3 ; _numberOfNodeOfEachConstituent[1][2]=3 ; @@ -1063,13 +1063,13 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _face5[5]=12; _face5[6]=13; _face5[7]=9; - int ** tmpConstituents1 = new (int*)[5]; + int ** tmpConstituents1 = new int*[5]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new (int*)[9]; + int ** tmpConstituents2 = new int*[9]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -1079,7 +1079,7 @@ CELLMODEL::CELLMODEL(medGeometryElement t) tmpConstituents2[6]=_edge7 ; tmpConstituents2[7]=_edge8 ; tmpConstituents2[8]=_edge9 ; - _constituents = new (int**)[2] ; + _constituents = new int**[2] ; _constituents[0]=tmpConstituents1 ; _constituents[1]=tmpConstituents2 ; medGeometryElement * tmpConstituentsType1 = new medGeometryElement[5] ; @@ -1098,7 +1098,7 @@ CELLMODEL::CELLMODEL(medGeometryElement t) tmpConstituentsType2[6] = MED_SEG3 ; tmpConstituentsType2[7] = MED_SEG3 ; tmpConstituentsType2[8] = MED_SEG3 ; - _constituentsType = new (medGeometryElement*)[2] ; + _constituentsType = new medGeometryElement*[2] ; _constituentsType[0]=tmpConstituentsType1 ; _constituentsType[1]=tmpConstituentsType2 ; break ; @@ -1113,14 +1113,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; _numberOfConstituents[1]=8 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[5] ; _numberOfNodeOfEachConstituent[0][0]=4 ; _numberOfNodeOfEachConstituent[0][1]=3 ; _numberOfNodeOfEachConstituent[0][2]=3 ; _numberOfNodeOfEachConstituent[0][3]=3 ; _numberOfNodeOfEachConstituent[0][4]=3 ; - _numberOfNodeOfEachConstituent[1]=new (int)[8] ; + _numberOfNodeOfEachConstituent[1]=new int[8] ; _numberOfNodeOfEachConstituent[1][0]=2 ; _numberOfNodeOfEachConstituent[1][1]=2 ; _numberOfNodeOfEachConstituent[1][2]=2 ; @@ -1175,13 +1175,13 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _face5[0]=4; _face5[1]=5; _face5[2]=1; - int ** tmpConstituents1 = new (int*)[5]; + int ** tmpConstituents1 = new int*[5]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new (int*)[8]; + int ** tmpConstituents2 = new int*[8]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -1223,14 +1223,14 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _numberOfConstituents=new int[2] ; _numberOfConstituents[0]=5 ; _numberOfConstituents[1]=8 ; - _numberOfNodeOfEachConstituent=new (int*)[2] ; - _numberOfNodeOfEachConstituent[0]=new (int)[5] ; + _numberOfNodeOfEachConstituent=new int*[2] ; + _numberOfNodeOfEachConstituent[0]=new int[5] ; _numberOfNodeOfEachConstituent[0][0]=8 ; _numberOfNodeOfEachConstituent[0][1]=6 ; _numberOfNodeOfEachConstituent[0][2]=6 ; _numberOfNodeOfEachConstituent[0][3]=6 ; _numberOfNodeOfEachConstituent[0][4]=6 ; - _numberOfNodeOfEachConstituent[1]=new (int)[8] ; + _numberOfNodeOfEachConstituent[1]=new int[8] ; _numberOfNodeOfEachConstituent[1][0]=3 ; _numberOfNodeOfEachConstituent[1][1]=3 ; _numberOfNodeOfEachConstituent[1][2]=3 ; @@ -1309,13 +1309,13 @@ CELLMODEL::CELLMODEL(medGeometryElement t) _face5[3]=13; _face5[4]=10; _face5[5]=9; - int ** tmpConstituents1 = new (int*)[5]; + int ** tmpConstituents1 = new int*[5]; tmpConstituents1[0]=_face1 ; tmpConstituents1[1]=_face2 ; tmpConstituents1[2]=_face3 ; tmpConstituents1[3]=_face4 ; tmpConstituents1[4]=_face5 ; - int ** tmpConstituents2 = new (int*)[8]; + int ** tmpConstituents2 = new int*[8]; tmpConstituents2[0]=_edge1 ; tmpConstituents2[1]=_edge2 ; tmpConstituents2[2]=_edge3 ; @@ -1443,7 +1443,7 @@ void CELLMODEL::init(const CELLMODEL &m) for(int i=0; i<_numberOfConstituentsDimension; i++) _numberOfConstituents[i]=m._numberOfConstituents[i] ; - _numberOfNodeOfEachConstituent = new (int*)[_numberOfConstituentsDimension] ; + _numberOfNodeOfEachConstituent = new int*[_numberOfConstituentsDimension] ; for(int i=0; i<_numberOfConstituentsDimension; i++) { int numberOf = _numberOfConstituents[i] ; int * newArray = new int[numberOf] ; @@ -1452,11 +1452,11 @@ void CELLMODEL::init(const CELLMODEL &m) newArray[j] = oldArray[j] ; _numberOfNodeOfEachConstituent[i] = newArray ; } - _constituents = new (int**)[_numberOfConstituentsDimension] ; - _constituentsType = new (medGeometryElement*)[_numberOfConstituentsDimension] ; + _constituents = new int**[_numberOfConstituentsDimension] ; + _constituentsType = new medGeometryElement*[_numberOfConstituentsDimension] ; for(int i=0; i<_numberOfConstituentsDimension; i++) { int numberOf = _numberOfConstituents[i] ; - int ** tmpArray = new (int*)[numberOf] ; + int ** tmpArray = new int*[numberOf] ; medGeometryElement * newArrayType = new medGeometryElement[numberOf] ; medGeometryElement * oldArrayType = m._constituentsType[i] ; diff --git a/src/MEDMEM/MEDMEM_CellModel.hxx b/src/MEDMEM/MEDMEM_CellModel.hxx index 97b905e4d..0dc98d33c 100644 --- a/src/MEDMEM/MEDMEM_CellModel.hxx +++ b/src/MEDMEM/MEDMEM_CellModel.hxx @@ -29,11 +29,11 @@ class CELLMODEL { private: - /*! private method : /n + /*! private method : \n used by constructor and operator= */ void init(const CELLMODEL &m); - /*! private method : /n */ + /*! private method : \n */ void clean(); @@ -93,7 +93,7 @@ public : /*! returns number of nodes forming this type of cell */ inline int getNumberOfNodes() const; - /*! returns the dimension of this type of cell./n + /*! returns the dimension of this type of cell.\n it can be different from mesh dimension */ inline int getDimension() const; diff --git a/src/MEDMEM/MEDMEM_Connectivity.cxx b/src/MEDMEM/MEDMEM_Connectivity.cxx index e084cebe7..fe4bbe3d6 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.cxx +++ b/src/MEDMEM/MEDMEM_Connectivity.cxx @@ -12,7 +12,7 @@ using namespace std; using namespace MEDMEM; /*! - Default Constructor. /n + Default Constructor. \n Default for Entity is MED_CELL and type of Connectivity is MED_NODAL */ //--------------------------------------------------------------// CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) : @@ -35,7 +35,7 @@ CONNECTIVITY::CONNECTIVITY(medEntityMesh Entity /* =MED_CELL */) : } /*! - Constructor. /n + Constructor. \n Default for Entity is MED_CELL */ //------------------------------------------------------------------------------// CONNECTIVITY::CONNECTIVITY(int numberOfTypes,medEntityMesh Entity /* =MED_CELL */): @@ -126,7 +126,7 @@ CONNECTIVITY::CONNECTIVITY (const CONNECTIVITY & m): } /*! - Destructor./n + Destructor.\n desallocates existing pointers */ //----------------------------// CONNECTIVITY::~CONNECTIVITY() @@ -1132,54 +1132,57 @@ void CONNECTIVITY::calculateReverseNodalConnectivity() if (_nodal==NULL) calculateNodalConnectivity(); - if(_reverseNodalConnectivity==NULL) { - - med_int node_number = 0; - vector > reverse_connectivity; - reverse_connectivity.resize(_numberOfNodes+1); + if(_reverseNodalConnectivity==NULL) + { + med_int node_number = 0; + vector > reverse_connectivity; + reverse_connectivity.resize(_numberOfNodes+1); - // Treat all cells types + // Treat all cells types - for (med_int j = 0; j < _numberOfTypes; j++) - { - // node number of the cell type - node_number = _type[j].getNumberOfNodes(); - // treat all cells of a particular type - for (med_int k = _count[j]; k < _count[j+1]; k++) - // treat all nodes of the cell type - for (med_int local_node_number = 1; local_node_number < node_number+1; local_node_number++) - { - med_int global_node = _nodal->getIJ(k,local_node_number); - reverse_connectivity[global_node].push_back(k); - } - } + for (med_int j = 0; j < _numberOfTypes; j++) + { + // node number of the cell type + node_number = _type[j].getNumberOfNodes(); + // treat all cells of a particular type + for (med_int k = _count[j]; k < _count[j+1]; k++) + // treat all nodes of the cell type + for (med_int local_node_number = 1; + local_node_number < node_number+1; + local_node_number++) + { + med_int global_node = _nodal->getIJ(k,local_node_number); + reverse_connectivity[global_node].push_back(k); + } + } - // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index + // Full reverse_nodal_connectivity and reverse_nodal_connectivity_index - //calculate size of reverse_nodal_connectivity array - med_int size_reverse_nodal_connectivity = 0; - for (med_int i = 1; i < _numberOfNodes+1; i++) - size_reverse_nodal_connectivity += reverse_connectivity[i].size(); + //calculate size of reverse_nodal_connectivity array + med_int size_reverse_nodal_connectivity = 0; + for (med_int i = 1; i < _numberOfNodes+1; i++) + size_reverse_nodal_connectivity += reverse_connectivity[i].size(); //MEDSKYLINEARRAY * ReverseConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity); - med_int * reverse_nodal_connectivity_index = new (med_int)[_numberOfNodes+1]; - med_int * reverse_nodal_connectivity = new (med_int)[size_reverse_nodal_connectivity]; + med_int * reverse_nodal_connectivity_index = new med_int[_numberOfNodes+1]; + med_int * reverse_nodal_connectivity = new med_int[size_reverse_nodal_connectivity]; //const med_int * reverse_nodal_connectivity = ReverseConnectivity->getValue(); //const med_int * reverse_nodal_connectivity_index = ReverseConnectivity->getIndex(); - reverse_nodal_connectivity_index[0] = 1; - for (med_int i = 1; i < _numberOfNodes+1; i++) - { - med_int size = reverse_connectivity[i].size(); - reverse_nodal_connectivity_index[i] = reverse_nodal_connectivity_index[i-1] + size; - for (med_int j = 0; j < size; j++) - reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j]; - } + reverse_nodal_connectivity_index[0] = 1; + for (med_int i = 1; i < _numberOfNodes+1; i++) + { + med_int size = reverse_connectivity[i].size(); + reverse_nodal_connectivity_index[i] = + reverse_nodal_connectivity_index[i-1] + size; + for (med_int j = 0; j < size; j++) + reverse_nodal_connectivity[reverse_nodal_connectivity_index[i-1]-1+j]= reverse_connectivity[i][j]; + } - //_reverseNodalConnectivity = ReverseConnectivity; - _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity, - reverse_nodal_connectivity_index, - reverse_nodal_connectivity); + //_reverseNodalConnectivity = ReverseConnectivity; + _reverseNodalConnectivity = new MEDSKYLINEARRAY(_numberOfNodes,size_reverse_nodal_connectivity, + reverse_nodal_connectivity_index, + reverse_nodal_connectivity); delete [] reverse_nodal_connectivity_index; delete [] reverse_nodal_connectivity; } @@ -1189,7 +1192,7 @@ void CONNECTIVITY::calculateReverseNodalConnectivity() /*! If not yet done, calculate the Descending Connectivity */ //-------------------------------------------------// void CONNECTIVITY::calculateDescendingConnectivity() - //-------------------------------------------------// +//-------------------------------------------------// { const char * LOC = "CONNECTIVITY::calculateDescendingConnectivity() : "; BEGIN_OF(LOC); @@ -1321,75 +1324,95 @@ void CONNECTIVITY::calculateDescendingConnectivity() for (int j=_count[i]; j<_count[i+1]; j++) // we loop on all cell of this type for (int k=1; k<=NumberOfConstituentPerCell; k++) { // we loop on all sub cell of it - if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) { - // it is a new sub cell ! - // TotalNumberOfSubCell++; - // Which type ? - if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0]){ - tmp_NumberOfConstituentsForeachType[0]++; - TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0]; - } else { - tmp_NumberOfConstituentsForeachType[1]++; - TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1]; - } - //we have maximum two types + if (descend_connectivity[descend_connectivity_index[j-1]+k-2]==0) + { + // it is a new sub cell ! + // TotalNumberOfSubCell++; + // Which type ? + if (Type.getConstituentType(1,k)==_constituent->_geometricTypes[0]) + { + tmp_NumberOfConstituentsForeachType[0]++; + TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[0]; + } + else + { + tmp_NumberOfConstituentsForeachType[1]++; + TotalNumberOfSubCell=tmp_NumberOfConstituentsForeachType[1]; + } + //we have maximum two types - descend_connectivity[descend_connectivity_index[j-1]+k-2]=TotalNumberOfSubCell; - ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2]=j; - int NumberOfNodesPerConstituent = Type.getConstituentType(1,k)%100; - - int * NodesLists = new int[NumberOfNodesPerConstituent]; - for (int l=0; lgetIJ(j,Type.getNodeConstituent(1,k,l+1)); - ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l]=NodesLists[l]; - } - // we use reverse_nodal_connectivity to find the other element which contain this sub cell - - // all elements which contains first node of sub cell : - int ReverseNodalConnectivityIndex_0 = ReverseNodalConnectivityIndex[NodesLists[0]-1]; - int ReverseNodalConnectivityIndex_1 = ReverseNodalConnectivityIndex[NodesLists[0]]; - int NumberOfCellsInList = ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0; - - if (NumberOfCellsInList > 0) - { // we could have no element ! - int * CellsList = new int[NumberOfCellsInList]; - for (int l=ReverseNodalConnectivityIndex_0; l 0) { // We have found some elements ! - int CellNumber = CellsList[0]; - //delete [] CellsList; - if (NumberOfCellsInList>1) - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<getIJ(j,Type.getNodeConstituent(1,k,l+1)); + ConstituentNodalConnectivity[ConstituentNodalConnectivityIndex[TotalNumberOfSubCell-1]-1+l] = + NodesLists[l]; + } + // we use reverse_nodal_connectivity to find the other element which contain this sub cell + + // all elements which contains first node of sub cell : + int ReverseNodalConnectivityIndex_0 = + ReverseNodalConnectivityIndex[NodesLists[0]-1]; + int ReverseNodalConnectivityIndex_1 = + ReverseNodalConnectivityIndex[NodesLists[0]]; + int NumberOfCellsInList = + ReverseNodalConnectivityIndex_1-ReverseNodalConnectivityIndex_0; + + if (NumberOfCellsInList > 0) + { // we could have no element ! + int * CellsList = new int[NumberOfCellsInList]; + for (int l=ReverseNodalConnectivityIndex_0; + l 0) + { // We have found some elements ! + if (NumberOfCellsInList>1) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"More than one other Cell ("<getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == NodesLists[n-1]) - counter++; + for (int l=1; l<=Type2.getNumberOfConstituents(1);l++) + { // on all sub cell + int counter = 0; + for (int m=1; m<=Type2.getConstituentType(1,l)%100; + m++) + for (int n=1; n<=Type.getConstituentType(1,k)%100; + n++) + { + if (_nodal->getIJ(CellNumber,Type2.getNodeConstituent(1,l,m)) == + NodesLists[n-1]) + counter++; + } + if (counter==Type.getConstituentType(1,k)%100) + { + descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]= + -1*TotalNumberOfSubCell; // because, see it in other side ! + find2 = true; } - if (counter==Type.getConstituentType(1,k)%100) - { - descend_connectivity[descend_connectivity_index[CellNumber-1]+l-2]=-1*TotalNumberOfSubCell; // because, see it in other side ! - find2 = true; - } - if (find2) - break; - } + if (find2) + break; + } if (!find2) - MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ? - } - } else { - ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0; + { + MESSAGE(LOC<<"ERROR ERROR ERROR ERROR ERROR : we find any subcell !!!"); // exception ? + } + } + else + { + ReverseDescendingConnectivityValue[(TotalNumberOfSubCell-1)*2+1]=0; + } + delete [] CellsList; } - delete [] CellsList; - } - - delete [] NodesLists; - } + + delete [] NodesLists; + } } } // we adjust _constituent int NumberOfConstituent=0; int SizeOfConstituentNodal=0; - for (int i=0;i<_constituent->_numberOfTypes; i++) { - NumberOfConstituent += tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1; - SizeOfConstituentNodal += (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes(); - } + for (int i=0;i<_constituent->_numberOfTypes; i++) + { + NumberOfConstituent += + tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1; + SizeOfConstituentNodal += + (tmp_NumberOfConstituentsForeachType[i]-_constituent->_count[i]+1)*_constituent->_type[i].getNumberOfNodes(); + } // we built new _nodal attribute in _constituent //MEDSKYLINEARRAY *ConstituentNodal = new MEDSKYLINEARRAY(NumberOfConstituent,SizeOfConstituentNodal); //const int *ConstituentNodalValue = ConstituentNodal->getValue(); @@ -1454,38 +1488,56 @@ void CONNECTIVITY::calculateDescendingConnectivity() reverseDescendingConnectivityIndex[0]=1; // first constituent type - for(int j=0; j_numberOfTypes==2) { - int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1; - int offset1=offset*_constituent->_type[0].getNumberOfNodes(); - int offset2=offset*2; - int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes(); - for(int j=tmp_NumberOfConstituentsForeachType[0]; j_numberOfTypes==2) + { + int offset = _constituent->_count[1]-tmp_NumberOfConstituentsForeachType[0]-1; + int offset1=offset*_constituent->_type[0].getNumberOfNodes(); + int offset2=offset*2; + int NumberOfNodesPerConstituent = _constituent->_type[1].getNumberOfNodes(); + for(int j=tmp_NumberOfConstituentsForeachType[0]; j_count[2]=NumberOfConstituent+1; + // we correct _descending to adjust face number + for(int j=0;jtmp_NumberOfConstituentsForeachType[0]) + descend_connectivity[j]-=offset; + else if (descend_connectivity[j]<-tmp_NumberOfConstituentsForeachType[0]) + descend_connectivity[j]+=offset; + } } - _constituent->_count[2]=NumberOfConstituent+1; - // we correct _descending to adjust face number - for(int j=0;jtmp_NumberOfConstituentsForeachType[0]) - descend_connectivity[j]-=offset; - } delete [] ConstituentNodalConnectivityIndex; delete [] ConstituentNodalConnectivity; @@ -1514,7 +1566,7 @@ void CONNECTIVITY::calculateDescendingConnectivity() delete [] ConstituentNodalIndex; delete [] ConstituentNodalValue; - + delete [] ReverseDescendingConnectivityValue; } END_OF(LOC); diff --git a/src/MEDMEM/MEDMEM_Connectivity.hxx b/src/MEDMEM/MEDMEM_Connectivity.hxx index 7fabf2bb2..8cea5dec7 100644 --- a/src/MEDMEM/MEDMEM_Connectivity.hxx +++ b/src/MEDMEM/MEDMEM_Connectivity.hxx @@ -16,7 +16,7 @@ class FAMILY; class GROUP; /*! - This class deals with all type of connectivity ./n + This class deals with all type of connectivity .\n it a recursive class. */ @@ -87,19 +87,19 @@ protected: /* -------------------- */ private: - /*! private method :/n + /*! private method :\n does nothing if already exists, else evaluates _nodal from _descending */ void calculateNodalConnectivity(); - /*! private method :/n + /*! private method :\n does nothing if already exists, else evaluates from _nodal */ void calculateReverseNodalConnectivity(); - /*! private method :/n + /*! private method :\n does nothing if already exists, else evaluates _descending from _nodal */ void calculateDescendingConnectivity(); - /*! private method :/n + /*! private method :\n does nothing if already exists, else evaluates from _descending */ // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity); @@ -109,7 +109,7 @@ private: const med_int* getReverseDescendingConnectivity (); const med_int* getReverseDescendingConnectivityIndex (); - /*! private method :/n + /*! private method :\n does nothing if already exists, else evaluates _neighbourhood from _descending */ void calculateNeighbourhood(CONNECTIVITY &myConnectivity); @@ -145,6 +145,8 @@ public: inline void setNumberOfNodes(med_int NumberOfNodes); + inline med_int getEntityDimension() const; + inline void setEntityDimension(med_int EntityDimension); inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const; @@ -206,7 +208,7 @@ inline medEntityMesh CONNECTIVITY::getEntity() const } /*! Returns the number of different %medGeometryElement types - existing in the specified entity. /n + existing in the specified entity. \n Note : Not implemented for MED_ALL_ENTITIES. */ //-----------------------------------------------------------------------// inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const @@ -217,33 +219,33 @@ inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const return _numberOfTypes; else if (_constituent!=NULL) return _constituent->getNumberOfTypes(Entity); - else if (_constituent == NULL) - { - MESSAGE("CONNECTIVITY::getNumberOfTypes : _constituent == NULL"); - try - { - (const_cast (this))->calculateDescendingConnectivity(); - } - catch (MEDEXCEPTION & ex) - { - return 0 ; - } - - SCRUTE(_entityDimension); - - if (_entityDimension != 2 && _entityDimension != 3) return 0; - - try - { - _constituent->calculateConnectivity(MED_NODAL,Entity); - } - catch (MEDEXCEPTION & ex) - { - return 0 ; - } - - return _constituent->getNumberOfTypes(Entity); - } +// else if (_constituent == NULL) +// { +// MESSAGE("CONNECTIVITY::getNumberOfTypes : _constituent == NULL"); +// try +// { +// (const_cast (this))->calculateDescendingConnectivity(); +// } +// catch (MEDEXCEPTION & ex) +// { +// return 0 ; +// } + +// SCRUTE(_entityDimension); + +// if (_entityDimension != 2 && _entityDimension != 3) return 0; + +// try +// { +// _constituent->calculateConnectivity(MED_NODAL,Entity); +// } +// catch (MEDEXCEPTION & ex) +// { +// return 0 ; +// } + +// return _constituent->getNumberOfTypes(Entity); +// } else return 0; // because it is the right information (no exception needed)! } @@ -265,17 +267,17 @@ inline const medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh E throw MEDEXCEPTION("CONNECTIVITY::getGeometricTypes : Entity not defined !"); } -/*! Returns an array containing the accumulated number of entities sorted by the geometric type./n +/*! Returns an array containing the accumulated number of entities sorted by the geometric type.\n - Exemple :/n + Exemple :\n - In case of a CONNECTIVITY containing 3*MED_TRIA3 et 2*MED_QUAD4 : /n - int * count = getGlobalNumberingIndex(MED_CELL)/n - count[0] is always set to 1/n - count[1] is set to 1+3=4/n - count[2] is set to 4+2=6 = total number of cells + 1/n + In case of a CONNECTIVITY containing 3*MED_TRIA3 et 2*MED_QUAD4 : \n + int * count = getGlobalNumberingIndex(MED_CELL)\n + count[0] is always set to 1\n + count[1] is set to 1+3=4\n + count[2] is set to 4+2=6 = total number of cells + 1\n - Note : Not implemented for MED_ALL_ENTITIES. /n + Note : Not implemented for MED_ALL_ENTITIES. \n Note : The geometric type order is given by the typedef enum medGeometryElement. */ @@ -311,7 +313,7 @@ inline bool CONNECTIVITY::existConnectivity( medConnectivity ConnectivityType, /*! Returns an array containing CELLMODEL foreach element type present -in connectivity for given medEntityMesh (similar as getGeometricTypes)./n +in connectivity for given medEntityMesh (similar as getGeometricTypes).\n Throw an execption if the given entity is not defined or if the array is not defined. */ //-----------------------------------------------------------------------------// @@ -385,5 +387,10 @@ inline void CONNECTIVITY::setEntityDimension(med_int EntityDimension) _entityDimension=EntityDimension; } +med_int CONNECTIVITY::getEntityDimension() const +{ + return _entityDimension; +} + #endif /* CONNECTIVITY_HXX */ diff --git a/src/MEDMEM/MEDMEM_Coordinate.cxx b/src/MEDMEM/MEDMEM_Coordinate.cxx index d968d8ec0..04451dcae 100644 --- a/src/MEDMEM/MEDMEM_Coordinate.cxx +++ b/src/MEDMEM/MEDMEM_Coordinate.cxx @@ -18,7 +18,7 @@ COORDINATE::COORDINATE():_coordinateSystem(""), BEGIN_OF("Default Constructor COORDINATE"); } -/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes./n +/*! This constructor allocate a MEDARRAY of SpaceDimension * NumberOfNodes.\n It will create empty array for optional data (nodeNumber..) */ //------------------------------------------------------------------------------// COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode): @@ -33,7 +33,7 @@ COORDINATE::COORDINATE(int SpaceDimension, int NumberOfNodes, medModeSwitch Mode BEGIN_OF("Constructor COORDINATE"); } -/*! This constructor will COPY all data (it is a deep copy) included in m./n +/*! This constructor will COPY all data (it is a deep copy) included in m.\n But only the default storage mode of coordinates array will be copied (not both storage representation modes even if they both exist in original object) : for example only full_interlace mode */ @@ -72,7 +72,7 @@ COORDINATE::~COORDINATE() /*! sets the attribute _coordinate with Coordinate */ //----------------------------------------------------------// -void COORDINATE::setCoordinates(MEDARRAY *Coordinate) +void COORDINATE::setCoordinates(MEDARRAY *Coordinate,bool shallowCopy) //----------------------------------------------------------// { @@ -81,14 +81,20 @@ void COORDINATE::setCoordinates(MEDARRAY *Coordinate) // const int numberOfNodes = (int) Coordinate->getLengthValue(); if ( Coordinate->get(mode) != NULL) { - MEDARRAY pourAttribut(*Coordinate,false); - _coordinate = pourAttribut; - //_coordinate.set(mode,Coordinate->get(mode)); + if(shallowCopy) + { + _coordinate.shallowCopy(*Coordinate); + } + else + { + MEDARRAY pourAttribut(*Coordinate,false); + _coordinate = pourAttribut; + //_coordinate.set(mode,Coordinate->get(mode)); + } } else { - throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY - *Coordinate)") << "No Coordinate")); + throw MED_EXCEPTION ( LOCALIZED(STRING("setCoordinates(MEDARRAY *Coordinate)") << "No Coordinate")); } } @@ -213,10 +219,10 @@ const double * COORDINATE::getCoordinateAxis(int Axis) return _coordinate.getColumn(Axis) ; } -/*! returns an array with names of coordinates. /n - Example : /n - - x,y,z /n - - r,teta,phi /n +/*! returns an array with names of coordinates. \n + Example : \n + - x,y,z \n + - r,teta,phi \n - ... */ //--------------------------------------// const string * COORDINATE::getCoordinatesNames() const diff --git a/src/MEDMEM/MEDMEM_Coordinate.hxx b/src/MEDMEM/MEDMEM_Coordinate.hxx index b4d5454df..ac176f530 100644 --- a/src/MEDMEM/MEDMEM_Coordinate.hxx +++ b/src/MEDMEM/MEDMEM_Coordinate.hxx @@ -16,9 +16,9 @@ #include "MEDMEM_Array.hxx" /*! - This class contains coordinates of the nodes ./n + This class contains coordinates of the nodes .\n It could also store useful optional information about nodes - as node numbers and about axes as names or units. /n + as node numbers and about axes as names or units. \n spaceDimension and numberOfNodes can be found in _coordinate object. */ @@ -33,10 +33,10 @@ protected: /*! _coordinate is a MEDARRAY object : \n - - spaceDimension /n - - numberOfNodes /n - - default storage mode /n - - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes/n + - spaceDimension \n + - numberOfNodes \n + - default storage mode \n + - Up to 4 "PointerOf" to an array of size spaceDimension*NumberOfNodes\n Storing the object (not a pointer to this object) is more convenient for memory management. @@ -64,7 +64,7 @@ public : COORDINATE(const COORDINATE & m); virtual ~COORDINATE(); - void setCoordinates(MEDARRAY *Coordinate); + void setCoordinates(MEDARRAY *Coordinate,bool shallowCopy=false); void setCoordinates(const medModeSwitch Mode, const double *Coordinate); void setCoordinatesNames(const string * CoordinateName); void setCoordinateName(const string CoordinateName, const int i); diff --git a/src/MEDMEM/MEDMEM_DriverFactory.cxx b/src/MEDMEM/MEDMEM_DriverFactory.cxx new file mode 100644 index 000000000..80b7f80f0 --- /dev/null +++ b/src/MEDMEM/MEDMEM_DriverFactory.cxx @@ -0,0 +1,89 @@ +#include "MEDMEM_DriverFactory.hxx" + +#include "MEDMEM_Mesh.hxx" +#include "MEDMEM_MedMeshDriver.hxx" +#include "MEDMEM_GibiMeshDriver.hxx" +#include "MEDMEM_PorflowMeshDriver.hxx" +#include "MEDMEM_VtkMeshDriver.hxx" + +#include "MEDMEM_Med.hxx" +#include "MEDMEM_MedMedDriver.hxx" +#include "MEDMEM_VtkMedDriver.hxx" + +//#include "MEDMEM_Field.hxx" + +#include "MEDMEM_Exception.hxx" +//#include "MEDMEM_STRING.hxx" +//#include "utilities.h" + +using namespace MEDMEM; + +GENDRIVER *DRIVERFACTORY::buildDriverForMesh(driverTypes driverType, const std::string & fileName, MESH *mesh,const string & driverName) +{ + GENDRIVER *ret; + switch(driverType) + { + case MED_DRIVER : { + MED_MESH_RDWR_DRIVER *retmed=new MED_MESH_RDWR_DRIVER(fileName,mesh); + retmed->setMeshName(driverName); + return retmed; + } + + case GIBI_DRIVER : { + ret=new GIBI_MESH_RDWR_DRIVER(fileName,mesh); + return ret; + } + + case PORFLOW_DRIVER : { + ret=new PORFLOW_MESH_RDWR_DRIVER(fileName,mesh); + return ret; + } + + case VTK_DRIVER : { + ret=new VTK_MESH_DRIVER(fileName,mesh); + return ret; + } + + case NO_DRIVER : { + throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed"); + } + default: + throw MED_EXCEPTION ("other driver than MED_DRIVER GIBI_DRIVER PORFLOW_DRIVER and VT_DRIVER has been specified to the method which is not allowed"); + } +} + +GENDRIVER *DRIVERFACTORY::buildDriverForMed(driverTypes driverType, const std::string & fileName, MED *med) +{ + GENDRIVER *ret; + switch(driverType) + { + case MED_DRIVER : { + ret=new MED_MED_RDWR_DRIVER(fileName,med); + break ; + } + + case VTK_DRIVER : { + ret=new VTK_MED_DRIVER(fileName,med); + break ; + } + + case GIBI_DRIVER : { + throw MED_EXCEPTION ("GIBI_DRIVER has been specified to the method which is not allowed because there is no GIBI driver for the MED object"); + break; + } + + case PORFLOW_DRIVER : { + throw MED_EXCEPTION ("PORFLOW_DRIVER has been specified to the method which is not allowed because there is no PORFLOW driver for the MED object"); + break; + } + + case NO_DRIVER : { + throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed"); + break; + } + default: + throw MED_EXCEPTION ("NO_DRIVER has been specified to the method which is not allowed"); + } + return ret; +} + diff --git a/src/MEDMEM/MEDMEM_DriverFactory.hxx b/src/MEDMEM/MEDMEM_DriverFactory.hxx new file mode 100644 index 000000000..a233b3cb4 --- /dev/null +++ b/src/MEDMEM/MEDMEM_DriverFactory.hxx @@ -0,0 +1,63 @@ +#ifndef DRIVERFACTORY_HXX +#define DRIVERFACTORY_HXX + +#include "MEDMEM_GenDriver.hxx" +#include + +namespace MEDMEM { + + class MESH; + template class FIELD; + class MED; + + namespace DRIVERFACTORY { + GENDRIVER *buildDriverForMesh(driverTypes driverType, const std::string & fileName, MESH *mesh,const string & driverName); + template + GENDRIVER *buildDriverForField(driverTypes driverType, const std::string & fileName, FIELD *field); + GENDRIVER *buildDriverForMed(driverTypes driverType, const std::string & fileName, MED *med); + } + +} + +#include "MEDMEM_VtkFieldDriver.hxx" +#include "MEDMEM_MedFieldDriver.hxx" + +using namespace MEDMEM; + +template +GENDRIVER *DRIVERFACTORY::buildDriverForField(driverTypes driverType, const std::string & fileName, FIELD *field) +{ + GENDRIVER *ret; + switch(driverType) + { + case MED_DRIVER : { + ret=new MED_FIELD_RDWR_DRIVER(fileName,field); + break; + } + + case VTK_DRIVER : { + ret=new VTK_FIELD_DRIVER(fileName,field); + break ; + } + + case GIBI_DRIVER : { + throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); + break; + } + + case PORFLOW_DRIVER : { + throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); + break; + } + + case NO_DRIVER : { + throw MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); + break; + } + default: + MED_EXCEPTION ("driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD"); + } + return ret; +} + +#endif diff --git a/src/MEDMEM/MEDMEM_DriverTools.cxx b/src/MEDMEM/MEDMEM_DriverTools.cxx index 5401f2458..ba616891f 100644 --- a/src/MEDMEM/MEDMEM_DriverTools.cxx +++ b/src/MEDMEM/MEDMEM_DriverTools.cxx @@ -4,6 +4,7 @@ using namespace std; #include "MEDMEM_Exception.hxx" #include "MEDMEM_Mesh.hxx" #include "MEDMEM_Group.hxx" +#include #include using namespace MEDMEM; diff --git a/src/MEDMEM/MEDMEM_DriversDef.hxx b/src/MEDMEM/MEDMEM_DriversDef.hxx index 981f0b7a5..7bf078274 100644 --- a/src/MEDMEM/MEDMEM_DriversDef.hxx +++ b/src/MEDMEM/MEDMEM_DriversDef.hxx @@ -12,10 +12,10 @@ using namespace std ; #include "utilities.h" namespace MED_FR { -/*! This Class inherits from map. /n - It is a constant map association int (which is a med_geometrie_element) and string. /n +/*! This Class inherits from map. \n + It is a constant map association int (which is a med_geometrie_element) and string. \n Operator [] returns the (string) name of the geometry of an element - given by a med_geometrie_element value. /n + given by a med_geometrie_element value. \n Such a static map is instancied and can be used in any code to have the name of the geometry of an element : MED_FR:GEO_NAME A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ @@ -35,10 +35,10 @@ static const GEO_NAME geoNames ; // ____________________________ -/*! This Class inherits from map. /n - It is a constant map association int (which is a med_entite_maillage) and string. /n +/*! This Class inherits from map. \n + It is a constant map association int (which is a med_entite_maillage) and string. \n Operator[] returns the (string) name of the type of an entity given by - a med_entite_maillage value. /n + a med_entite_maillage value. \n Such a static map is instancied and can be used in any code to have the name of the geometry of an element : MED_FR:ENT_NAME A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ @@ -59,10 +59,10 @@ static const ENT_NAME entNames ; // ____________________________ -/*! This Class inherits from map. /n - It is a constant map association int (which is a med_entite_maillage) and a list. /n +/*! This Class inherits from map. \n + It is a constant map association int (which is a med_entite_maillage) and a list. \n Operator[] returns the list of all exisiting med_geometrie_element for - a med_entite_maillage value. /n + a med_entite_maillage value. \n Such a static map is instancied and can be used in any code to have the name of the geometry of an element : MED_FR:MESH_ENTITIES A simple test/use case can be found in test/testUGeoNameMeshEntities.cxx */ diff --git a/src/MEDMEM/MEDMEM_Exception.cxx b/src/MEDMEM/MEDMEM_Exception.cxx index ccd7c216a..cfe4281c8 100644 --- a/src/MEDMEM/MEDMEM_Exception.cxx +++ b/src/MEDMEM/MEDMEM_Exception.cxx @@ -22,8 +22,8 @@ extern "C" \internal Function used to duplicate char * */ -const char* duplicate( const char *const str ) ; -const char* duplicate( const char *const str ) +char* duplicate( const char *const str ) ; +char* duplicate( const char *const str ) { ASSERT(str!=NULL) ; const size_t length = strlen( str ) ; @@ -51,7 +51,7 @@ MEDEXCEPTION::MEDEXCEPTION( void ): exception() , _text(0) Function used to elaborate the text of the MEDEXCEPTION */ // --------------------------------------------------------------------------------------- // -const char *makeText( const char *text, const char *fileName, const unsigned int lineNumber ) +char *makeText( const char *text, const char *fileName, const unsigned int lineNumber ) // --------------------------------------------------------------------------------------- // { char *newText = 0 ; @@ -110,8 +110,7 @@ MEDEXCEPTION::~MEDEXCEPTION() throw () if ( _text ) { delete [] _text ; - char *& txt = (char*)_text ; - txt = 0 ; + _text = 0 ; } ASSERT(_text==NULL) ; } diff --git a/src/MEDMEM/MEDMEM_Exception.hxx b/src/MEDMEM/MEDMEM_Exception.hxx index 1591771df..3ea508ce0 100644 --- a/src/MEDMEM/MEDMEM_Exception.hxx +++ b/src/MEDMEM/MEDMEM_Exception.hxx @@ -30,7 +30,7 @@ private : MEDEXCEPTION(void); protected : - const char* _text ; + char* _text ; public : MEDEXCEPTION(const char *text, const char *fileName=0, diff --git a/src/MEDMEM/MEDMEM_Family.hxx b/src/MEDMEM/MEDMEM_Family.hxx index f1fe07824..ea8a45edf 100644 --- a/src/MEDMEM/MEDMEM_Family.hxx +++ b/src/MEDMEM/MEDMEM_Family.hxx @@ -6,10 +6,10 @@ /*! - This class describe a family of elements on an entity./n - It inherits from support. /n + This class describe a family of elements on an entity.\n + It inherits from support. \n It contains a list of elements (by SUPPORT class inheritance) - and a description of some attributs./n + and a description of some attributs.\n All families on one entity represent a mesh partition for this entity. @@ -27,7 +27,7 @@ protected : int _identifier ; /*! \if developper - Number of attribute of the family ./n + Number of attribute of the family .\n Note that attributes are numbered from 1 to N. \endif */ @@ -180,7 +180,7 @@ inline void FAMILY::setGroupsNames(string * GroupName) { _groupName = GroupName ; } -/*! Returns the attribute _identifier./n +/*! Returns the attribute _identifier.\n Note that there is one identifier precisely for each family. */ //-------------------------------------- inline int FAMILY::getIdentifier() const @@ -204,7 +204,7 @@ inline int * FAMILY::getAttributesIdentifiers() const { return _attributeIdentifier ; } -/*! Returns identifer of the Ith attribute of the family./n +/*! Returns identifer of the Ith attribute of the family.\n Note that they are numbered from 1 to N */ //---------------------------------------------------- inline int FAMILY::getAttributeIdentifier(int i) const @@ -220,7 +220,7 @@ inline int * FAMILY::getAttributesValues() const { return _attributeValue ; } -/*! Returns value of the Ith attribute of the family./n +/*! Returns value of the Ith attribute of the family.\n Note that they are numbered from 1 to N */ //----------------------------------------------- inline int FAMILY::getAttributeValue(int i) const @@ -234,7 +234,7 @@ inline string * FAMILY::getAttributesDescriptions() const { return _attributeDescription ; } -/*! Returns description of the Ith attribute of the family/n +/*! Returns description of the Ith attribute of the family\n Note that they are numbered from 1 to N */ //-------------------------------------------------------- inline string FAMILY::getAttributeDescription(int i) const @@ -256,7 +256,7 @@ inline string * FAMILY::getGroupsNames() const { return _groupName ; } -/*! Returns the name of the Ith group the family belongs to./n +/*! Returns the name of the Ith group the family belongs to.\n Note that they are numbered from 1 to N*/ //--------------------------------------------- inline string FAMILY::getGroupName(int i) const diff --git a/src/MEDMEM/MEDMEM_Field.cxx b/src/MEDMEM/MEDMEM_Field.cxx index c36f44dc9..9b7fc3294 100644 --- a/src/MEDMEM/MEDMEM_Field.cxx +++ b/src/MEDMEM/MEDMEM_Field.cxx @@ -1,5 +1,6 @@ using namespace std; #include "MEDMEM_Field.hxx" +#include "MEDMEM_Mesh.hxx" using namespace MEDMEM; // --------------------------------- @@ -210,13 +211,16 @@ void FIELD_::_checkFieldCompatibility(const FIELD_& m, const FIELD_& n ) throw ( // check-up, fill diagnosis if some incompatibility is found. if(m._support != n._support) - diagnosis+="They don't have the same support!"; + { + if(!(*m._support==*n._support)) + diagnosis+="They don't have the same support!"; + } else if(m._numberOfComponents != n._numberOfComponents) - diagnosis+="They don't have the same number of components!"; + diagnosis+="They don't have the same number of components!"; else if(m._numberOfValues != n._numberOfValues) - diagnosis+="They don't have the same number of values!"; + diagnosis+="They don't have the same number of values!"; else - { + { for(int i=0; i class FIELD; + class FIELD_ // GENERIC POINTER TO a template class FIELD { protected: @@ -77,13 +75,13 @@ protected: /*! \if developper - Array of size _numberOfComponents. /n - (constant, scalar, vector, tensor)/n + Array of size _numberOfComponents. \n + (constant, scalar, vector, tensor)\n We could use an array of integer to store - numbers of values: /n - - 1 for scalar,/n - - space dimension for vector,/n - - space dimension square for tensor./n + numbers of values: \n + - 1 for scalar,\n + - space dimension for vector,\n + - space dimension square for tensor.\n So numbers of values per entities would be sum of _componentsTypes array. @@ -539,37 +537,14 @@ inline void FIELD_::setValueType (const med_type_champ ValueType) */ namespace MEDMEM { + + template class MED_FIELD_RDONLY_DRIVER; + template class MED_FIELD_WRONLY_DRIVER; + template class VTK_FIELD_DRIVER; + template class FIELD : public FIELD_ { - - // ------- Drivers Management Part protected: - - //-----------------------// - class INSTANCE - //-----------------------// - { - public: - virtual GENDRIVER * run(const string & fileName, FIELD * ptrFIELD) const = 0 ; - } ; - - //-------------------------------------------------------// - template class INSTANCE_DE : public INSTANCE - //-------------------------------------------------------// - { - public : - GENDRIVER * run(const string & fileName, FIELD * ptrFIELD) const - { - return new T2(fileName,ptrFIELD); - } - } ; - - // static INSTANCE_DE inst_med_rdonly ; - static INSTANCE_DE > inst_med ; - static INSTANCE_DE > inst_vtk ; - - static const INSTANCE * const instances[] ; - // ------ End of Drivers Management Part // array of value of type T @@ -620,7 +595,6 @@ public: friend class MED_FIELD_RDONLY_DRIVER; friend class MED_FIELD_WRONLY_DRIVER; - friend class VTK_FIELD_DRIVER; //friend class MED_FIELD_RDWR_DRIVER ; @@ -647,6 +621,7 @@ public: inline void setValue(MEDARRAY *Value); inline MEDARRAY* getvalue() const; + inline int getValueLength(medModeSwitch Mode) const; inline const T* getValue(medModeSwitch Mode) const; inline const T* getValueI(medModeSwitch Mode,int i) const; inline T getValueIJ(int i,int j) const; @@ -792,7 +767,7 @@ template FIELD & FIELD::operator=(const FIELD &m) /*! Overload addition operator. This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:/n + The compatibility checking includes equality tests of the folowing data members:\n - _support - _numberOfComponents - _numberOfValues @@ -801,11 +776,11 @@ template FIELD & FIELD::operator=(const FIELD &m) The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a + b; /n + Advised Utilisation in C++ : FIELD c = a + b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator + in associatives expressions like - a = b + c + d +e; /n + a = b + c + d +e; \n no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ @@ -889,7 +864,7 @@ FIELD* FIELD::add(const FIELD& m, const FIELD& n) /*! Overload substraction operator. This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:/n + The compatibility checking includes equality tests of the folowing data members:\n - _support - _numberOfComponents - _numberOfValues @@ -898,11 +873,11 @@ FIELD* FIELD::add(const FIELD& m, const FIELD& n) The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a - b; /n + Advised Utilisation in C++ : FIELD c = a - b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator - in associatives expressions like - a = b - c - d -e; /n + a = b - c - d -e; \n no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ @@ -1019,7 +994,7 @@ FIELD* FIELD::sub(const FIELD& m, const FIELD& n) /*! Overload multiplication operator. This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:/n + The compatibility checking includes equality tests of the folowing data members:\n - _support - _numberOfComponents - _numberOfValues @@ -1028,11 +1003,11 @@ FIELD* FIELD::sub(const FIELD& m, const FIELD& n) The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a * b; /n + Advised Utilisation in C++ : FIELD c = a * b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator * in associatives expressions like - a = b * c * d *e; /n + a = b * c * d *e; \n no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ @@ -1118,7 +1093,7 @@ FIELD* FIELD::mul(const FIELD& m, const FIELD& n) /*! Overload division operator. This operation is authorized only for compatible fields that have the same support. - The compatibility checking includes equality tests of the folowing data members:/n + The compatibility checking includes equality tests of the folowing data members:\n - _support - _numberOfComponents - _numberOfValues @@ -1127,11 +1102,11 @@ FIELD* FIELD::mul(const FIELD& m, const FIELD& n) The data members of the returned field are initialized, based on the first field, except for the name, which is the combination of the two field's names and the operator. - Advised Utilisation in C++ : FIELD c = a / b; /n + Advised Utilisation in C++ : FIELD c = a / b; \n In this case, the (recent) compilators perform optimisation and don't call the copy constructor. When using python, this operator calls the copy constructor in any case. The user has to be aware that when using operator / in associatives expressions like - a = b / c / d /e; /n + a = b / c / d /e; \n no optimisation is performed : the evaluation of last expression requires the construction of 3 temporary fields. */ @@ -1450,7 +1425,7 @@ template void FIELD::applyLin(T a, T b) /*! * Return a pointer to a new field that holds the scalar product. Static member function. * This operation is authorized only for compatible fields that have the same support. - * The compatibility checking includes equality tests of the folowing data members:/n + * The compatibility checking includes equality tests of the folowing data members:\n * - _support * - _numberOfComponents * - _numberOfValues @@ -1798,14 +1773,6 @@ template void FIELD::deallocValue() // Methodes Inline // ----------------- - -template FIELD::INSTANCE_DE > FIELD::inst_med ; - -template FIELD::INSTANCE_DE > FIELD::inst_vtk ; - -template const typename FIELD::INSTANCE * const FIELD::instances[] = { &FIELD::inst_med, &FIELD::inst_vtk} ; - - /*! Create the specified driver and return its index reference to path to read or write methods. @@ -1818,46 +1785,16 @@ template int FIELD::addDriver(driverTypes driverType, const char * LOC = "FIELD::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Field Name\") : "; GENDRIVER * driver; - int current; - int itDriver = (int) NO_DRIVER; BEGIN_OF(LOC); SCRUTE(driverType); - SCRUTE(instances[driverType]); - - switch(driverType) - { - case MED_DRIVER : { - itDriver = (int) driverType ; - break ; - } - - case VTK_DRIVER : { - itDriver = 1 ; - break ; - } - - case GIBI_DRIVER : { - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD")); - break; - } - - case NO_DRIVER : { - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD")); - break; - } - } - - if (itDriver == ((int) NO_DRIVER)) - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "driverType other than MED_DRIVER and VTK_DRIVER has been specified to the method which is not allowed for the object FIELD")); - - driver = instances[itDriver]->run(fileName, this) ; + driver = DRIVERFACTORY::buildDriverForField(driverType,fileName,this); _drivers.push_back(driver); - current = _drivers.size()-1; + int current = _drivers.size()-1; _drivers[current]->setFieldName(driverName); @@ -2073,6 +2010,13 @@ template inline MEDARRAY* FIELD::getvalue() const return _value ; } +/*! + Return the actual length of the reference to values array returned by getValue. +*/ +template inline int FIELD::getValueLength(medModeSwitch Mode) const{ + return _numberOfComponents*_numberOfValues; +} + /*! Return a reference to values array to read them. */ diff --git a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx index d401ffff1..fa7fb1875 100644 --- a/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx +++ b/src/MEDMEM/MEDMEM_GibiMeshDriver.cxx @@ -308,8 +308,8 @@ void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION) if (nb_indices != nb_objets) { throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName - << "Erreur de lecture dans enregistrement de type " << ENREG_TYPE_2 - << " (pile " << PILE_NOEUDS << ")" )); + << "Erreur de lecture dans enregistrement de type " << (int)ENREG_TYPE_2 + << " (pile " << (int)PILE_NOEUDS << ")" )); } place_noeuds.resize(nb_objets); @@ -331,8 +331,8 @@ void GIBI_MESH_RDONLY_DRIVER::read(void) throw (MEDEXCEPTION) // PROVISOIRE : certains fichier gibi n'ont if (nb_reels < numero_noeuds.size()*(space_dimension)) throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << " Could not read file " << _fileName - << "Erreur de lecture dans enregistrement de type " << ENREG_TYPE_2 - << " (pile " << PILE_COORDONNEES << ")" )); + << "Erreur de lecture dans enregistrement de type " << (int)ENREG_TYPE_2 + << " (pile " << (int)PILE_COORDONNEES << ")" )); for (unsigned i=0; i!=numero_noeuds.size(); ++i) { diff --git a/src/MEDMEM/MEDMEM_Group.cxx b/src/MEDMEM/MEDMEM_Group.cxx index 870cf85b4..85dfb2490 100644 --- a/src/MEDMEM/MEDMEM_Group.cxx +++ b/src/MEDMEM/MEDMEM_Group.cxx @@ -61,7 +61,7 @@ GROUP::GROUP(const string & name, const list & families) throw (MEDEXCE SCRUTE(numberOfFamilies); - if ((numberOfFamilies==1)&(isOnAllElts)) + if ((numberOfFamilies==1) || (isOnAllElts)) { _numberOfFamilies = numberOfFamilies; _isOnAllElts = isOnAllElts ; diff --git a/src/MEDMEM/MEDMEM_Group.hxx b/src/MEDMEM/MEDMEM_Group.hxx index f0cde2141..d5c5a8b1a 100644 --- a/src/MEDMEM/MEDMEM_Group.hxx +++ b/src/MEDMEM/MEDMEM_Group.hxx @@ -13,9 +13,9 @@ /*! - This class describe a group of elements on an entity./n - It inherits from SUPPORT./n - It is a blending of some FAMILY class./n/n + This class describe a group of elements on an entity.\n + It inherits from SUPPORT.\n + It is a blending of some FAMILY class.\n\n */ diff --git a/src/MEDMEM/MEDMEM_Med.cxx b/src/MEDMEM/MEDMEM_Med.cxx index 5671280db..4169c4464 100644 --- a/src/MEDMEM/MEDMEM_Med.cxx +++ b/src/MEDMEM/MEDMEM_Med.cxx @@ -2,7 +2,7 @@ using namespace std; # include # include "MEDMEM_Med.hxx" - +# include "MEDMEM_DriverFactory.hxx" # include "MEDMEM_STRING.hxx" # include "MEDMEM_Mesh.hxx" @@ -30,9 +30,7 @@ MED::MED(driverTypes driverType, const string & fileName) MESSAGE(LOC << "driverType = " << driverType); - MED_MED_RDONLY_DRIVER * myDriver = new MED_MED_RDONLY_DRIVER(fileName,this) ; - int current = addDriver(*myDriver); - //int current= addDriver(driverType,fileName); + int current = addDriver(driverType,fileName); _drivers[current]->open(); _drivers[current]->readFileStruct(); @@ -144,14 +142,6 @@ MED::~MED() END_OF(LOC); } ; -// ------- Drivers Management Part - -// Add your new driver instance declaration here (step 3-1) -MED::INSTANCE_DE MED::inst_med ; -MED::INSTANCE_DE MED::inst_vtk ; - -// Add your new driver instance in the MED instance list (step 3-2) -const MED::INSTANCE * const MED::instances[] = { &MED::inst_med, &MED::inst_vtk }; /*! Create the specified driver and return its index reference to path to @@ -160,9 +150,6 @@ const MED::INSTANCE * const MED::instances[] = { &MED::inst_med, &MED::inst_vtk int MED::addDriver(driverTypes driverType, const string & fileName="Default File Name.med") { const char * LOC = "MED::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\") : "; - GENDRIVER * driver; - int current; - int itDriver = (int) NO_DRIVER; BEGIN_OF(LOC); @@ -170,37 +157,11 @@ int MED::addDriver(driverTypes driverType, const string & fileName="Default File SCRUTE(driverType); - SCRUTE(instances[driverType]); - - switch(driverType) - { - case MED_DRIVER : { - itDriver = (int) driverType ; - break ; - } - - case VTK_DRIVER : { - itDriver = 1 ; - break ; - } - - case GIBI_DRIVER : { - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "GIBI_DRIVER has been specified to the method which is not allowed because there is no GIBI driver for the MED object")); - break; - } - - case NO_DRIVER : { - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed")); - break; - } - } + GENDRIVER *driver = DRIVERFACTORY::buildDriverForMed(driverType,fileName,this); - if (itDriver == ((int) NO_DRIVER)) - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed")); + _drivers.push_back(driver); - driver = instances[itDriver]->run(fileName, this) ; - - current = _drivers.size()-1; + int current = _drivers.size()-1; driver->setId(current); @@ -231,13 +192,9 @@ int MED::addDriver(GENDRIVER & driver) { current = _drivers.size()-1; SCRUTE(current); driver.setId(current); - - - MESSAGE(LOC << " je suis la 1"); END_OF(LOC); - MESSAGE(LOC << " je suis la 2"); return current; } diff --git a/src/MEDMEM/MEDMEM_Med.hxx b/src/MEDMEM/MEDMEM_Med.hxx index adf96c1b6..1cba1d33d 100644 --- a/src/MEDMEM/MEDMEM_Med.hxx +++ b/src/MEDMEM/MEDMEM_Med.hxx @@ -9,12 +9,9 @@ // LOCAL # include "MEDMEM_define.hxx" - -// Add your own driver header (step 2) -# include "MEDMEM_MedMedDriver.hxx" -# include "MEDMEM_VtkMedDriver.hxx" - # include "MEDMEM_Exception.hxx" +# include "MEDMEM_GenDriver.hxx" + using namespace MED_EN; @@ -85,31 +82,6 @@ public: void addField ( FIELD_ * const ptrField ) throw (MED_EXCEPTION) ; void addMesh ( MESH * const ptrMesh ) throw (MED_EXCEPTION) ; - - // ------ Drivers Management Part -protected: - - class INSTANCE { - public: - virtual GENDRIVER * run(const string & fileName, MED * const ptrMed) const = 0 ; - } ; - - template class INSTANCE_DE : public INSTANCE { - public : - GENDRIVER * run(const string & fileName, MED * const ptrMed) const - { - MESSAGE("GENDRIVER * run") ; - return new T(fileName,ptrMed) ; - } - } ; - - // Add your new driver instance here (step 3) - static INSTANCE_DE inst_med ; - static INSTANCE_DE inst_vtk ; - static const INSTANCE * const instances[] ; - -public: - int addDriver (driverTypes driverType, const string & fileName); int addDriver (GENDRIVER & driver); void rmDriver (int index=0) throw (MEDEXCEPTION) ; diff --git a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx index 13da382e5..6ffab10ed 100644 --- a/src/MEDMEM/MEDMEM_MedFieldDriver.hxx +++ b/src/MEDMEM/MEDMEM_MedFieldDriver.hxx @@ -384,16 +384,16 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) const char * LOC = " MED_FIELD_RDONLY_DRIVER::read() " ; BEGIN_OF(LOC); - if (_ptrField->_name=="") - _ptrField->_name = _fieldName ; + if (MED_FIELD_DRIVER::_ptrField->_name=="") + MED_FIELD_DRIVER::_ptrField->_name = MED_FIELD_DRIVER::_fieldName ; else - _fieldName = _ptrField->_name; // bug indetermine ! apres avoir fait readfilestruct, lorsque je recupere le champ, tout est bon sauf le nom du champ dans le driver !!!!! + 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("###### "<_name); + MESSAGE("###### "<::_fieldName<<" fieldName : "<::_ptrField->_name); - string MeshName = _ptrField->getSupport()->getMesh()->getName() ; + string MeshName = MED_FIELD_DRIVER::_ptrField->getSupport()->getMesh()->getName() ; - if (_status==MED_OPENED) + if (MED_FIELD_DRIVER::_status==MED_OPENED) { // search_field() ; @@ -407,14 +407,14 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) MED_FR::med_type_champ type ; // we search the field number !!!! - if (_fieldNum==MED_INVALID) { + if (MED_FIELD_DRIVER::_fieldNum==MED_INVALID) { int numberOfFields = 0; //MED_INVALID - numberOfFields = MED_FR::MEDnChamp(_medIdt,0) ; + numberOfFields = MED_FR::MEDnChamp(MED_FIELD_DRIVER::_medIdt,0) ; if ( numberOfFields <= 0 ) throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<": No Field found !")); for (int i=1;i<=numberOfFields;i++) { - numberOfComponents = MED_FR::MEDnChamp(_medIdt,i) ; + numberOfComponents = MED_FR::MEDnChamp(MED_FIELD_DRIVER::_medIdt,i) ; if ( numberOfComponents <= 0 ) // throw MED_EXCEPTION ( LOCALIZED( STRING(LOC) // << "Be careful there is no compound for field n°" @@ -424,13 +424,13 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) componentName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ; unitName = new char[numberOfComponents*MED_TAILLE_PNOM+1] ; - err = MED_FR::MEDchampInfo(_medIdt, i, fieldName, &type, componentName, + err = MED_FR::MEDchampInfo(MED_FIELD_DRIVER::_medIdt, 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 ; } // not found : release memory and search next field ! @@ -441,50 +441,51 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) delete[] fieldName ; - if (_fieldNum==MED_INVALID) - throw MEDEXCEPTION(LOCALIZED( STRING(LOC) << ": Field "<<_fieldName << " not found in file " << _fileName ) ); - MESSAGE ("FieldNum : "<<_fieldNum); + 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_FR::MEDnChamp(_medIdt,_fieldNum) ; + // int NumberOfComponents = MED_FR::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 !!!??? - _ptrField->_numberOfComponents = numberOfComponents ; - _ptrField->_componentsTypes = new int[numberOfComponents] ; - _ptrField->_componentsNames = new string[numberOfComponents] ; - _ptrField->_componentsUnits = new UNIT[numberOfComponents] ; - _ptrField->_componentsDescriptions = new string[numberOfComponents] ; - _ptrField->_MEDComponentsUnits = new string[numberOfComponents] ; + 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_componentsTypes[i] = 1 ; + MED_FIELD_DRIVER::_ptrField->_componentsTypes[i] = 1 ; // PG : what about space !!! - _ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; - SCRUTE(_ptrField->_componentsNames[i]); - _ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; - SCRUTE(_ptrField->_MEDComponentsUnits[i]); + MED_FIELD_DRIVER::_ptrField->_componentsNames[i] = string(componentName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; + SCRUTE(MED_FIELD_DRIVER::_ptrField->_componentsNames[i]); + MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i] = string(unitName,i*MED_TAILLE_PNOM,MED_TAILLE_PNOM) ; + SCRUTE(MED_FIELD_DRIVER::_ptrField->_MEDComponentsUnits[i]); } delete[] componentName; delete[] unitName; // read values for each geometric type in _support - int NumberOfTypes = _ptrField->_support->getNumberOfTypes() ; - const medGeometryElement *Types = _ptrField->_support->getTypes() ; - T ** myValues = new (T*)[NumberOfTypes] ; + int NumberOfTypes = MED_FIELD_DRIVER::_ptrField->_support->getNumberOfTypes() ; + const medGeometryElement *Types = MED_FIELD_DRIVER::_ptrField->_support->getTypes() ; + T ** myValues = new T*[NumberOfTypes] ; int * NumberOfValues = new int[NumberOfTypes] ; int TotalNumberOfValues = 0 ; MESSAGE ("NumberOfTypes :"<< NumberOfTypes); + _ptrField->_numberOfValues=0 ; for (int i=0; i_support->getEntity()); + MESSAGE ("Entity :"<::_ptrField->_support->getEntity()); NumberOfValues[i] = - MEDnVal(_medIdt, - const_cast (_fieldName.c_str()), - (MED_FR::med_entite_maillage)_ptrField->_support->getEntity(), + MEDnVal(MED_FIELD_DRIVER::_medIdt, + const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), + (MED_FR::med_entite_maillage)MED_FIELD_DRIVER::_ptrField->_support->getEntity(), (MED_FR::med_geometrie_element)Types[i], - _ptrField->_iterationNumber, - _ptrField->_orderNumber) ; // no time step ! prend en compte le nbre de pt de gauss + 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 @@ -494,21 +495,21 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) MESSAGE ("NumberOfValues :"<< NumberOfValues[i]); MESSAGE ("NumberOfComponents :"<< numberOfComponents); MESSAGE ("MESH_NAME :"<< MeshName.c_str()); - MESSAGE ("FIELD_NAME :"<< _fieldName.c_str()); - MESSAGE ("MED_ENTITE :"<< (MED_FR::med_entite_maillage) _ptrField->_support->getEntity()); + MESSAGE ("FIELD_NAME :"<< MED_FIELD_DRIVER::_fieldName.c_str()); + MESSAGE ("MED_ENTITE :"<< (MED_FR::med_entite_maillage) MED_FIELD_DRIVER::_ptrField->_support->getEntity()); MESSAGE("MED_GEOM :"<<(MED_FR::med_geometrie_element)Types[i]); - MESSAGE("Iteration :"<<_ptrField->getIterationNumber()); - MESSAGE("Order :"<<_ptrField->getOrderNumber()); - _ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! - if ( MED_FR::MEDchampLire(_medIdt,const_cast (MeshName.c_str()), - const_cast (_fieldName.c_str()), + MESSAGE("Iteration :"<::_ptrField->getIterationNumber()); + MESSAGE("Order :"<::_ptrField->getOrderNumber()); + MED_FIELD_DRIVER::_ptrField->_numberOfValues+=NumberOfValues[i]; // problem with gauss point : _numberOfValues != TotalNumberOfValues !!!!!!! + if ( MED_FR::MEDchampLire(MED_FIELD_DRIVER::_medIdt,const_cast (MeshName.c_str()), + const_cast (MED_FIELD_DRIVER::_fieldName.c_str()), (unsigned char*) myValues[i], MED_FR::MED_NO_INTERLACE, MED_ALL, ProfilName, - (MED_FR::med_entite_maillage) _ptrField->_support->getEntity(),(MED_FR::med_geometrie_element)Types[i], - _ptrField->getIterationNumber(), - _ptrField->getOrderNumber() + (MED_FR::med_entite_maillage) MED_FIELD_DRIVER::_ptrField->_support->getEntity(),(MED_FR::med_geometrie_element)Types[i], + MED_FIELD_DRIVER::_ptrField->getIterationNumber(), + MED_FIELD_DRIVER::_ptrField->getOrderNumber() ) < 0) { // we must do some delete !!! for(int j=0; j<=i;j++) @@ -516,17 +517,17 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) delete[] myValues; delete[] NumberOfValues ; delete[] ProfilName; - delete[] _ptrField->_componentsTypes ; - delete[] _ptrField->_componentsNames ; - delete[] _ptrField->_componentsUnits ; - delete[] _ptrField->_componentsDescriptions ; - delete[] _ptrField->_MEDComponentsUnits ; - _ptrField->_componentsTypes = NULL ; - _ptrField->_componentsNames = NULL ; - _ptrField->_componentsUnits = NULL ; - _ptrField->_componentsDescriptions = NULL ; - _ptrField->_MEDComponentsUnits = NULL ; - _fieldNum = MED_INVALID ; // we have not found right field, so reset the field number + 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")) ; } @@ -534,12 +535,12 @@ template void MED_FIELD_RDONLY_DRIVER::read(void) } // allocate _value // probleme avec les points de gauss : voir lorsqu-il y en a (!= 1) - // MEDARRAY * Values = new MEDARRAY(_ptrField->getNumberOfComponents(),TotalNumberOfValues/_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE); + // MEDARRAY * Values = new MEDARRAY(MED_FIELD_DRIVER::_ptrField->getNumberOfComponents(),TotalNumberOfValues/MED_FIELD_DRIVER::_ptrField->getNumberOfComponents(),MED_EN::MED_NO_INTERLACE); - if (_ptrField->_value==NULL) - _ptrField->_value=new MEDARRAY(numberOfComponents,TotalNumberOfValues,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 = _ptrField->_value ; // create by constructor ??? + 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 "< void MED_FIELD_RDONLY_DRIVER::read(void) for (int j=0; j_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_DRIVER::read(void) delete[] myValues ; delete[] NumberOfValues ; - _ptrField->_isRead = true ; + MED_FIELD_DRIVER::_ptrField->_isRead = true ; } END_OF(LOC); @@ -601,16 +602,16 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const { const char * LOC = "MED_FIELD_WRONLY_DRIVER::write(void) const " ; BEGIN_OF(LOC); - if (_status==MED_OPENED) + if (MED_FIELD_DRIVER::_status==MED_OPENED) { int err ; - int component_count=_ptrField->getNumberOfComponents(); + int component_count=MED_FIELD_DRIVER::_ptrField->getNumberOfComponents(); string component_name(component_count*MED_TAILLE_PNOM,' ') ; string component_unit(component_count*MED_TAILLE_PNOM,' ') ; - const string * listcomponent_name=_ptrField->getComponentsNames() ; - const string * listcomponent_unit=_ptrField->getMEDComponentsUnits() ; + const string * listcomponent_name=MED_FIELD_DRIVER::_ptrField->getComponentsNames() ; + const string * listcomponent_unit=MED_FIELD_DRIVER::_ptrField->getMEDComponentsUnits() ; int length ; for (int i=0; i < component_count ; i++) { length = min(MED_TAILLE_PNOM,(int)listcomponent_name[i].size()); @@ -624,7 +625,7 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const MESSAGE("component_name=|"<getValueType() ; + MED_EN::med_type_champ ValueType=MED_FIELD_DRIVER::_ptrField->getValueType() ; MESSAGE("Template Type =|"< void MED_FIELD_WRONLY_DRIVER::write(void) const char * compName ; char * compUnit ; bool Find = false ; - int n = MED_FR::MEDnChamp(_medIdt,0); + int n = MED_FR::MEDnChamp(MED_FIELD_DRIVER::_medIdt,0); int nbComp ; for (int i=1; i<=n; i++) { - nbComp = MED_FR::MEDnChamp(_medIdt,i); + nbComp = MED_FR::MEDnChamp(MED_FIELD_DRIVER::_medIdt,i); compName = new char[MED_TAILLE_PNOM*nbComp+1]; compUnit = new char[MED_TAILLE_PNOM*nbComp+1]; - err = MED_FR::MEDchampInfo(_medIdt,i,champName,&type,compName,compUnit,nbComp); + err = MED_FR::MEDchampInfo(MED_FIELD_DRIVER::_medIdt,i,champName,&type,compName,compUnit,nbComp); if (err == 0) - if (strcmp(champName,_ptrField->getName().c_str())==0) { // Found ! + if (strcmp(champName,MED_FIELD_DRIVER::_ptrField->getName().c_str())==0) { // Found ! Find = true ; break ; } @@ -669,14 +670,14 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const // Verify the field doesn't exist string dataGroupName = "/CHA/"; - dataGroupName += _ptrField->getName(); + dataGroupName += MED_FIELD_DRIVER::_ptrField->getName(); MESSAGE(LOC << "|" << dataGroupName << "|" ); - med_idt gid = H5Gopen(_medIdt, dataGroupName.c_str() ); + med_idt gid = H5Gopen(MED_FIELD_DRIVER::_medIdt, dataGroupName.c_str() ); if ( gid < 0 ) { // create field : - err=MED_FR::MEDchampCr(_medIdt, - const_cast ((_ptrField->getName()).c_str()), + err=MED_FR::MEDchampCr(MED_FIELD_DRIVER::_medIdt, + const_cast ((MED_FIELD_DRIVER::_ptrField->getName()).c_str()), (MED_FR::med_type_champ) ValueType, const_cast ( component_name.c_str() ), const_cast ( component_unit.c_str() ), @@ -690,7 +691,7 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const else H5Gclose(gid); } - const SUPPORT * mySupport = _ptrField->getSupport() ; + const SUPPORT * mySupport = MED_FIELD_DRIVER::_ptrField->getSupport() ; if (! mySupport->isOnAllElements()) throw MEDEXCEPTION( LOCALIZED (STRING(LOC) @@ -700,7 +701,7 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const MESH * myMesh = mySupport->getMesh() ; string MeshName = myMesh->getName() ; - //MED_EN::medModeSwitch Mode = _ptrField->_value->getMode() ; + //MED_EN::medModeSwitch Mode = MED_FIELD_DRIVER::_ptrField->_value->getMode() ; // on boucle sur tout les types pour ecrire les tableaux de valeur int NumberOfType = mySupport->getNumberOfTypes() ; int Index = 1 ; @@ -709,19 +710,19 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const for (int i=0;igetNumberOfElements(Types[i]) ; - const T * value = _ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ; + const T * value = MED_FIELD_DRIVER::_ptrField->getValueI(MED_EN::MED_FULL_INTERLACE,Index) ; - MESSAGE("_medIdt : "<<_medIdt); + MESSAGE("MED_FIELD_DRIVER::_medIdt : "<::_medIdt); MESSAGE("MeshName.c_str() : "<getName() : "<<_ptrField->getName()); + MESSAGE("MED_FIELD_DRIVER::_ptrField->getName() : "<::_ptrField->getName()); MESSAGE("value : "<getEntity() : "<getEntity()); MESSAGE("Types[i] : "<getIterationNumber() : "<<_ptrField->getIterationNumber()); - MESSAGE("_ptrField->getTime() : "<<_ptrField->getTime()); - MESSAGE("_ptrField->getOrderNumber() : "<<_ptrField->getOrderNumber()); + MESSAGE("MED_FIELD_DRIVER::_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]; @@ -729,7 +730,7 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const MED_FR::med_type_champ chatype; med_int chancomp=1; - err=MED_FR::MEDchampInfo(_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp); + err=MED_FR::MEDchampInfo(MED_FIELD_DRIVER::_medIdt,1,chanom,&chatype,chacomp,chaunit,chancomp); if (err<0) { @@ -743,9 +744,9 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const cout<<"==================> valeur de MED_FR::MED_REEL64 = "<::_medIdt, const_cast ( MeshName.c_str()) , //( string(mesh_name).resize(MED_TAILLE_NOM).c_str()) - const_cast ( (_ptrField->getName()).c_str()), + const_cast ( (MED_FIELD_DRIVER::_ptrField->getName()).c_str()), (unsigned char*)value, MED_FR::MED_FULL_INTERLACE, NumberOfElements, @@ -755,14 +756,14 @@ template void MED_FIELD_WRONLY_DRIVER::write(void) const MED_FR::MED_REMP, // PROFIL NON GERE, mode de remplacement non géré (MED_FR::med_entite_maillage)mySupport->getEntity(), (MED_FR::med_geometrie_element)Types[i], - _ptrField->getIterationNumber(), + MED_FIELD_DRIVER::_ptrField->getIterationNumber(), " ", - _ptrField->getTime(), - _ptrField->getOrderNumber() + MED_FIELD_DRIVER::_ptrField->getTime(), + MED_FIELD_DRIVER::_ptrField->getOrderNumber() ); if (err < MED_VALID ) throw MEDEXCEPTION(LOCALIZED( STRING(LOC) - <<": Error in writing Field "<< _ptrField->getName() <<", type "<::_ptrField->getName() <<", type "< # include "MEDMEM_MedMedDriver.hxx" - +# include "MEDMEM_MedMeshDriver.hxx" # include "MEDMEM_DriversDef.hxx" # include "MEDMEM_Mesh.hxx" diff --git a/src/MEDMEM/MEDMEM_MedMeshDriver.cxx b/src/MEDMEM/MEDMEM_MedMeshDriver.cxx index 1aa73c0e3..6f09f5cd2 100644 --- a/src/MEDMEM/MEDMEM_MedMeshDriver.cxx +++ b/src/MEDMEM/MEDMEM_MedMeshDriver.cxx @@ -573,16 +573,20 @@ int MED_MESH_RDONLY_DRIVER::getCONNECTIVITY() // if neither nodal nor descending connectivity exists // throw an exception. err = getNodalConnectivity(Connectivity) ; - if (err!=MED_VALID) { - Connectivity->_typeConnectivity = MED_DESCENDING ; - err = getDescendingConnectivity(Connectivity) ; - } else + if (err!=MED_VALID) + { + Connectivity->_typeConnectivity = MED_DESCENDING ; + err = getDescendingConnectivity(Connectivity) ; + } + else getDescendingConnectivity(Connectivity) ; // we read it if there is one - if (err!=MED_VALID) { - delete Connectivity ; - throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read any Connectivity")) ; - } + if (err!=MED_VALID) + { + delete Connectivity ; + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "We could not read " << + "any Connectivity")) ; + } _ptrMesh->_meshDimension = Connectivity->_entityDimension ; @@ -596,72 +600,99 @@ int MED_MESH_RDONLY_DRIVER::getCONNECTIVITY() // PROVISOIRE : if we have some face or edge in MED_MAILLE, we don't read more. There could not be have face or edge !!!! - if(Connectivity->_constituent==NULL) { - - SCRUTE(_ptrMesh->_meshDimension); - if (_ptrMesh->_meshDimension == 3) { - MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." ); - CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ; - ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; // NODAL or DESCENDING - SCRUTE(ConnectivityFace->_typeConnectivity); - if (Connectivity->_typeConnectivity == MED_DESCENDING) { - MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" ); - err = getDescendingConnectivity(ConnectivityFace) ; - if (err!=MED_VALID) - throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No FACE in descending connectivity")) ; - getNodalConnectivity(ConnectivityFace) ; // if any ! - } else { - MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" ); - err = getNodalConnectivity(ConnectivityFace) ; - if (err!=MED_VALID) { // or error ????? we are in NODAL mode. - err = getDescendingConnectivity(ConnectivityFace) ; - } else - getDescendingConnectivity(ConnectivityFace); // if any ! - } - if (err!=MED_VALID) { - delete ConnectivityFace ; - MESSAGE(LOC<<"No FACE defined.") ; - } else { - MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES FACES DANS L'OBJET CONNECTIVITY" ); - Connectivity->_constituent=ConnectivityFace ; - } - } + if(Connectivity->_constituent==NULL) + { + SCRUTE(_ptrMesh->_meshDimension); + if (_ptrMesh->_meshDimension == 3) + { + MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES FACES..." ); + CONNECTIVITY * ConnectivityFace = new CONNECTIVITY(MED_EN::MED_FACE) ; + ConnectivityFace->_typeConnectivity = Connectivity->_typeConnectivity ; + // NODAL or DESCENDING + SCRUTE(ConnectivityFace->_typeConnectivity); + if (Connectivity->_typeConnectivity == MED_DESCENDING) + { + MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES FACES" ); + err = getDescendingConnectivity(ConnectivityFace) ; + if (err!=MED_VALID) + throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << + "No FACE in descending connectivity")) ; + getNodalConnectivity(ConnectivityFace) ; // if any ! + } + else + { + MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES FACES" ); + err = getNodalConnectivity(ConnectivityFace) ; + if (err!=MED_VALID) + { // or error ????? we are in NODAL mode. + err = getDescendingConnectivity(ConnectivityFace) ; + } + else + getDescendingConnectivity(ConnectivityFace); // if any ! + } + + if (err!=MED_VALID) + { + delete ConnectivityFace ; + MESSAGE(LOC<<"No FACE defined.") ; + } + else + { + MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " << + "FACES DANS L'OBJET CONNECTIVITY" ); + Connectivity->_constituent=ConnectivityFace ; + } + } - // read MED_EDGE connectivity - if (_ptrMesh->_meshDimension > 1) { // we are in 3 or 2D - MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." ); - CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ; - ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ; - if (Connectivity->_typeConnectivity == MED_DESCENDING) { - MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE DES ARRETES" ); - err = getDescendingConnectivity(ConnectivityEdge) ; - if (err!=MED_VALID) - throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << "No EDGE in descending connectivity")) ; - getNodalConnectivity(ConnectivityEdge) ; // if any ! - } else { - MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" ); - err = getNodalConnectivity(ConnectivityEdge) ; - if (err!=MED_VALID) { // or error ????? we are in NODAL mode. - err = getDescendingConnectivity(ConnectivityEdge) ; - } else - getDescendingConnectivity(ConnectivityEdge) ; // if any ! + // read MED_EDGE connectivity + if (_ptrMesh->_meshDimension > 1) + { // we are in 3 or 2D + MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DES ARRETES...." ); + CONNECTIVITY * ConnectivityEdge = new CONNECTIVITY(MED_EDGE) ; + ConnectivityEdge->_typeConnectivity = Connectivity->_typeConnectivity ; + if (Connectivity->_typeConnectivity == MED_DESCENDING) + { + MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE DESCENDANTE " << + "DES ARRETES" ); + err = getDescendingConnectivity(ConnectivityEdge) ; + if (err!=MED_VALID) + throw MEDEXCEPTION ( LOCALIZED(STRING(LOC) << + "No EDGE in descending connectivity")) ; + getNodalConnectivity(ConnectivityEdge) ; // if any ! + } + else + { + MESSAGE(LOC<<" ESSAI DE LECTURE DE LA CONNECTIVITE NODALE DES ARRETES" ); + err = getNodalConnectivity(ConnectivityEdge) ; + if (err!=MED_VALID) + { // or error ????? we are in NODAL mode. + err = getDescendingConnectivity(ConnectivityEdge) ; + } + else + getDescendingConnectivity(ConnectivityEdge) ; // if any ! + } + + if (err!=MED_VALID) + { + delete ConnectivityEdge ; + MESSAGE(LOC<<"No EDGE defined.") ; + } + else + { + if (_ptrMesh->_meshDimension == 3) + if (Connectivity->_constituent != NULL) + Connectivity->_constituent->_constituent=ConnectivityEdge ; + else + throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ; + else + { // IN 2D + MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES " << + "ARETES DANS L'OBJET CONNECTIVITY" ); + Connectivity->_constituent=ConnectivityEdge ; + } + } + } } - if (err!=MED_VALID) { - delete ConnectivityEdge ; - MESSAGE(LOC<<"No EDGE defined.") ; - } else { - if (_ptrMesh->_meshDimension == 3) - if (Connectivity->_constituent != NULL) - Connectivity->_constituent->_constituent=ConnectivityEdge ; - else - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<< "EDGE defined but there are no FACE !")) ; - else { // IN 2D - MESSAGE(LOC<<" SAUVEGARDE DE LA CONNECTIVITE DES ARETES DANS L'OBJET CONNECTIVITY" ); - Connectivity->_constituent=ConnectivityEdge ; - } - } - } - } _ptrMesh->_connectivity = Connectivity ; // all right ! @@ -691,6 +722,9 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) { const char * LOC = "MED_MESH_RDONLY_DRIVER::getNodalConnectivity : " ; BEGIN_OF(LOC); + + int spaceDimension = _ptrMesh->_spaceDimension; + if (_status==MED_OPENED) { // Get the type of entity to work on (previously set in the Connectivity Object) @@ -699,36 +733,40 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) // Get the number of cells of each type & store it in . int * tmp_cells_count = new int[MED_NBR_GEOMETRIE_MAILLE] ; int i; - for (i=1;i (_ptrMesh->_name.c_str())), - MED_FR::MED_CONN,(MED_FR::med_entite_maillage) Entity, - all_cell_type[i],MED_FR::MED_NOD); - - - // Get the greatest dimension of the cells : Connectivity->_entityDimension - // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!! - // In version prior to 2.2.x, it is possible - if (tmp_cells_count[i]>0) { - Connectivity->_entityDimension=all_cell_type[i]/100; - Connectivity->_numberOfTypes++; + for (i=1;i (_ptrMesh->_name.c_str())), + MED_FR::MED_CONN,(MED_FR::med_entite_maillage) Entity, + all_cell_type[i],MED_FR::MED_NOD); + + // Get the greatest dimension of the cells : Connectivity->_entityDimension + // We suppose there is no cells used as faces in MED 2.2.x , this is forbidden !!! + // In version prior to 2.2.x, it is possible + if (tmp_cells_count[i]>0) + { + Connectivity->_entityDimension=all_cell_type[i]/100; + Connectivity->_numberOfTypes++; + } } - } // If there is no nodal connectivity, we quit ! - if ( Connectivity->_numberOfTypes == 0 ) { - delete[] tmp_cells_count ; - return MED_ERROR ; - } + if ( Connectivity->_numberOfTypes == 0 ) + { + delete[] tmp_cells_count ; + return MED_ERROR ; + } // if MED version < 2.2.x, we read only entity with dimention = Connectivity->_entityDimension. Lesser dimension are face or edge ! char version_med[10] ; - if ( MEDfichEntete(_medIdt,MED_FR::MED_VERSION,version_med) != 0 ){ - // error : we suppose we have not a good med file ! - delete[] tmp_cells_count ; - return MED_ERROR ; - } + if ( MEDfichEntete(_medIdt,MED_FR::MED_VERSION,version_med) != 0 ) + { + // error : we suppose we have not a good med file ! + delete[] tmp_cells_count ; + return MED_ERROR ; + } // we get MED version number // If MED version is < 2.2 then the cells which dimension @@ -744,38 +782,76 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) tmpFaceCount[0] = 0 ; int numberOfFacesTypes = 0; - if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE)) { +// if ((version_med != "2.2")&(Entity==MED_FR::MED_MAILLE)) +// { +// Connectivity->_numberOfTypes=0; - Connectivity->_numberOfTypes=0; +// for ( i=1;i_entityDimension==dimension) +// Connectivity->_numberOfTypes++ ; + +// if (dimension == 2) +// if (Connectivity->_entityDimension==3) +// { +// tmpFaceCount[i]=tmp_cells_count[i] ; +// tmp_cells_count[i]=0 ; +// numberOfFacesTypes++; +// } +// if (dimension == 1) +// if (Connectivity->_entityDimension>dimension) +// { +// tmpEdgeCount[i]=tmp_cells_count[i] ; +// tmp_cells_count[i]=0; +// numberOfEdgesTypes++ ; +// } +// } +// } +// } + + if (Entity==MED_FR::MED_MAILLE) + { + Connectivity->_numberOfTypes=0; - for ( i=1;i_entityDimension==dimension) - Connectivity->_numberOfTypes++ ; + for ( i=1;i_entityDimension==dimension) + Connectivity->_numberOfTypes++ ; - if (dimension == 2) - if (Connectivity->_entityDimension==3) { - tmpFaceCount[i]=tmp_cells_count[i] ; - tmp_cells_count[i]=0 ; - numberOfFacesTypes++; - } - if (dimension == 1) - if (Connectivity->_entityDimension>dimension) { - tmpEdgeCount[i]=tmp_cells_count[i] ; - tmp_cells_count[i]=0; - numberOfEdgesTypes++ ; - } - } + if (dimension == 2) + if (Connectivity->_entityDimension==3) + { + tmpFaceCount[i]=tmp_cells_count[i] ; + //tmp_cells_count[i]=0 ; + //Connectivity->_numberOfTypes++ ; + numberOfFacesTypes++; + } + if (dimension == 1) + if (Connectivity->_entityDimension>dimension) + { + tmpEdgeCount[i]=tmp_cells_count[i] ; + //tmp_cells_count[i]=0; + //Connectivity->_numberOfTypes++ ; + numberOfEdgesTypes++ ; + } + } + } } - } // bloc to read CELL : { - // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY - // We use to calculate _count> then we release it + // Prepare an array of indexes on the different cell types to create a MEDSKYLINEARRAY + // We use to calculate _count> then we release it Connectivity->_geometricTypes = new MED_EN::medGeometryElement [Connectivity->_numberOfTypes] ; // Double emploi pour des raisons pratiques Connectivity->_type = new CELLMODEL [Connectivity->_numberOfTypes] ; // Connectivity->_count = new int [Connectivity->_numberOfTypes+1] ; @@ -784,27 +860,32 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) int size = 0 ; int typeNumber=1 ; int i; - for ( i=1;i0) { - Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i]; + for ( i=1;i0) && (Connectivity->_entityDimension == dimension)) + { + Connectivity->_count[typeNumber]=Connectivity->_count[typeNumber-1]+tmp_cells_count[i]; - CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ; - Connectivity->_type[typeNumber-1]=t ; + CELLMODEL t( (MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i]) ; + + Connectivity->_type[typeNumber-1] = t ; - Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ; + Connectivity->_geometricTypes[typeNumber-1]=( MED_EN::medGeometryElement) MED_MESH_DRIVER::all_cell_type[i] ; - // probleme avec les mailles de dimension < a dimension du maillage : - // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!! + // probleme avec les mailles de dimension < a dimension du maillage : + // Il faut oter le zero a la lecture est le remettre a l'ecriture : ce n'est pas fait !!!!! On interdit ce cas pour l'instant !!! - size+=tmp_cells_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ; + size+=tmp_cells_count[i]*((MED_MESH_DRIVER::all_cell_type[i])%100) ; - MESSAGE(LOC - << Connectivity->_count[typeNumber]-1 << " cells of type " - << all_cell_type_tab[i] ); - typeNumber++; + MESSAGE(LOC + << Connectivity->_count[typeNumber]-1 << " cells of type " + << all_cell_type_tab[i] ); + + typeNumber++; + } } - } // Creation of the MEDSKYLINEARRAY //Connectivity->_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1,size) ; @@ -815,79 +896,80 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) // Fill the MEDSKYLINEARRAY by reading the MED file. int j=0; - for ( i=0;i_numberOfTypes;i++) { - int multi = 0 ; - MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) Connectivity->_type[i].getType() ; -// if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension) - if (Connectivity->_entity == MED_CELL) - if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension) - multi=1; + for ( i=0;i_numberOfTypes;i++) + { + int multi = 0 ; + MED_FR::med_geometrie_element med_type = (MED_FR::med_geometrie_element) Connectivity->_type[i].getType() ; + //if ( Connectivity->_type[i].getDimension() < Connectivity->_entityDimension) + if (Connectivity->_entity == MED_CELL) + if ( Connectivity->_type[i].getDimension() < _ptrMesh->_spaceDimension) + multi=1; - // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ; - int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ; + // int NumberOfCell = Connectivity->_count[i+1]-Connectivity->_count[i] ; + int NumberOfNodeByCell = Connectivity->_type[i].getNumberOfNodes() ; - // initialise index - for ( j=Connectivity->_count[i]; j_count[i+1];j++) - NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ; + // initialise index + for ( j=Connectivity->_count[i]; j_count[i+1];j++) + NodalIndex[j]=NodalIndex[j-1]+NumberOfNodeByCell ; - int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ; - int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells]; + int tmp_numberOfCells = Connectivity->_count[i+1]-Connectivity->_count[i] ; + int * tmp_ConnectivityArray = new int[(NumberOfNodeByCell+multi)*tmp_numberOfCells]; -// int err=MEDconnLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), -// Connectivity->_entityDimension,tmp_ConnectivityArray, -// MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD); - int err=MEDconnLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), - _ptrMesh->_spaceDimension,tmp_ConnectivityArray, - MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD); - - if ( err != MED_VALID) { - delete[] tmp_ConnectivityArray; - delete[] tmp_cells_count; - delete[] tmpFaceCount; - delete[] tmpEdgeCount; - MESSAGE(LOC<<": MEDconnLire returns "< (_ptrMesh->_name.c_str()), + // Connectivity->_entityDimension,tmp_ConnectivityArray, + //MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type,MED_FR::MED_NOD); + + int err=MEDconnLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), + _ptrMesh->_spaceDimension,tmp_ConnectivityArray, + MED_FR::MED_FULL_INTERLACE,NULL,0,Entity,med_type, + MED_FR::MED_NOD); + + if ( err != MED_VALID) + { + delete[] tmp_ConnectivityArray; + delete[] tmp_cells_count; + delete[] tmpFaceCount; + delete[] tmpEdgeCount; + MESSAGE(LOC<<": MEDconnLire returns "<_count[i]-1]-1 ; + int * ConnectivityArray = NodalValue + NodalIndex[Connectivity->_count[i]-1]-1 ; - // version originale sans prise en compte des numéros optionnels - // - for ( j=0; j_arePresentOptionnalNodesNumbers==1) -// { -// for ( j=0; j_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ; -// } -// else -// { -// for ( j=0; j_arePresentOptionnalNodesNumbers==1) + // { + // for ( j=0; j_optionnalToCanonicNodesNumbers[tmp_ConnectivityArray[j*(NumberOfNodeByCell+multi)+k]] ; + // } + // else + // { + // for ( j=0; j_nodal = new MEDSKYLINEARRAY(Connectivity->_count[Connectivity->_numberOfTypes]-1, size, NodalIndex, NodalValue) ; + delete[] NodalIndex; delete[] NodalValue; - } // end of bloc to read CELL delete[] tmp_cells_count; @@ -959,6 +1041,7 @@ int MED_MESH_RDONLY_DRIVER::getNodalConnectivity(CONNECTIVITY * Connectivity) tmp_constituentArray = new int[NumberOfNodeByFace*tmp_numberOfFaces] ; MESSAGE(LOC<<": WE ARE USING MED2.2 so there is no +1 for calculating the size of tmp_constituentArray !") ; } + int err=MEDconnLire(_medIdt,const_cast (_ptrMesh->_name.c_str()), Connectivity->_entityDimension,tmp_constituentArray, MED_FR::MED_FULL_INTERLACE,NULL,0,MED_FR::MED_MAILLE,med_type,MED_FR::MED_NOD); @@ -1207,7 +1290,7 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() MESSAGE(LOC << "error returned from getNodesFamiliesNumber " << err); - MEDArrayCellFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ? + MEDArrayCellFamily = new int*[_ptrMesh->getNumberOfTypes(MED_CELL)] ; // ET SI IL N'Y A PAS DE CELLS ? const medGeometryElement * myTypes = _ptrMesh->getTypes(MED_CELL); for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_CELL);i++) MEDArrayCellFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_CELL,myTypes[i])] ; @@ -1219,7 +1302,7 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() if (_ptrMesh->_connectivity->_constituent != NULL) { if (_ptrMesh->_connectivity->_constituent->_entity == MED_EN::MED_FACE) { // FACE - MEDArrayFaceFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_FACE)] ; + MEDArrayFaceFamily = new int*[_ptrMesh->getNumberOfTypes(MED_FACE)] ; myTypes = _ptrMesh->getTypes(MED_FACE); for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_FACE);i++) MEDArrayFaceFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_FACE,myTypes[i])] ; @@ -1230,7 +1313,7 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() } else { // EDGE in 2D - MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ; + MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ; myTypes = _ptrMesh->getTypes(MED_EDGE); for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++) MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ; @@ -1241,7 +1324,7 @@ int MED_MESH_RDONLY_DRIVER::getFAMILY() } // EDGE in 3D if (_ptrMesh->_connectivity->_constituent->_constituent != NULL) { - MEDArrayEdgeFamily = new (int*)[_ptrMesh->getNumberOfTypes(MED_EDGE)] ; + MEDArrayEdgeFamily = new int*[_ptrMesh->getNumberOfTypes(MED_EDGE)] ; myTypes = _ptrMesh->getTypes(MED_EDGE); for (int i=0;i<_ptrMesh->getNumberOfTypes(MED_EDGE);i++) MEDArrayEdgeFamily[i] = new int[_ptrMesh->getNumberOfElements(MED_EDGE,myTypes[i])] ; @@ -1400,7 +1483,7 @@ int MED_MESH_RDONLY_DRIVER::getNodesFamiliesNumber(int * MEDArrayNodeFamily) err = MEDfamLire(_medIdt,(const_cast (_ptrMesh->_name.c_str())), MEDArrayNodeFamily, _ptrMesh->getNumberOfNodes(), - MED_FR::MED_NOEUD,(enum MED_FR::med_geometrie_element) MED_NONE); + MED_FR::MED_NOEUD,(MED_FR::med_geometrie_element) MED_NONE); if ( err != MED_VALID) { throw MEDEXCEPTION(LOCALIZED(STRING(LOC) << "There is no family for the |"<< _ptrMesh->getNumberOfNodes() << "| nodes in mesh |" @@ -2038,7 +2121,7 @@ int MED_MESH_WRONLY_DRIVER::writeFamilyNumbers() const { err = MEDfamEcr(_medIdt, const_cast ( _meshName.c_str() ), MEDArrayNodeFamily, NumberOfNodes,MED_FR::MED_REMP , MED_FR::MED_NOEUD, - (enum MED_FR::med_geometrie_element) MED_NONE); + (MED_FR::med_geometrie_element) MED_NONE); else err = MEDfamGridEcr(_medIdt, const_cast (_ptrMesh->_name.c_str()), diff --git a/src/MEDMEM/MEDMEM_Mesh.cxx b/src/MEDMEM/MEDMEM_Mesh.cxx index 435890dc9..2ba5a7b23 100644 --- a/src/MEDMEM/MEDMEM_Mesh.cxx +++ b/src/MEDMEM/MEDMEM_Mesh.cxx @@ -8,6 +8,7 @@ using namespace std; #include #include +#include #include "MEDMEM_DriversDef.hxx" #include "MEDMEM_Field.hxx" @@ -19,6 +20,9 @@ using namespace std; #include "MEDMEM_Coordinate.hxx" #include "MEDMEM_Connectivity.hxx" #include "MEDMEM_CellModel.hxx" + +#include "MEDMEM_DriverFactory.hxx" + using namespace MEDMEM; //#include "MEDMEM_Grid.hxx" this inclision should have never be here !!! @@ -27,20 +31,6 @@ using namespace MEDMEM; // ------- Drivers Management Part -// MESH::INSTANCE_DE MESH::inst_med_rdonly ; -//const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med_rdonly , &MESH::inst_med_rdwr } ; - -// Add a similar line for your personnal driver (step 3) - -MESH::INSTANCE_DE MESH::inst_med ; -MESH::INSTANCE_DE MESH::inst_gibi ; -MESH::INSTANCE_DE MESH::inst_porflow ; -MESH::INSTANCE_DE MESH::inst_vtk; - -// Add your own driver in the driver list (step 4) -// Note the list must be coherent with the driver type list defined in MEDMEM_DRIVER.hxx. -const MESH::INSTANCE * const MESH::instances[] = { &MESH::inst_med, &MESH::inst_gibi, &MESH::inst_porflow, &MESH::inst_vtk } ; - /*! Add a %MESH driver of type %driverTypes (MED_DRIVER, ....) associated with file fileName. The meshname used in the file is driverName. addDriver returns an integer handler. */ int MESH::addDriver(driverTypes driverType, @@ -49,50 +39,16 @@ int MESH::addDriver(driverTypes driverType, const char * LOC = "MESH::addDriver(driverTypes driverType, const string & fileName=\"Default File Name.med\",const string & driverName=\"Default Mesh Name\") : "; GENDRIVER * driver; - int current; - int itDriver = (int) NO_DRIVER; BEGIN_OF(LOC); SCRUTE(driverType); - SCRUTE(instances[driverType]); - - switch(driverType) - { - case MED_DRIVER : { - itDriver = (int) driverType ; - break ; - } - - case GIBI_DRIVER : { - itDriver = (int) driverType ; - break ; - } - - case PORFLOW_DRIVER : { - itDriver = (int) driverType ; - break ; - } - - case VTK_DRIVER : { - itDriver = 3 ; - break ; - } - - case NO_DRIVER : { - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "NO_DRIVER has been specified to the method which is not allowed")); - } - } - - if (itDriver == ((int) NO_DRIVER)) - throw MED_EXCEPTION (LOCALIZED(STRING(LOC)<< "othe driver than MED_DRIVER GIBI_DRIVER PORFLOW_DRIVER and VT_DRIVER has been specified to the method which is not allowed")); - - driver = instances[itDriver]->run(fileName, this) ; + driver = DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName) ; _drivers.push_back(driver); - current = _drivers.size()-1; + int current = _drivers.size()-1; _drivers[current]->setMeshName(driverName); @@ -338,44 +294,9 @@ MESH::MESH(driverTypes driverType, const string & fileName/*=""*/, const string BEGIN_OF(LOC); init(); - - switch(driverType) - { - case MED_DRIVER : - { - MED_MESH_RDONLY_DRIVER myDriver(fileName,this); - myDriver.setMeshName(driverName); - current = addDriver(myDriver); - break; - } - case GIBI_DRIVER : - { - GIBI_MESH_RDONLY_DRIVER myDriver(fileName,this); - current = addDriver(myDriver); - break; - } - case PORFLOW_DRIVER : - { - PORFLOW_MESH_RDONLY_DRIVER myDriver(fileName,this); - current = addDriver(myDriver); - break; - } - default : - { - throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Driver type unknown : can't create driver!")); - break; - } - } - -// current = addDriver(driverType,fileName,driverName); -// switch(_drivers[current]->getAccessMode() ) { -// case MED_WRONLY : { -// MESSAGE("MESH::MESH(driverTypes driverType, .....) : driverType must not be a MED_WRONLY accessMode"); -// rmDriver(current); -// break;} -// default : { -// } -// } + GENDRIVER *myDriver=DRIVERFACTORY::buildDriverForMesh(driverType,fileName,this,driverName); + current = addDriver(*myDriver); + delete myDriver; _drivers[current]->open(); _drivers[current]->read(); _drivers[current]->close(); diff --git a/src/MEDMEM/MEDMEM_Mesh.hxx b/src/MEDMEM/MEDMEM_Mesh.hxx index d4a4e2deb..2b9d6a0f7 100644 --- a/src/MEDMEM/MEDMEM_Mesh.hxx +++ b/src/MEDMEM/MEDMEM_Mesh.hxx @@ -13,20 +13,7 @@ //#include "MEDMEM_Support.hxx" #include "MEDMEM_Coordinate.hxx" #include "MEDMEM_Connectivity.hxx" - -// Add your own driver header (step 2) -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedMedDriver.hxx" -#include "MEDMEM_GibiMeshDriver.hxx" -#include "MEDMEM_PorflowMeshDriver.hxx" - -#include "MEDMEM_VtkMeshDriver.hxx" - - - -//class GENDRIVER; -//class MED_MESH_RDONLY_DRIVER; -//class MED_MESH_WRONLY_DRIVER; +#include "MEDMEM_GenDriver.hxx" using namespace MED_EN; @@ -54,43 +41,6 @@ class SUPPORT; class MESH { - - -public : - - // ------- Drivers Management Part -protected: - - //-----------------------// - class INSTANCE - //-----------------------// - { - public: - virtual GENDRIVER * run(const string & fileName, MESH * ptrMesh) const = 0; - }; - - //-------------------------------------------------------// - template class INSTANCE_DE : public INSTANCE - //-------------------------------------------------------// - { - public : - GENDRIVER * run(const string & fileName, MESH * ptrMesh) const - { return new T(fileName,ptrMesh); } - }; - - // Add a similar line for your personnal driver (step 3) - - static INSTANCE_DE inst_med; - static INSTANCE_DE inst_gibi; - static INSTANCE_DE inst_porflow; - static INSTANCE_DE inst_vtk; - - //static INSTANCE_DE inst_vtk ; - static const INSTANCE * const instances[]; - - // ------ End of Drivers Management Part - - //-----------------------// // Attributes //-----------------------// @@ -181,9 +131,9 @@ public : void rmDriver(int index=0); virtual void read(int index=0); - inline void read(const MED_MED_DRIVER & genDriver); + inline void read(const GENDRIVER & genDriver); inline void write(int index=0, const string & driverName = ""); - inline void write(const MED_MED_DRIVER & genDriver); + inline void write(const GENDRIVER & genDriver); // void calculateReverseConnectivity(); // void createFaces(); //Faces creation => full constituent informations @@ -220,6 +170,10 @@ public : virtual inline void calculateConnectivity(medModeSwitch Mode, medConnectivity ConnectivityType, medEntityMesh Entity) const ; + virtual inline int getConnectivityLength(medModeSwitch Mode, + medConnectivity ConnectivityType, + medEntityMesh Entity, + medGeometryElement Type) const; virtual inline const int * getConnectivity(medModeSwitch Mode, medConnectivity ConnectivityType, medEntityMesh Entity, @@ -230,9 +184,12 @@ public : medEntityMesh Entity, medGeometryElement Type, int * connectivity) const; - + virtual inline int getReverseConnectivityLength(medConnectivity ConnectivityType, + medEntityMesh Entity=MED_CELL) const; virtual inline const int * getReverseConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity=MED_CELL) const; + virtual inline int getReverseConnectivityIndexLength(medConnectivity ConnectivityType, + medEntityMesh Entity=MED_CELL) const; virtual inline const int * getReverseConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity=MED_CELL) const; @@ -346,7 +303,7 @@ inline void MESH::write(int index/*=0*/, const string & driverName/* = ""*/) // This method is MED specific : don't use it // must be private. -inline void MESH::write(const MED_MED_DRIVER & genDriver) +inline void MESH::write(const GENDRIVER & genDriver) { const char * LOC = "MESH::write(const MED_MED_DRIVER & genDriver): "; BEGIN_OF(LOC); @@ -365,7 +322,7 @@ inline void MESH::write(const MED_MED_DRIVER & genDriver) // This method is MED specific : don't use it // must be private. -inline void MESH::read(const MED_MED_DRIVER & genDriver) +inline void MESH::read(const GENDRIVER & genDriver) { const char * LOC = "MESH::read(const MED_MED_DRIVER & genDriver): "; BEGIN_OF(LOC); @@ -600,6 +557,25 @@ inline void MESH::calculateConnectivity(medModeSwitch Mode,medConnectivity Conne else throw MEDEXCEPTION(LOCALIZED("MESH::calculateConnectivity : only for MED_FULL_INTERLACE mode")); } +/*! + Return the corresponding length of the array returned by MESH::getConnectivity with exactly the same arguments. + Used particulary for wrapping CORBA and python. + */ +inline int MESH::getConnectivityLength(medModeSwitch Mode,medConnectivity ConnectivityType,medEntityMesh entity, medGeometryElement Type) const +{ + int nbOfElm = getNumberOfElements(entity,Type); + int size; + + if (Type == MED_ALL_ELEMENTS) + { + size = getConnectivityIndex(ConnectivityType,entity)[nbOfElm]-1; + } + else + { + size = nbOfElm*(((int) Type)%100); + } + return size; +} /*! Return the required connectivity in the right mode for the given geometric type of the given entity. @@ -631,6 +607,32 @@ inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,m // checkGridFillConnectivity(); return _connectivity->getConnectivityIndex(ConnectivityType, entity); } +/*! + Return the corresponding length of the array returned by MESH::getReverseConnectivity with exactly the same arguments. + Used particulary for wrapping CORBA and python. + */ + +inline int MESH::getReverseConnectivityLength(medConnectivity ConnectivityType, + medEntityMesh Entity) const +{ + int spaceDim = getSpaceDimension(); + int nb; + + if (ConnectivityType == MED_NODAL) + { + nb = getNumberOfNodes(); + } + else + { + if (spaceDim == 2) + nb = getNumberOfElements(MED_EDGE, + MED_ALL_ELEMENTS); + else if (spaceDim == 3) + nb = getNumberOfElements(MED_FACE, + MED_ALL_ELEMENTS); + } + return getReverseConnectivityIndex(ConnectivityType)[nb]-1; +} /*! Return the reverse connectivity required by ConnectivityType : - If ConnectivityType=MED_NODAL : return connectivity node-cell @@ -638,6 +640,7 @@ inline const int * MESH::getConnectivityIndex(medConnectivity ConnectivityType,m You must get ReverseConnectivityIndex array to use it. */ + inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity/*=MED_CELL*/) const { // checkGridFillConnectivity(); @@ -646,6 +649,29 @@ inline const int * MESH::getReverseConnectivity(medConnectivity ConnectivityType return _connectivity->getReverseConnectivity(ConnectivityType,Entity); } +/*! + Return the corresponding length of the array returned by MESH::getReverseConnectivityIndex with exactly the same arguments. + Used particulary for wrapping CORBA and python. + */ +inline int MESH::getReverseConnectivityIndexLength(medConnectivity ConnectivityType, + medEntityMesh Entity) const +{ + int spaceDim = getSpaceDimension(); + + if (ConnectivityType == MED_NODAL) + { + return getNumberOfNodes()+1; + } + else + { + if (spaceDim == 2) + return getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS)+1; + else if (spaceDim == 3) + return getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)+1; + else + throw MEDEXCEPTION("Invalid dimension"); + } +} /*! Return the index array required by ConnectivityType. diff --git a/src/MEDMEM/MEDMEM_PointerOf.hxx b/src/MEDMEM/MEDMEM_PointerOf.hxx index be3201043..96f3684f4 100644 --- a/src/MEDMEM/MEDMEM_PointerOf.hxx +++ b/src/MEDMEM/MEDMEM_PointerOf.hxx @@ -36,6 +36,7 @@ public : void set( const int &size ) ; void set( const T *pointer ) ; void set( const int &size, const T *pointer ) ; + void setShallowAndOwnership( const T *pointer ); PointerOf& operator=( const PointerOf &pointer ) ; } ; } ; @@ -76,7 +77,7 @@ template PointerOf::PointerOf( const int &size, const PointerOf< } /*! If size <= 0, creates a null "T*" pointer\n - Else allocates memory and sets desallocation boolean to true./n + Else allocates memory and sets desallocation boolean to true.\n Memory will be desallocated when erasing this PointerOf*/ template PointerOf::PointerOf( const int &size ) { @@ -92,15 +93,15 @@ template PointerOf::PointerOf( const int &size ) } } -/*! Creates a standard pointer to the memory zone pointed by T*. /n - T* owner is in charged of memory desallocation. /n +/*! Creates a standard pointer to the memory zone pointed by T*. \n + T* owner is in charged of memory desallocation. \n Memory will not be released when erasing this PointerOf*/ template PointerOf::PointerOf( const T* pointer ) : _pointer( (T*)pointer ), _done(false) { } /*! If size <= 0, return an exception\n - Else duplicate array and sets desallocation boolean to true./n + Else duplicate array and sets desallocation boolean to true.\n Memory will be desallocated when erasing this PointerOf*/ template PointerOf::PointerOf( const int &size, const T* pointer) { @@ -164,9 +165,9 @@ template PointerOf::operator const T*() const } -/*! If necessary, released memory holded by PointerOf/n. - Else allocates memory and sets desallocation boolean to true./n - Can be used in order to "nullify" an existing PointerOf/n +/*! If necessary, released memory holded by PointerOf\n. + Else allocates memory and sets desallocation boolean to true.\n + Can be used in order to "nullify" an existing PointerOf\n Memory will be desallocated when erasing this PointerOf*/ template void PointerOf::set( const int &size ) { @@ -187,9 +188,9 @@ template void PointerOf::set( const int &size ) return ; } -/*! If necessary, released memory holded by PointerOf/n. - Then, sets _pointer to the memory zone pointed by T*. /n - T* owner is in charged of memory desallocation. /n +/*! If necessary, released memory holded by PointerOf\n. + Then, sets _pointer to the memory zone pointed by T*. \n + T* owner is in charged of memory desallocation. \n memory will not be released when erasing this PointerOf*/ template void PointerOf::set( const T *pointer ) { @@ -209,10 +210,10 @@ template void PointerOf::set( const T *pointer ) return ; } -/*! If necessary, released memory holded by PointerOf/n. +/*! If necessary, released memory holded by PointerOf\n. If size <= 0, return an exception\n. - Else allocates memory and sets desallocation boolean to true./n - Can be used in order to "nullify" an existing PointerOf/n + Else allocates memory and sets desallocation boolean to true.\n + Can be used in order to "nullify" an existing PointerOf\n Memory will be desallocated when erasing this PointerOf*/ template void PointerOf::set( const int &size, const T *pointer) { @@ -231,4 +232,12 @@ template void PointerOf::set( const int &size, const T *pointer) return ; } +template void PointerOf::setShallowAndOwnership( const T *pointer ) +{ + if ( _pointer && _done ) + delete [] _pointer; + _pointer=(T*)pointer; + _done=true; +} + # endif /* # if ! defined( __PointerOf_HXX__ ) */ diff --git a/src/MEDMEM/MEDMEM_SkyLineArray.cxx b/src/MEDMEM/MEDMEM_SkyLineArray.cxx index 00cf6fac4..27688e1d1 100644 --- a/src/MEDMEM/MEDMEM_SkyLineArray.cxx +++ b/src/MEDMEM/MEDMEM_SkyLineArray.cxx @@ -35,13 +35,20 @@ MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length): } MEDSKYLINEARRAY::MEDSKYLINEARRAY(const med_int count, const med_int length, - const med_int* index, const med_int* value): - _count(count), _length(length), - _index(_count+1),_value(_length) + const med_int* index, const med_int* value,bool shallowCopy): + _count(count), _length(length) { MESSAGE("Constructeur MEDSKYLINEARRAY(count="< +#include +#include #include "MEDMEM_define.hxx" @@ -569,54 +571,38 @@ template void VTK_FIELD_DRIVER::write(void) const switch (fieldType) { - case MED_INT32 : { - MESSAGE("MED_INT32"); - if (NomberOfComponents==3) - (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ; - else if (NomberOfComponents<=4) - { - (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ; - (*_vtkFile) << "LOOKUP_TABLE default" << endl ; - } - else - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !")); - - //const int * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; - const int * value = ((FIELD*)_ptrField)->getValue(MED_NO_INTERLACE) ; - for (int i=0; igetName()<<" there are more than 4 components !")); - - const double * value = ((FIELD*)_ptrField)->getValue(MED_NO_INTERLACE) ; - for (int i=0; igetName()<<" there are more than 4 components !")); + + const T * value = _ptrField->getValue(MED_NO_INTERLACE) ; + for (int i=0; i void VTK_FIELD_DRIVER::writeAppend(void) const SCRUTE(name.str()); SCRUTE(fieldType); - switch (fieldType) { - case MED_INT32 : { - MESSAGE("MED_INT32"); - if (NomberOfComponents==3) - (*_vtkFile) << "VECTORS " << name.str() << " int" << endl ; - else if (NomberOfComponents<=4) - { - (*_vtkFile) << "SCALARS " << name.str() << " int " << NomberOfComponents << endl ; - (*_vtkFile) << "LOOKUP_TABLE default" << endl ; - } - else - throw MED_EXCEPTION(LOCALIZED(STRING(LOC) << "Could not write field "<<_ptrField->getName()<<" there are more than 4 components !")); - - //const int * value = ((FIELD*)myField)->getValue(MED_NO_INTERLACE) ; - const int * value = ((FIELD*)_ptrField)->getValue(MED_NO_INTERLACE) ; - for (int i=0; igetName()<<" there are more than 4 components !")); - - const double * value = ((FIELD*)_ptrField)->getValue(MED_NO_INTERLACE) ; - for (int i=0; igetName()<<" there are more than 4 components !")); + const T * value = _ptrField->getValue(MED_NO_INTERLACE) ; + + for (int i=0; i() +FIELDDOUBLE_i::FIELDDOUBLE_i(): FIELD_i() { BEGIN_OF("Default Constructor FIELDDOUBLE_i"); END_OF("Default Constructor FIELDDOUBLE_i"); @@ -37,7 +39,7 @@ FIELDDOUBLE_i::~FIELDDOUBLE_i() */ //============================================================================= FIELDDOUBLE_i::FIELDDOUBLE_i(FIELDDOUBLE_i & fd): - FIELDOF_i(fd._fieldTptr) + FIELD_i(fd) { BEGIN_OF("Default Constructor FIELDDOUBLE_i"); END_OF("Default Constructor FIELDDOUBLE_i"); @@ -47,7 +49,8 @@ FIELDDOUBLE_i::FIELDDOUBLE_i(FIELDDOUBLE_i & fd): * Default constructor */ //============================================================================= -FIELDDOUBLE_i::FIELDDOUBLE_i(SALOME_MED::SUPPORT_ptr mySupportIOR,::FIELD * const f): FIELDOF_i(mySupportIOR,f) +FIELDDOUBLE_i::FIELDDOUBLE_i(::FIELD * const f, bool ownCppPtr): + FIELD_i(f,ownCppPtr) { BEGIN_OF("Constructor FIELDDOUBLE_i"); END_OF(" Constructor FIELDDOUBLE_i"); @@ -68,25 +71,12 @@ throw (SALOME::SALOME_Exception) SALOME_MED::double_array_var myseq = new SALOME_MED::double_array; try { - int nbval=_fieldTptr->getNumberOfComponents(); - - // Ajout NB pour avoir la valeur correct de nbval - SALOME_MED::medEntityMesh entity = _support->getEntity(); - if (_support->isOnAllElements()) - { - if (entity == SALOME_MED::MED_NODE) - nbval = (_support->getMesh()->getNumberOfNodes())*nbval; - else - nbval = (_support->getMesh()->getNumberOfElements(entity,SALOME_MED::MED_ALL_ELEMENTS))*nbval; - } - else - { - nbval = (_support->getNumberOfElements(SALOME_MED::MED_ALL_ELEMENTS))*nbval; - } - medModeSwitch modemed=convertIdlModeToMedMode(mode); - const double * values =_fieldTptr->getValue(modemed); - +// ::FIELD *ptrD=dynamic_cast< ::FIELD* >(_fieldTptr); +// the alternative is not safe but the previous fails using the python API + MEDMEM::FIELD *ptrD = (MEDMEM::FIELD *) _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); + 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 index d103ad445..746e5f950 100644 --- a/src/MEDMEM_I/MEDMEM_FieldDouble_i.hxx +++ b/src/MEDMEM_I/MEDMEM_FieldDouble_i.hxx @@ -14,23 +14,26 @@ #include CORBA_SERVER_HEADER(MED) #include "MEDMEM_Field_i.hxx" -#include "MEDMEM_FieldOf_i.hxx" #include "MEDMEM_Field.hxx" namespace MEDMEM { -class FIELDDOUBLE_i: public FIELDOF_i + class FIELDDOUBLE_i: public POA_SALOME_MED::FIELDDOUBLE, + public FIELD_i, + public SALOMEMultiComm { private: public: FIELDDOUBLE_i(); ~FIELDDOUBLE_i(); - FIELDDOUBLE_i(SALOME_MED::SUPPORT_ptr mySupportIOR,::FIELD * const f); + FIELDDOUBLE_i(::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::Sender_ptr getSenderForValue(SALOME_MED::medModeSwitch mode) + throw (SALOME::SALOME_Exception); }; } diff --git a/src/MEDMEM_I/MEDMEM_FieldInt_i.cxx b/src/MEDMEM_I/MEDMEM_FieldInt_i.cxx index f3d40e209..c08c37fbb 100644 --- a/src/MEDMEM_I/MEDMEM_FieldInt_i.cxx +++ b/src/MEDMEM_I/MEDMEM_FieldInt_i.cxx @@ -9,6 +9,8 @@ #include "utilities.h" #include "MEDMEM_FieldInt_i.hxx" #include "MEDMEM_convert.hxx" +#include "SenderFactory.hxx" +#include "MultiCommException.hxx" using namespace MEDMEM; //============================================================================= @@ -16,7 +18,7 @@ using namespace MEDMEM; * Default constructor */ //============================================================================= -FIELDINT_i::FIELDINT_i(): FIELDOF_i() +FIELDINT_i::FIELDINT_i(): FIELD_i() { BEGIN_OF("Default Constructor FIELDINT_i"); END_OF("Default Constructor FIELDINT_i"); @@ -36,7 +38,8 @@ FIELDINT_i::~FIELDINT_i() * Default constructor */ //============================================================================= -FIELDINT_i::FIELDINT_i(SALOME_MED::SUPPORT_ptr mySupportIOR, ::FIELD * const f): FIELDOF_i(mySupportIOR,f) +FIELDINT_i::FIELDINT_i(::FIELD * const f, bool ownCppPtr): + FIELD_i(f,ownCppPtr) { BEGIN_OF("Constructor FIELDINT_i"); END_OF(" Constructor FIELDINT_i"); @@ -46,8 +49,7 @@ FIELDINT_i::FIELDINT_i(SALOME_MED::SUPPORT_ptr mySupportIOR, ::FIELD * cons * Constructor par recopie */ //============================================================================= -FIELDINT_i::FIELDINT_i(FIELDINT_i &fi): - FIELDOF_i(fi._fieldTptr) +FIELDINT_i::FIELDINT_i(FIELDINT_i &fi):FIELD_i(fi) { BEGIN_OF("Constructor FIELDINT_i"); END_OF(" Constructor FIELDINT_i"); @@ -67,27 +69,15 @@ throw (SALOME::SALOME_Exception) SALOME::INTERNAL_ERROR); SALOME_MED::long_array_var myseq = new SALOME_MED::long_array; try - { - int nbval=_fieldTptr->getNumberOfComponents(); - - // Ajout NB pour avoir la valeur correct de nbval - SALOME_MED::medEntityMesh entity = _support->getEntity(); - if (_support->isOnAllElements()) - { - if (entity == SALOME_MED::MED_NODE) - nbval = (_support->getMesh()->getNumberOfNodes())*nbval; - else - nbval = (_support->getMesh()->getNumberOfElements(entity,SALOME_MED::MED_ALL_ELEMENTS))*nbval; - } - else - { - nbval = (_support->getNumberOfElements(SALOME_MED::MED_ALL_ELEMENTS))*nbval; - } - - medModeSwitch modemed=convertIdlModeToMedMode(mode); - const int * values =_fieldTptr->getValue(modemed); + { + 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 = (MEDMEM::FIELD *) _fieldTptr; - myseq->length(nbval); + const int * values =ptrI->getValue(modemed); + int nbval=ptrI->getValueLength(modemed); + myseq->length(nbval); for (int i=0; i *ptrI=dynamic_cast< ::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 index c72aa27fa..c831d26c7 100644 --- a/src/MEDMEM_I/MEDMEM_FieldInt_i.hxx +++ b/src/MEDMEM_I/MEDMEM_FieldInt_i.hxx @@ -14,22 +14,25 @@ #include CORBA_SERVER_HEADER(MED) #include "MEDMEM_Field_i.hxx" -#include "MEDMEM_FieldOf_i.hxx" #include "MEDMEM_Field.hxx" namespace MEDMEM { -class FIELDINT_i: public FIELDOF_i + class FIELDINT_i: public POA_SALOME_MED::FIELDINT, + public FIELD_i, + public SALOMEMultiComm { private: FIELDINT_i(); public: ~FIELDINT_i(); - FIELDINT_i(SALOME_MED::SUPPORT_ptr mySupportIOR, ::FIELD * const f); + FIELDINT_i(::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::Sender_ptr getSenderForValue(SALOME_MED::medModeSwitch mode) + throw (SALOME::SALOME_Exception); }; } #endif /* MED_FIELDINT_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_FieldOf_i.hxx b/src/MEDMEM_I/MEDMEM_FieldOf_i.hxx deleted file mode 100644 index e53095e87..000000000 --- a/src/MEDMEM_I/MEDMEM_FieldOf_i.hxx +++ /dev/null @@ -1,691 +0,0 @@ -//============================================================================= -// File : MEDMEM_FieldOf_i.hxx -// Project : SALOME -// Author : EDF -// Copyright : EDF 2002 -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_FieldOf_i.hxx -//============================================================================= - - -#ifndef MED_FIELDOF_I_HXX_ -#define MED_FIELDOF_I_HXX_ - -#include -#include -# include - -#include - -# include "Utils_ORB_INIT.hxx" -# include "Utils_SINGLETON.hxx" - -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOMEDS) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - -#include "MEDMEM_Field_i.hxx" -#include "MEDMEM_Support_i.hxx" - -#include "MEDMEM_convert.hxx" - -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" - -namespace MEDMEM { -template class FIELDOF_i: public FIELD_i -{ -public : - static map < int, ::MEDMEM::FIELD * > fieldMap ; -protected : - static int fieldIndex ; - -protected : - // C++ object containing values - - ::MEDMEM::FIELD * const _fieldTptr; - const int _corbaIndex; - string _FieldId; - - // CORBA : SUPPORT IOR - const SALOME_MED::SUPPORT_ptr _support ; - - -public : - // Constructors and associated internal methods - FIELDOF_i(); - FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD * const field); - FIELDOF_i(::FIELD * const f); - FIELDOF_i(FIELDOF_i & f); - ~FIELDOF_i(); - - char * getName() throw (SALOME::SALOME_Exception); - char * getDescription() throw (SALOME::SALOME_Exception); - SALOME_MED::SUPPORT_ptr getSupport() throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfComponents() - throw (SALOME::SALOME_Exception); - char * getComponentName(CORBA::Long i) - throw (SALOME::SALOME_Exception); - char * getComponentUnit(CORBA::Long i) - throw (SALOME::SALOME_Exception); - CORBA::Long getIterationNumber() - throw (SALOME::SALOME_Exception); - CORBA::Long getOrderNumber() throw (SALOME::SALOME_Exception); - CORBA::Double getTime() throw (SALOME::SALOME_Exception); - CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception); - - SALOME_MED::string_array * getComponentsNames() throw (SALOME::SALOME_Exception); - SALOME_MED::string_array * getComponentsUnits() throw (SALOME::SALOME_Exception); - void addInStudy(SALOMEDS::Study_ptr myStudy, - SALOME_MED::FIELD_ptr myIor) - throw (SALOME::SALOME_Exception, - SALOMEDS::StudyBuilder::LockProtection); - - CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType, - const char* fileName, const char* fieldName) - throw (SALOME::SALOME_Exception); - void rmDriver (CORBA::Long i) throw (SALOME::SALOME_Exception); - void read (CORBA::Long i) throw (SALOME::SALOME_Exception); - void write (CORBA::Long i, const char* driverFieldName) - throw (SALOME::SALOME_Exception); - - // Cuisine Interne - ::FIELD * constructConstField() const; - - }; -} -using namespace MEDMEM; -template map < int, ::FIELD * > FIELDOF_i::fieldMap ; -template int FIELDOF_i::fieldIndex = 0; -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= - -//template FIELDOF_i::FIELDOF_i():_fieldTptr(FIELDOF_i::constructConstField()) -template FIELDOF_i::FIELDOF_i():_fieldTptr(constructConstField()), - _support((SALOME_MED::SUPPORT_ptr) NULL) -{ - BEGIN_OF("Default Constructor Field_i"); - END_OF(" Default Constructor Field_i"); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -template FIELDOF_i::~FIELDOF_i() -{ -} -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -template FIELDOF_i::FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD * const field): - _fieldTptr(field), - _corbaIndex(FIELDOF_i::fieldIndex++), - _FieldId(""), - _support(SALOME_MED::SUPPORT::_duplicate(support)) -{ - BEGIN_OF("Constructor FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD * const field)"); - FIELDOF_i::fieldMap[_corbaIndex]=_fieldTptr; - - MESSAGE("FIELDOF_i::FIELDOF_i Checking of pointeurs !!!"); - - SCRUTE(_fieldTptr); - SCRUTE(_support); - SCRUTE(_support->getMesh()); - - END_OF("Constructor FIELDOF_i(SALOME_MED::SUPPORT_ptr support,::FIELD * const field)"); -} - - -template FIELDOF_i::FIELDOF_i( FIELD * const f): - _fieldTptr(f), - _corbaIndex(FIELDOF_i::fieldIndex++), - _FieldId(""), - _support((SALOME_MED::SUPPORT_ptr) NULL) -{ - BEGIN_OF("Constructor Field_i"); - FIELDOF_i::fieldMap[_corbaIndex]=_fieldTptr; - END_OF("Constructor Field_i"); -} -//============================================================================= -/*! - * Constructor par recopie - */ -//============================================================================= -template FIELDOF_i::FIELDOF_i( FIELDOF_i & f):_fieldTptr(f._fieldTptr), - _corbaIndex(FIELDOF_i::fieldIndex++), - _FieldId("") -{ - BEGIN_OF("Constructor Field_i"); - FIELDOF_i::fieldMap[_corbaIndex]=_fieldTptr; - END_OF("Constructor Field_i"); -} -//============================================================================= -/*! - * Constructor d un pointeur constant - */ -//============================================================================= -template ::FIELD * FIELDOF_i::constructConstField() const -{ - ::FIELD * const ptrField =new ::FIELD(); - return ptrField; -} -//============================================================================= -/*! - * CORBA: Accessor for Fields's Name - */ -//============================================================================= -template char * FIELDOF_i::getName() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return CORBA::string_dup(_fieldTptr->getName().c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au nom"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for Fields's Description - */ -//============================================================================= -template char * FIELDOF_i::getDescription() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return CORBA::string_dup(_fieldTptr->getDescription().c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant a la description"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for Fields's Support - */ -//============================================================================= - -template SALOME_MED::SUPPORT_ptr FIELDOF_i::getSupport() - throw (SALOME::SALOME_Exception) -{ - BEGIN_OF("SALOME_MED::SUPPORT_ptr FIELDOF_i::getSupport()"); - - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", - SALOME::INTERNAL_ERROR); - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No Support in Field", - SALOME::INTERNAL_ERROR); - - SCRUTE(_fieldTptr); - - SCRUTE(_support); - - SALOME_MED::SUPPORT_ptr support = SALOME_MED::SUPPORT::_duplicate(_support); - - END_OF("SALOME_MED::SUPPORT_ptr FIELDOF_i::getSupport()"); - - return support ; -} -//============================================================================= -/*! - * CORBA: Accessor for Fields's Number of components - */ -//============================================================================= -template CORBA::Long FIELDOF_i::getNumberOfComponents() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return _fieldTptr->getNumberOfComponents(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au support"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for names of component I - */ -//============================================================================= -template char * FIELDOF_i::getComponentName(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return CORBA::string_dup(_fieldTptr->getComponentName(i).c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au nom d un component"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for unit of component I - */ -//============================================================================= -template char * FIELDOF_i::getComponentUnit(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return CORBA::string_dup(_fieldTptr->getMEDComponentUnit(i).c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au nom d un component"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for iteration number - */ -//============================================================================= -template CORBA::Long FIELDOF_i::getIterationNumber() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return _fieldTptr->getIterationNumber(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for Corba Number - */ -//============================================================================= -template CORBA::Long FIELDOF_i::getCorbaIndex() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - return _corbaIndex; - -} -//============================================================================= -/*! - * CORBA: Accessor for iteration number - */ -//============================================================================= -template CORBA::Long FIELDOF_i::getOrderNumber() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return _fieldTptr->getOrderNumber(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor - */ -//============================================================================= -template CORBA::Double FIELDOF_i::getTime() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return _fieldTptr->getTime(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for Fields's Components names - */ -//============================================================================= -template SALOME_MED::string_array * FIELDOF_i::getComponentsNames() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::string_array_var myseq = new SALOME_MED::string_array; - try - { - int nbcom = _fieldTptr->getNumberOfComponents(); - myseq->length(nbcom); - const string * namecom=_fieldTptr->getComponentsNames(); - for (int i=0;i SALOME_MED::string_array * FIELDOF_i::getComponentsUnits() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::string_array_var myseq = new SALOME_MED::string_array; - try - { - int nbcom = _fieldTptr->getNumberOfComponents(); - myseq->length(nbcom); - const string * unitcom=_fieldTptr->getMEDComponentsUnits(); - for (int i=0;i void FIELDOF_i::addInStudy(SALOMEDS::Study_ptr myStudy, - SALOME_MED::FIELD_ptr myIor ) - throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection) -{ - BEGIN_OF(" FIELDOF_i::addInStudy"); - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - if ( _FieldId != "" ) - { - MESSAGE("Field already in Study"); - THROW_SALOME_CORBA_EXCEPTION("Field already in Study", \ - SALOME::BAD_PARAM); - }; - - - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var aIOR; - - // Create SComponent labelled 'Med' - SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); - if ( CORBA::is_nil(medfather) ) - THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'MED' not Found",SALOME::INTERNAL_ERROR); - - // Create SObject labelled 'MEDFIELD' if it doesn't already exit - SALOMEDS::SObject_var medfieldfather = myStudy->FindObject("MEDFIELD"); - if ( CORBA::is_nil(medfieldfather) ) - { - MESSAGE("Add Object 'MEDFIELD'"); - medfieldfather = myBuilder->NewObject(medfather); - anAttr = myBuilder->FindOrCreateAttribute(medfieldfather, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue("MEDFIELD"); - - } ; - - string fieldName = _fieldTptr->getName(); - - // Create SObject labelled 'FIELDNAME' if it doesn't already exit - SALOMEDS::SObject_var medfieldnamefather = myStudy->FindObject(fieldName.c_str()); - if ( CORBA::is_nil(medfieldnamefather) ) - { - MESSAGE("Add Object "<NewObject(medfieldfather); - anAttr = myBuilder->FindOrCreateAttribute(medfieldnamefather, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(fieldName.c_str()); - - } ; - - // Create object labelled according to Field's Name - - MESSAGE("Add a Field Object under "<NewCommand(); - SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfieldnamefather); - - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init(0,0); - - int iterationNumber = _fieldTptr->getIterationNumber(); - SCRUTE(iterationNumber); - - int orderNumber = _fieldTptr->getOrderNumber(); - SCRUTE(orderNumber); - - ostringstream iterationName ; - iterationName<<"(" << iterationNumber << "," << orderNumber << ")"; - // string supportName = _support->getName(); - string supportName = (_fieldTptr->getSupport())->getName(); - // string meshName = (_support->getMesh())->getName(); - string meshName = ((_fieldTptr->getSupport())->getMesh())->getName(); - string meshNameStudy = meshName; - - char * fieldEntryName; - int lenName = strlen(iterationName.str().c_str()) + 4 + - strlen(supportName.c_str()) + 4 + strlen(meshName.c_str()) + 1; - - fieldEntryName = new char[lenName]; - fieldEntryName = strcpy(fieldEntryName,iterationName.str().c_str()); - fieldEntryName = strcat(fieldEntryName,"_ON_"); - fieldEntryName = strcat(fieldEntryName,supportName.c_str()); - fieldEntryName = strcat(fieldEntryName,"_OF_"); - - for (string::size_type pos=0; posFindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); -// aName->SetValue(iterationName.str().c_str()); - aName->SetValue(fieldEntryName); - - string iorStr = orb->object_to_string(myIor); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.c_str()); - myBuilder->CommitCommand(); - _FieldId = newObj->GetID(); - - MESSAGE("Computing path to Support"); - - 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 fieldof " << supportEntryPath << " length " << lenName); - -// SALOMEDS::SObject_var supportObject = myStudy->FindObject(supportName.c_str()); - SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath); - - SCRUTE(supportObject); - - if ( CORBA::is_nil(supportObject) ) - { - MESSAGE("supportObject is a nil corba object"); - MESSAGE("FIELDOF_i::addInStudy : SUPPORT not found") ; - } - else - { - MESSAGE("supportObject is OK and is now going to be referenced !"); - SALOMEDS::SObject_var newObjSupport = myBuilder->NewObject(newObj); - myBuilder->Addreference(newObjSupport,supportObject); - MESSAGE(" OUF !!!"); - } - - myBuilder->CommitCommand(); - - delete [] supportEntryPath; - delete [] fieldEntryName; - - MESSAGE("FIELDOF_i::addInStudy"); - - //END_OF("FIELDOF_i::addInStudy"); -} -//============================================================================= -/*! - * CORBA: write - */ -//============================================================================= -template void FIELDOF_i::write (CORBA::Long i, const char* driverFieldName) -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - _fieldTptr->write(i,driverFieldName); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\ - ,SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: read - */ -//============================================================================= -template void FIELDOF_i::read (CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - _fieldTptr->read(i); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: rmDriver - */ -//============================================================================= -template void FIELDOF_i::rmDriver (CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - _fieldTptr->rmDriver(i); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: addDriver - */ -//============================================================================= -template CORBA::Long FIELDOF_i::addDriver (SALOME_MED::medDriverTypes driverType, - const char* fileName, const char* fieldName) throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - int drivernum=_fieldTptr->addDriver( - convertIdlDriverToMedDriver(driverType), - fileName, - fieldName); - return drivernum; - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -#endif /* MED_FIELDOF_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_Field_i.cxx b/src/MEDMEM_I/MEDMEM_Field_i.cxx index 84584e430..ff7a44c42 100644 --- a/src/MEDMEM_I/MEDMEM_Field_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Field_i.cxx @@ -6,16 +6,645 @@ // Copyright : EDF 2002 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Field_i.cxx //============================================================================= -# include "MEDMEM_Field_i.hxx" -using namespace MEDMEM; +#include "MEDMEM_Field_i.hxx" -FIELD_i::FIELD_i() +map < int, ::FIELD_ * > FIELD_i::fieldMap ; +int FIELD_i::fieldIndex = 0; +//============================================================================= +/*! + * Default constructor + */ +//============================================================================= + +//FIELD_i::FIELD_i():_fieldTptr(FIELD_i::constructConstField()) +FIELD_i::FIELD_i():_fieldTptr(constructConstField()) { + BEGIN_OF("Default Constructor Field_i"); + END_OF(" Default Constructor Field_i"); } -FIELD_i::FIELD_i(const FIELD_i & x) +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +FIELD_i::~FIELD_i() { + if (_ownCppPtr) delete _fieldTptr; } -FIELD_i::~FIELD_i() +//============================================================================= +/*! + * Constructor + */ +//============================================================================= +FIELD_i::FIELD_i(::FIELD_ * const field, bool ownCppPtr): + _fieldTptr(field), + _corbaIndex(FIELD_i::fieldIndex++), + _FieldId(""), + _ownCppPtr(ownCppPtr) +{ + BEGIN_OF("Constructor FIELD_i(SALOME_MED::SUPPORT_ptr support,::FIELD * const field)"); + FIELD_i::fieldMap[_corbaIndex]=_fieldTptr; + + MESSAGE("FIELD_i::FIELD_i Checking of pointeurs !!!"); + + SCRUTE(_fieldTptr); + + END_OF("Constructor FIELD_i(SALOME_MED::SUPPORT_ptr support,::FIELD * const field)"); +} + +//============================================================================= +/*! + * Constructor par recopie + */ +//============================================================================= +FIELD_i::FIELD_i( FIELD_i & f):_fieldTptr(f._fieldTptr), + _corbaIndex(FIELD_i::fieldIndex++), + _FieldId(""), _ownCppPtr(false) +{ + BEGIN_OF("Constructor Field_i"); + FIELD_i::fieldMap[_corbaIndex]=_fieldTptr; + END_OF("Constructor Field_i"); +} +//============================================================================= +/*! + * Constructor d un pointeur constant + */ +//============================================================================= + ::FIELD_ * FIELD_i::constructConstField() const +{ + ::FIELD_ * const ptrField =new ::FIELD_(); + return ptrField; +} +//============================================================================= +/*! + * CORBA: Accessor for Fields's Name + */ +//============================================================================= +char * FIELD_i::getName() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return CORBA::string_dup(_fieldTptr->getName().c_str()); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au nom"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for Fields's Description + */ +//============================================================================= +char * FIELD_i::getDescription() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return CORBA::string_dup(_fieldTptr->getDescription().c_str()); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant a la description"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for Fields's Support + */ +//============================================================================= + +SALOME_MED::SUPPORT_ptr FIELD_i::getSupport() + throw (SALOME::SALOME_Exception) +{ + BEGIN_OF("SALOME_MED::SUPPORT_ptr FIELD_i::getSupport()"); + + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", + SALOME::INTERNAL_ERROR); + + SUPPORT_i* servant = new SUPPORT_i(_fieldTptr->getSupport()); + + SALOME_MED::SUPPORT_ptr support=servant->_this(); + + SCRUTE(_fieldTptr); + + END_OF("SALOME_MED::SUPPORT_ptr FIELD_i::getSupport()"); + + return support ; +} +//============================================================================= +/*! + * CORBA: Accessor for Fields's Number of components + */ +//============================================================================= +CORBA::Long FIELD_i::getNumberOfComponents() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return _fieldTptr->getNumberOfComponents(); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au support"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for names of component I + */ +//============================================================================= +char * FIELD_i::getComponentName(CORBA::Long i) +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return CORBA::string_dup(_fieldTptr->getComponentName(i).c_str()); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au nom d un component"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for unit of component I + */ +//============================================================================= +char * FIELD_i::getComponentUnit(CORBA::Long i) +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return CORBA::string_dup(_fieldTptr->getMEDComponentUnit(i).c_str()); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au nom d un component"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for description of component I + */ +//============================================================================= +char * FIELD_i::getComponentDescription(CORBA::Long i) +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return CORBA::string_dup(_fieldTptr->getComponentDescription(i).c_str()); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant a la description d un component"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for iteration number + */ +//============================================================================= +CORBA::Long FIELD_i::getIterationNumber() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return _fieldTptr->getIterationNumber(); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for Corba Number + */ +//============================================================================= +CORBA::Long FIELD_i::getCorbaIndex() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + return _corbaIndex; + +} +//============================================================================= +/*! + * CORBA: Accessor for iteration number + */ +//============================================================================= +CORBA::Long FIELD_i::getOrderNumber() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return _fieldTptr->getOrderNumber(); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor + */ +//============================================================================= +CORBA::Double FIELD_i::getTime() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + return _fieldTptr->getTime(); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: Accessor for Fields's Components names + */ +//============================================================================= +SALOME_MED::string_array * FIELD_i::getComponentsNames() +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + SALOME_MED::string_array_var myseq = new SALOME_MED::string_array; + try + { + int nbcom = _fieldTptr->getNumberOfComponents(); + myseq->length(nbcom); + const string * namecom=_fieldTptr->getComponentsNames(); + for (int i=0;igetNumberOfComponents(); + myseq->length(nbcom); + const string * unitcom=_fieldTptr->getMEDComponentsUnits(); + for (int i=0;igetNumberOfComponents(); + myseq->length(nbcom); + const string * namecom=_fieldTptr->getComponentsDescriptions(); + for (int i=0;iNewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var aIOR; + + // Create SComponent labelled 'Med' + SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); + if ( CORBA::is_nil(medfather) ) + THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'MED' not Found",SALOME::INTERNAL_ERROR); + + // Create SObject labelled 'MEDFIELD' if it doesn't already exit + SALOMEDS::SObject_var medfieldfather = myStudy->FindObject("MEDFIELD"); + if ( CORBA::is_nil(medfieldfather) ) + { + MESSAGE("Add Object 'MEDFIELD'"); + medfieldfather = myBuilder->NewObject(medfather); + anAttr = myBuilder->FindOrCreateAttribute(medfieldfather, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue("MEDFIELD"); + + } ; + + string fieldName = _fieldTptr->getName(); + + // Create SObject labelled 'FIELDNAME' if it doesn't already exit + SALOMEDS::SObject_var medfieldnamefather = myStudy->FindObject(fieldName.c_str()); + if ( CORBA::is_nil(medfieldnamefather) ) + { + MESSAGE("Add Object "<NewObject(medfieldfather); + anAttr = myBuilder->FindOrCreateAttribute(medfieldnamefather, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); + aName->SetValue(fieldName.c_str()); + + } ; + + // Create object labelled according to Field's Name + + MESSAGE("Add a Field Object under "<NewCommand(); + SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfieldnamefather); + + ORB_INIT &init = *SINGLETON_::Instance() ; + ASSERT(SINGLETON_::IsAlreadyExisting()) ; + CORBA::ORB_var &orb = init(0,0); + + int iterationNumber = _fieldTptr->getIterationNumber(); + SCRUTE(iterationNumber); + + int orderNumber = _fieldTptr->getOrderNumber(); + SCRUTE(orderNumber); + + ostringstream iterationName ; + iterationName<<"(" << iterationNumber << "," << orderNumber << ")"; + // string supportName = _support->getName(); + string supportName = (_fieldTptr->getSupport())->getName(); + // string meshName = (_support->getMesh())->getName(); + string meshName = ((_fieldTptr->getSupport())->getMesh())->getName(); + string meshNameStudy = meshName; + + char * fieldEntryName; + int lenName = strlen(iterationName.str().c_str()) + 4 + + strlen(supportName.c_str()) + 4 + strlen(meshName.c_str()) + 1; + + fieldEntryName = new char[lenName]; + fieldEntryName = strcpy(fieldEntryName,iterationName.str().c_str()); + fieldEntryName = strcat(fieldEntryName,"_ON_"); + fieldEntryName = strcat(fieldEntryName,supportName.c_str()); + fieldEntryName = strcat(fieldEntryName,"_OF_"); + + for (string::size_type pos=0; posFindOrCreateAttribute(newObj, "AttributeName"); + aName = SALOMEDS::AttributeName::_narrow(anAttr); +// aName->SetValue(iterationName.str().c_str()); + aName->SetValue(fieldEntryName); + + string iorStr = orb->object_to_string(myIor); + anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); + aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + aIOR->SetValue(iorStr.c_str()); + myBuilder->CommitCommand(); + _FieldId = newObj->GetID(); + + MESSAGE("Computing path to Support"); + + 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); + +// SALOMEDS::SObject_var supportObject = myStudy->FindObject(supportName.c_str()); + SALOMEDS::SObject_var supportObject = myStudy->FindObjectByPath(supportEntryPath); + + SCRUTE(supportObject); + + if ( CORBA::is_nil(supportObject) ) + { + MESSAGE("supportObject is a nil corba object"); + MESSAGE("FIELD_i::addInStudy : SUPPORT not found") ; + } + else + { + MESSAGE("supportObject is OK and is now going to be referenced !"); + SALOMEDS::SObject_var newObjSupport = myBuilder->NewObject(newObj); + myBuilder->Addreference(newObjSupport,supportObject); + MESSAGE(" OUF !!!"); + } + + myBuilder->CommitCommand(); + + delete [] supportEntryPath; + delete [] fieldEntryName; + + MESSAGE("FIELD_i::addInStudy"); + + //END_OF("FIELD_i::addInStudy"); +} +//============================================================================= +/*! + * CORBA: write + */ +//============================================================================= +void FIELD_i::write (CORBA::Long i, const char* driverFieldName) +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + _fieldTptr->write(i,driverFieldName); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION("Unable to acces Field C++ Object"\ + ,SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: read + */ +//============================================================================= +void FIELD_i::read (CORBA::Long i) +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + _fieldTptr->read(i); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: rmDriver + */ +//============================================================================= +void FIELD_i::rmDriver (CORBA::Long i) +throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + _fieldTptr->rmDriver(i); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} +//============================================================================= +/*! + * CORBA: addDriver + */ +//============================================================================= +CORBA::Long FIELD_i::addDriver (SALOME_MED::medDriverTypes driverType, + const char* fileName, const char* fieldName) throw (SALOME::SALOME_Exception) +{ + if (_fieldTptr==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ + SALOME::INTERNAL_ERROR); + try + { + int drivernum=_fieldTptr->addDriver( + convertIdlDriverToMedDriver(driverType), + fileName, + fieldName); + return drivernum; + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Exception en accedant au champ"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } +} + +//============================================================================= +/*! + * CORBA: Destructor +*/ +//============================================================================= +void FIELD_i::release() { + PortableServer::ObjectId_var oid=_default_POA()->servant_to_id(this); + _default_POA()->deactivate_object(oid); + _remove_ref(); } diff --git a/src/MEDMEM_I/MEDMEM_Field_i.hxx b/src/MEDMEM_I/MEDMEM_Field_i.hxx index e0f195cac..11cfd0f91 100644 --- a/src/MEDMEM_I/MEDMEM_Field_i.hxx +++ b/src/MEDMEM_I/MEDMEM_Field_i.hxx @@ -1,68 +1,99 @@ //============================================================================= // File : MEDMEM_Field_i.hxx -// Created : mer fév 20 15:47:57 CET 2002 -// Author : EDF // Project : SALOME +// Author : EDF // Copyright : EDF 2002 // $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Field_i.hxx //============================================================================= -# ifndef __FIELD_I_H__ -# define __FIELD_I_H__ -# include -# include CORBA_SERVER_HEADER(MED) -# include "Utils_CorbaException.hxx" +#ifndef MED_FIELD_I_HXX_ +#define MED_FIELD_I_HXX_ + +#include +#include +#include + +#include "Utils_CorbaException.hxx" +#include + +# include "Utils_ORB_INIT.hxx" +# include "Utils_SINGLETON.hxx" + +#include CORBA_SERVER_HEADER(MED) +#include CORBA_SERVER_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) + +#include "MEDMEM_Support_i.hxx" + +#include "MEDMEM_convert.hxx" + +#include "MEDMEM_Support.hxx" +#include "MEDMEM_Field.hxx" namespace MEDMEM { -class FIELD_i +class FIELD_i: public virtual POA_SALOME_MED::FIELD, + public PortableServer::RefCountServantBase { - +public : + static map < int, ::MEDMEM::FIELD_ * > fieldMap ; +protected : + static int fieldIndex ; + bool _ownCppPtr; protected : - FIELD_i(); + // C++ object containing values and Constructor + // are protected because it is not supposed to be instancied + + ::MEDMEM::FIELD_ * const _fieldTptr; + const int _corbaIndex; + string _FieldId; + FIELD_i(); + FIELD_i(::FIELD_ * const field, bool ownCppPtr); + FIELD_i(FIELD_i & f); public : - FIELD_i( const FIELD_i & x); - ~FIELD_i(); - virtual char * getName() - throw (SALOME::SALOME_Exception) = 0; - virtual char * getDescription() - throw (SALOME::SALOME_Exception) = 0; - virtual SALOME_MED::SUPPORT_ptr getSupport() - throw (SALOME::SALOME_Exception) = 0; - virtual CORBA::Long getNumberOfComponents() - throw (SALOME::SALOME_Exception) = 0; - virtual char * getComponentName(CORBA::Long i) - throw (SALOME::SALOME_Exception) = 0; - virtual char * getComponentUnit(CORBA::Long i) - throw (SALOME::SALOME_Exception) = 0; - virtual CORBA::Long getIterationNumber() - throw (SALOME::SALOME_Exception) = 0; - virtual CORBA::Long getOrderNumber() - throw (SALOME::SALOME_Exception) = 0; - virtual CORBA::Double getTime() - throw (SALOME::SALOME_Exception) = 0; - virtual CORBA::Long getCorbaIndex() - throw (SALOME::SALOME_Exception) = 0; - virtual SALOME_MED::string_array * getComponentsNames() - throw (SALOME::SALOME_Exception) = 0; - virtual SALOME_MED::string_array * getComponentsUnits() - throw (SALOME::SALOME_Exception) = 0; - virtual void addInStudy(SALOMEDS::Study_ptr myStudy , - SALOME_MED::FIELD_ptr myIor) - throw (SALOME::SALOME_Exception, - SALOMEDS::StudyBuilder::LockProtection) = 0; - virtual CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType, - const char* fileName, - const char* fieldName) - throw (SALOME::SALOME_Exception) = 0; - virtual void rmDriver (CORBA::Long i) - throw (SALOME::SALOME_Exception) = 0; - virtual void read (CORBA::Long i) - throw (SALOME::SALOME_Exception) = 0; - virtual void write (CORBA::Long i, - const char* driverFieldName) - throw (SALOME::SALOME_Exception) = 0; -}; -}; -# endif /* ifndef ____FIELD_I_H__ */ + // Associated internal methods + ~FIELD_i(); + + char * getName() throw (SALOME::SALOME_Exception); + char * getDescription() throw (SALOME::SALOME_Exception); + SALOME_MED::SUPPORT_ptr getSupport() throw (SALOME::SALOME_Exception); + CORBA::Long getNumberOfComponents() + throw (SALOME::SALOME_Exception); + char * getComponentName(CORBA::Long i) + throw (SALOME::SALOME_Exception); + char * getComponentUnit(CORBA::Long i) + throw (SALOME::SALOME_Exception); + char * getComponentDescription(CORBA::Long i) + throw (SALOME::SALOME_Exception); + CORBA::Long getIterationNumber() + throw (SALOME::SALOME_Exception); + CORBA::Long getOrderNumber() throw (SALOME::SALOME_Exception); + CORBA::Double getTime() throw (SALOME::SALOME_Exception); + CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception); + + SALOME_MED::string_array * getComponentsNames() throw (SALOME::SALOME_Exception); + SALOME_MED::string_array * getComponentsUnits() throw (SALOME::SALOME_Exception); + SALOME_MED::string_array * getComponentsDescriptions() throw (SALOME::SALOME_Exception); + void addInStudy(SALOMEDS::Study_ptr myStudy, + SALOME_MED::FIELD_ptr myIor) + throw (SALOME::SALOME_Exception, + SALOMEDS::StudyBuilder::LockProtection); + + CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType, + const char* fileName, const char* fieldName) + throw (SALOME::SALOME_Exception); + void rmDriver (CORBA::Long i) throw (SALOME::SALOME_Exception); + void read (CORBA::Long i) throw (SALOME::SALOME_Exception); + void write (CORBA::Long i, const char* driverFieldName) + throw (SALOME::SALOME_Exception); + void release(); + // Cuisine Interne + ::FIELD_ * constructConstField() const; + + }; +} + +//using namespace MEDMEM; + +#endif /* MED_FIELD_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_Group_i.cxx b/src/MEDMEM_I/MEDMEM_Group_i.cxx index d405cdf50..e11867a24 100644 --- a/src/MEDMEM_I/MEDMEM_Group_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Group_i.cxx @@ -103,10 +103,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - myseq[i] = f2; + myseq[i] = f1->POA_SALOME_MED::FAMILY::_this(); } } catch (MEDEXCEPTION &ex) @@ -132,9 +129,7 @@ throw (SALOME::SALOME_Exception) { FAMILY * fam=_group->getFamily(i); FAMILY_i * f1=new FAMILY_i(fam); - SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - return (SALOME_MED::FAMILY::_duplicate(f2)); + return f1->POA_SALOME_MED::FAMILY::_this(); } catch (MEDEXCEPTION &ex) { diff --git a/src/MEDMEM_I/MEDMEM_Med_i.cxx b/src/MEDMEM_I/MEDMEM_Med_i.cxx index c2f48b4c8..ef2503c35 100644 --- a/src/MEDMEM_I/MEDMEM_Med_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Med_i.cxx @@ -58,7 +58,7 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin MESH_i * myMeshI = new MESH_i(myMesh); SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this(); _meshes[meshesNames[i]] = myMeshIOR; - myMeshI->addInStudy(myStudy,myMeshIOR,fileName); +// myMeshI->addInStudy(myStudy,myMeshIOR,fileName); } // SUPPORTS : @@ -92,7 +92,7 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin { FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt); SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->POA_SALOME_MED::FAMILY::_this(); - myFamilyI->addInStudy(myStudy,myFamilyIOR); +// myFamilyI->addInStudy(myStudy,myFamilyIOR); } // group : @@ -105,7 +105,7 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin { GROUP_i * myGroupI = new GROUP_i(*groupVectorIt); SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->POA_SALOME_MED::GROUP::_this(); - myGroupI->addInStudy(myStudy,myGroupIOR); +// myGroupI->addInStudy(myStudy,myGroupIOR); } } } @@ -121,7 +121,7 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin SUPPORT_i * mySupportI = new SUPPORT_i((*itSupport).second); SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this(); mySupportsIOR[(*itSupport).first] = mySupportIOR; - mySupportI->addInStudy(myStudy,mySupportIOR); +// mySupportI->addInStudy(myStudy,mySupportIOR); } } @@ -160,23 +160,18 @@ void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes driverType, const strin case MED_FR::MED_INT32 : { ((FIELD*)myField)->read(); - FIELDINT_i * myFieldIntI = new FIELDINT_i(mySupportIOR,(FIELD*)myField); - POA_SALOME_MED::FIELD_tie * myFieldTie - = new POA_SALOME_MED::FIELD_tie(myFieldIntI); - myFieldIOR = myFieldTie->_this(); - myFieldIntI->addInStudy(myStudy,myFieldIOR); + FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); + myFieldIOR = myFieldIntI->_this(); +// myFieldIntI->addInStudy(myStudy,myFieldIOR); break; } case MED_FR::MED_REEL64: { ((FIELD*)myField)->read(); - FIELDDOUBLE_i * myFieldDoubleI - = new FIELDDOUBLE_i(mySupportIOR,(FIELD*)myField); - POA_SALOME_MED::FIELD_tie * myFieldTie - = new POA_SALOME_MED::FIELD_tie(myFieldDoubleI); - myFieldIOR = myFieldTie->_this(); - myFieldDoubleI->addInStudy(myStudy,myFieldIOR); + FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); + myFieldIOR = myFieldDoubleI->_this(); +// myFieldDoubleI->addInStudy(myStudy,myFieldIOR); break; } default: @@ -488,12 +483,9 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType case MED_FR::MED_INT32: { ((FIELD*)myField)->read(); - FIELDINT_i * myFieldIntI - = new FIELDINT_i(mySupportIOR,(FIELD*)myField); + FIELDINT_i * myFieldIntI = new FIELDINT_i((FIELD*)myField); SALOME_MED::FIELDINT_ptr myFieldIntIOR; - POA_SALOME_MED::FIELDINT_tie * myFieldIntTie - = new POA_SALOME_MED::FIELDINT_tie(myFieldIntI); - myFieldIntIOR = myFieldIntTie->_this(); + myFieldIntIOR = myFieldIntI->_this(); MESSAGE(LOC << " add in study of the field " << fieldsNames[i].c_str() << " dt = " << dtIt.dt << " it = " << dtIt.it); @@ -505,12 +497,9 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType case MED_FR::MED_REEL64: { ((FIELD*)myField)->read(); - FIELDDOUBLE_i * myFieldDoubleI - = new FIELDDOUBLE_i(mySupportIOR,(FIELD*)myField); + FIELDDOUBLE_i * myFieldDoubleI = new FIELDDOUBLE_i((FIELD*)myField); SALOME_MED::FIELDDOUBLE_ptr myFieldDoubleIOR; - POA_SALOME_MED::FIELDDOUBLE_tie * myFieldDoubleTie - = new POA_SALOME_MED::FIELDDOUBLE_tie(myFieldDoubleI); - myFieldDoubleIOR = myFieldDoubleTie->_this(); + myFieldDoubleIOR = myFieldDoubleI->_this(); MESSAGE(LOC << " add in study of the field " << fieldsNames[i].c_str() << " dt = " << dtIt.dt << " it = " << dtIt.it); @@ -530,7 +519,6 @@ void MED_i::initWithFieldType(SALOMEDS::Study_ptr myStudy,driverTypes driverType } } - MESSAGE("Here we are i="<< i); } @@ -796,9 +784,7 @@ throw (SALOME::SALOME_Exception) { MESH * mesh=_med->getMesh(meshName); MESH_i * m1 = new MESH_i(mesh); - SALOME_MED::MESH_ptr m2 = m1->POA_SALOME_MED::MESH::_this(); - m1->_remove_ref(); - return (SALOME_MED::MESH::_duplicate(m2)); + return m1->POA_SALOME_MED::MESH::_this(); } catch (MEDEXCEPTION &ex) { @@ -829,22 +815,22 @@ throw (SALOME::SALOME_Exception) SALOME_MED::FIELDDOUBLE_var fielddouble = SALOME_MED::FIELDDOUBLE::_narrow(fieldPtr); ASSERT(!CORBA::is_nil(fielddouble)); - ASSERT(FIELDOF_i::fieldMap.find(ind) - !=FIELDOF_i::fieldMap.end()); - ::FIELD * fdouble = FIELDOF_i::fieldMap[ind]; + + ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); + + ::FIELD * fdouble = (::FIELD *)FIELD_i::fieldMap[ind]; MESH * mesh=_med->getMesh(fdouble); } else { MESSAGE("Integer"); - ASSERT(FIELDOF_i::fieldMap.find(ind)!=FIELDOF_i::fieldMap.end()); - ::FIELD * fint = FIELDOF_i::fieldMap[ind]; + ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); + + ::FIELD * fint = (::FIELD *)FIELD_i::fieldMap[ind]; MESH * mesh=_med->getMesh(fint); } MESH_i * meshi = new MESH_i(mesh); - SALOME_MED::MESH_ptr meshptr = meshi->POA_SALOME_MED::MESH::_this(); - meshi->_remove_ref(); - return (SALOME_MED::MESH::_duplicate(meshptr)); + return meshi->POA_SALOME_MED::MESH::_this(); } //============================================================================= @@ -1129,17 +1115,18 @@ throw (SALOME::SALOME_Exception) SALOME_MED::FIELDDOUBLE_var fielddouble = SALOME_MED::FIELDDOUBLE::_narrow(ptrField); ASSERT(!CORBA::is_nil(fielddouble)); - ASSERT(FIELDOF_i::fieldMap.find(ind) - !=FIELDOF_i::fieldMap.end()); - ::FIELD * fdouble = FIELDOF_i::fieldMap[ind]; + + ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); + + ::FIELD * fdouble = (::FIELD *)FIELD_i::fieldMap[ind]; // A modifier //_med->addField(fdouble); } else { MESSAGE("Integer"); - ASSERT(FIELDOF_i::fieldMap.find(ind)!=FIELDOF_i::fieldMap.end()); - ::FIELD * fint = FIELDOF_i::fieldMap[ind]; + ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); + ::FIELD * fint = (::FIELD *)FIELD_i::fieldMap[ind]; //_med->addField(fint); } } diff --git a/src/MEDMEM_I/MEDMEM_Mesh_i.cxx b/src/MEDMEM_I/MEDMEM_Mesh_i.cxx index 292bb52ce..e8feb02c7 100644 --- a/src/MEDMEM_I/MEDMEM_Mesh_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Mesh_i.cxx @@ -24,6 +24,9 @@ #include "MEDMEM_Family.hxx" #include "MEDMEM_Group.hxx" #include "MEDMEM_CellModel.hxx" + +#include "SenderFactory.hxx" +#include "MultiCommException.hxx" using namespace MEDMEM; // Initialisation des variables statiques @@ -290,6 +293,34 @@ throw (SALOME::SALOME_Exception) return myseq._retn(); } //============================================================================= +/*! + * CORBA: 2nd Accessor for Coordinates + */ +//============================================================================= +SALOME::Sender_ptr MESH_i::getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch) + throw (SALOME::SALOME_Exception) +{ + if (_mesh==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ + SALOME::INTERNAL_ERROR); + SALOME::Sender_ptr ret; + try + { + int spaceDimension=_mesh->getSpaceDimension(); + int nbNodes=_mesh->getNumberOfNodes(); + const double * coordinates =_mesh->getCoordinates(convertIdlModeToMedMode(typeSwitch)); + ret=SenderFactory::buildSender(*this,coordinates,nbNodes*spaceDimension); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Unable to acces the coordinates"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } + catch(MultiCommException &ex2) + THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR); + return ret; +} +//============================================================================= /*! * CORBA: Accessor for Coordinates Names */ @@ -540,6 +571,45 @@ SCRUTE(nbelements); return myseq._retn(); } //============================================================================= +/*! + * CORBA: 2nd Accessor for connectivities + */ +//============================================================================= +SALOME::Sender_ptr MESH_i::getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch, + SALOME_MED::medConnectivity mode, + SALOME_MED::medEntityMesh entity, + SALOME_MED::medGeometryElement geomElement) +throw (SALOME::SALOME_Exception) +{ + if (_mesh==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ + SALOME::INTERNAL_ERROR); + if (verifieParam(entity,geomElement)==false) + THROW_SALOME_CORBA_EXCEPTION("parameters don't match",\ + SALOME::BAD_PARAM); + SALOME::Sender_ptr ret; + try + { + int nbelements=_mesh->getConnectivityLength(convertIdlModeToMedMode(typeSwitch), + convertIdlConnToMedConn(mode), + convertIdlEntToMedEnt(entity), + convertIdlEltToMedElt(geomElement)); + const int * numbers=_mesh->getConnectivity(convertIdlModeToMedMode(typeSwitch), + convertIdlConnToMedConn(mode), + convertIdlEntToMedEnt(entity), + convertIdlEltToMedElt(geomElement)); + ret=SenderFactory::buildSender(*this,numbers,nbelements); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Unable to acces connectivities"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } + catch(MultiCommException &ex2) + THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR); + return ret; +} +//============================================================================= /*! * CORBA: Accessor for connectivities */ @@ -649,15 +719,7 @@ throw (SALOME::SALOME_Exception) SALOME_MED::long_array_var myseq= new SALOME_MED::long_array; try { - int nbelements; - if ( mode == SALOME_MED::MED_DESCENDING) - { - nbelements =(_mesh->getNumberOfNodes())+1; - } - else - { - nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS); - } + int nbelements=_mesh->getReverseConnectivityLength(convertIdlConnToMedConn(mode)); SCRUTE(nbelements); myseq->length(nbelements); const int * numbers=_mesh->getReverseConnectivity(convertIdlConnToMedConn(mode)); @@ -687,24 +749,7 @@ throw (SALOME::SALOME_Exception) SALOME_MED::long_array_var myseq= new SALOME_MED::long_array; try { - int nbelements; - if ( mode == SALOME_MED::MED_DESCENDING) - { - nbelements =_mesh->getNumberOfNodes(); - } - else - { - int dim=_mesh->getMeshDimension(); - if ( dim == 3) - nbelements = _mesh->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS); - else - if (dim == 2) - nbelements = _mesh->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS); - else - THROW_SALOME_CORBA_EXCEPTION("Pb ", \ - SALOME::INTERNAL_ERROR); - } - + int nbelements=_mesh->getReverseConnectivityIndexLength(convertIdlConnToMedConn(mode)); myseq->length(nbelements); const int * numbers=_mesh->getReverseConnectivityIndex(convertIdlConnToMedConn(mode)); for (int i=0;iPOA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - myseq[i] = f2; + myseq[i] = f1->POA_SALOME_MED::FAMILY::_this(); } } catch (MEDEXCEPTION &ex) @@ -852,6 +894,7 @@ throw (SALOME::SALOME_Exception) convertIdlEntToMedEnt(entity)); all->meshTypes.length(nbTypes); all->numberOfElements.length(nbTypes); + all->entityDimension=_mesh->getConnectivityptr()->getEntityDimension(); for (int i=0; imeshTypes[i]=convertMedEltToIdlElt(elemts[i]); @@ -883,9 +926,7 @@ throw (SALOME::SALOME_Exception) { const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i); FAMILY_i * f1=new FAMILY_i(fam); - SALOME_MED::FAMILY_ptr f2 = f1->POA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - return (SALOME_MED::FAMILY::_duplicate(f2)); + return f1->POA_SALOME_MED::FAMILY::_this(); } catch (MEDEXCEPTION &ex) { @@ -921,9 +962,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - all->famNode[i] = f2; + all->famNode[i] = f1->POA_SALOME_MED::FAMILY::_this(); } nbFam = _mesh->getNumberOfFamilies(MED_EDGE); @@ -934,9 +973,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - all->famEdge[i] = f2; + all->famEdge[i] = f1->POA_SALOME_MED::FAMILY::_this(); } nbFam = _mesh->getNumberOfFamilies(MED_FACE); @@ -946,9 +983,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - all->famFace[i] = f2; + all->famFace[i] = f1->POA_SALOME_MED::FAMILY::_this(); } nbFam = _mesh->getNumberOfFamilies(MED_CELL); @@ -958,9 +993,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::FAMILY::_this(); - f1->_remove_ref(); - all->famCell[i] = f2; + all->famCell[i] = f1->POA_SALOME_MED::FAMILY::_this(); } int nbGroup = _mesh->getNumberOfGroups(MED_NODE); @@ -970,9 +1003,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::GROUP::_this(); - f1->_remove_ref(); - all->groupNode[i] = f2; + all->groupNode[i] = f1->POA_SALOME_MED::GROUP::_this(); } nbGroup = _mesh->getNumberOfGroups(MED_EDGE); @@ -982,9 +1013,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::GROUP::_this(); - f1->_remove_ref(); - all->groupEdge[i] = f2; + all->groupEdge[i] = f1->POA_SALOME_MED::GROUP::_this(); } nbGroup = _mesh->getNumberOfGroups(MED_FACE); all->groupFace.length(nbGroup); @@ -993,9 +1022,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::GROUP::_this(); - f1->_remove_ref(); - all->groupFace[i] = f2; + all->groupFace[i] = f1->POA_SALOME_MED::GROUP::_this(); } nbGroup = _mesh->getNumberOfGroups(MED_CELL); @@ -1005,9 +1032,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::GROUP::_this(); - f1->_remove_ref(); - all->groupCell[i] = f2; + all->groupCell[i] = f1->POA_SALOME_MED::GROUP::_this(); } } @@ -1039,9 +1064,7 @@ throw (SALOME::SALOME_Exception) for (int i=0;iPOA_SALOME_MED::GROUP::_this(); - f1->_remove_ref(); - myseq[i] = f2; + myseq[i] = f1->POA_SALOME_MED::GROUP::_this(); } } catch (MEDEXCEPTION &ex) @@ -1067,9 +1090,7 @@ throw (SALOME::SALOME_Exception) { const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i); GROUP_i * f1=new GROUP_i(grou); - SALOME_MED::GROUP_ptr f2 = f1->POA_SALOME_MED::GROUP::_this(); - f1->_remove_ref(); - return (SALOME_MED::GROUP::_duplicate(f2)); + return f1->POA_SALOME_MED::GROUP::_this(); } catch (MEDEXCEPTION &ex) { @@ -1092,8 +1113,7 @@ throw (SALOME::SALOME_Exception) { SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity)); SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport); - SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ; - return (SALOME_MED::SUPPORT::_duplicate(mySupportIOR)); + return mySupportI->_this(); } catch (MEDEXCEPTION &ex) { @@ -1117,12 +1137,8 @@ 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(mySupport,f); - POA_SALOME_MED::FIELDDOUBLE_tie * f1 = - new POA_SALOME_MED::FIELDDOUBLE_tie(medf,true); - SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this(); - f1->_remove_ref(); - return (SALOME_MED::FIELD::_duplicate(f2)); + FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + return medf->_this(); } catch (MEDEXCEPTION &ex) { @@ -1148,8 +1164,7 @@ throw (SALOME::SALOME_Exception) const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport); SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport); - SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this() ; - return (SALOME_MED::SUPPORT::_duplicate(mySupportIOR)); + return mySupportI->_this() ; } catch (MEDEXCEPTION &ex) { @@ -1174,12 +1189,8 @@ 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(mySupport,f); - POA_SALOME_MED::FIELDDOUBLE_tie * f1 = - new POA_SALOME_MED::FIELDDOUBLE_tie(medf,true); - SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this(); - f1->_remove_ref(); - return (SALOME_MED::FIELD::_duplicate(f2)); + FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + return medf->_this(); } catch (MEDEXCEPTION &ex) { @@ -1204,12 +1215,8 @@ 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(mySupport,f); - POA_SALOME_MED::FIELDDOUBLE_tie * f1 = - new POA_SALOME_MED::FIELDDOUBLE_tie(medf,true); - SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this(); - f1->_remove_ref(); - return (SALOME_MED::FIELD::_duplicate(f2)); + FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + return medf->_this(); } catch (MEDEXCEPTION &ex) { @@ -1234,12 +1241,8 @@ 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(mySupport,f); - POA_SALOME_MED::FIELDDOUBLE_tie * f1 = - new POA_SALOME_MED::FIELDDOUBLE_tie(medf,true); - SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this(); - f1->_remove_ref(); - return (SALOME_MED::FIELD::_duplicate(f2)); + FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + return medf->_this(); } catch (MEDEXCEPTION &ex) { @@ -1264,12 +1267,8 @@ 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(mySupport,f); - POA_SALOME_MED::FIELDDOUBLE_tie * f1 = - new POA_SALOME_MED::FIELDDOUBLE_tie(medf,true); - SALOME_MED::FIELDDOUBLE_ptr f2 = f1->_this(); - f1->_remove_ref(); - return (SALOME_MED::FIELD::_duplicate(f2)); + FIELDDOUBLE_i * medf = new FIELDDOUBLE_i(f); + return medf->_this(); } catch (MEDEXCEPTION &ex) { @@ -1513,3 +1512,14 @@ throw (SALOME::SALOME_Exception) } } +//============================================================================= +/*! + * CORBA : Servant destruction + */ +//============================================================================= +void MESH_i::release() +{ + PortableServer::ObjectId_var oid=_default_POA()->servant_to_id(this); + _default_POA()->deactivate_object(oid); + _remove_ref(); +} diff --git a/src/MEDMEM_I/MEDMEM_Mesh_i.hxx b/src/MEDMEM_I/MEDMEM_Mesh_i.hxx index 5b0e640dc..616027bba 100644 --- a/src/MEDMEM_I/MEDMEM_Mesh_i.hxx +++ b/src/MEDMEM_I/MEDMEM_Mesh_i.hxx @@ -13,15 +13,16 @@ #include #include +#include "SALOMEMultiComm.hxx" #include CORBA_SERVER_HEADER(MED) #include CORBA_SERVER_HEADER(SALOMEDS_Attributes) +#include CORBA_SERVER_HEADER(SALOME_Comm) namespace MEDMEM { class MESH; -class MESH_i: - public POA_SALOME_MED::MESH, - public PortableServer::RefCountServantBase -// public SALOME_MED_Component_i +class MESH_i: public POA_SALOME_MED::MESH, + public PortableServer::RefCountServantBase, + public SALOMEMultiComm { public : static map < int,::MEDMEM::MESH *> meshMap; @@ -64,6 +65,9 @@ public: SALOME_MED::double_array* getCoordinates(SALOME_MED::medModeSwitch typeSwitch) throw (SALOME::SALOME_Exception); + + SALOME::Sender_ptr getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch) + throw (SALOME::SALOME_Exception); CORBA::Double getCoordinate(CORBA::Long Number, CORBA::Long Axis) throw (SALOME::SALOME_Exception); @@ -97,6 +101,12 @@ public: SALOME_MED::medEntityMesh entity, SALOME_MED::medGeometryElement geomElement) throw (SALOME::SALOME_Exception); + + SALOME::Sender_ptr getSenderForConnectivity(SALOME_MED::medModeSwitch typeSwitch, + SALOME_MED::medConnectivity mode, + SALOME_MED::medEntityMesh entity, + SALOME_MED::medGeometryElement geomElement) + throw (SALOME::SALOME_Exception); SALOME_MED::long_array* getConnectivityIndex(SALOME_MED::medConnectivity mode, SALOME_MED::medEntityMesh entity) @@ -178,6 +188,8 @@ public: SALOME_MED::MESH::connectivityInfos * getConnectGlobal (SALOME_MED::medEntityMesh entity) throw (SALOME::SALOME_Exception); + + void release(); }; } diff --git a/src/MEDMEM_I/MEDMEM_Support_i.cxx b/src/MEDMEM_I/MEDMEM_Support_i.cxx index 8858a600c..0bcd75b69 100644 --- a/src/MEDMEM_I/MEDMEM_Support_i.cxx +++ b/src/MEDMEM_I/MEDMEM_Support_i.cxx @@ -21,6 +21,9 @@ #include "MEDMEM_Support_i.hxx" #include "MEDMEM_Mesh_i.hxx" #include "MEDMEM_convert.hxx" + +#include "SenderFactory.hxx" +#include "MultiCommException.hxx" using namespace MEDMEM; // Initialisation des variables statiques @@ -153,6 +156,7 @@ throw (SALOME::SALOME_Exception) all->description = CORBA::string_dup(_support->getDescription().c_str()); const int numberOfTypes = _support->getNumberOfTypes(); all->numberOfGeometricType = numberOfTypes; + all->entity = _support->getEntity(); all->types.length(numberOfTypes); all->nbEltTypes.length(numberOfTypes); @@ -200,11 +204,9 @@ throw (SALOME::SALOME_Exception) SCRUTE(m1); SCRUTE(m2); - m1->_remove_ref(); - END_OF("SALOME_MED::MESH_ptr SUPPORT_i::getMesh()"); - return (SALOME_MED::MESH::_duplicate(m2)); + return (m2); } catch (MEDEXCEPTION &ex) { @@ -384,6 +386,37 @@ SCRUTE(numbers[i]); return myseq._retn(); } + +//============================================================================= +/*! + * CORBA: 2nd get Nodes + */ +//============================================================================= +SALOME::Sender_ptr SUPPORT_i::getSenderForNumber(SALOME_MED::medGeometryElement geomElement) + throw (SALOME::SALOME_Exception) +{ + SCRUTE(_support); + SCRUTE(geomElement); + SCRUTE(convertIdlEltToMedElt(geomElement)); + if (_support==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Support", \ + SALOME::INTERNAL_ERROR); + SALOME::Sender_ptr ret; + try + { + int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement)); + const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement)); + ret=SenderFactory::buildSender(*this,numbers,nbelements); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Unable to access the support optionnal index"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } + catch(MultiCommException &ex2) + THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR); + return ret; +} //============================================================================= /*! * CORBA: Global Nodes Index (optionnaly designed by the user) @@ -418,6 +451,35 @@ throw (SALOME::SALOME_Exception) } //============================================================================= +/*! + * CORBA: 2nd Global Nodes Index (optionnaly designed by the user) + */ +//============================================================================= + +SALOME::Sender_ptr SUPPORT_i::getSenderForNumberIndex() + throw (SALOME::SALOME_Exception) +{ + if (_support==NULL) + THROW_SALOME_CORBA_EXCEPTION("No associated Support", \ + SALOME::INTERNAL_ERROR); + SALOME::Sender_ptr ret; + try + { + 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); + } + catch (MEDEXCEPTION &ex) + { + MESSAGE("Unable to access the support index"); + THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); + } + catch(MultiCommException &ex2) + THROW_SALOME_CORBA_EXCEPTION(ex2.what(),SALOME::INTERNAL_ERROR); + return ret; +} +//============================================================================= /*! * CORBA: */ @@ -649,3 +711,15 @@ void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr END_OF(LOC); } + +//============================================================================= +/*! + * CORBA: release <=> remote delete this + */ +//============================================================================= +void SUPPORT_i::release() +{ + PortableServer::ObjectId_var oid=_default_POA()->servant_to_id(this); + _default_POA()->deactivate_object(oid); + _remove_ref(); +} diff --git a/src/MEDMEM_I/MEDMEM_Support_i.hxx b/src/MEDMEM_I/MEDMEM_Support_i.hxx index 03afd5a87..f35bf9e63 100644 --- a/src/MEDMEM_I/MEDMEM_Support_i.hxx +++ b/src/MEDMEM_I/MEDMEM_Support_i.hxx @@ -14,15 +14,17 @@ #include +#include "SALOMEMultiComm.hxx" #include CORBA_SERVER_HEADER(MED) +#include CORBA_SERVER_HEADER(SALOME_Comm) namespace MEDMEM { class SUPPORT; class SALOME_MED::MESH; -class SUPPORT_i: - public POA_SALOME_MED::SUPPORT, - public PortableServer::RefCountServantBase +class SUPPORT_i: public POA_SALOME_MED::SUPPORT, + public PortableServer::RefCountServantBase, + public SALOMEMultiComm { public : static map < int,::MEDMEM::SUPPORT *> supportMap; @@ -57,8 +59,12 @@ public: throw (SALOME::SALOME_Exception); SALOME_MED::long_array* getNumber(SALOME_MED::medGeometryElement geomElement) throw (SALOME::SALOME_Exception); + SALOME::Sender_ptr getSenderForNumber(SALOME_MED::medGeometryElement geomElement) + throw (SALOME::SALOME_Exception); SALOME_MED::long_array* getNumberIndex() throw (SALOME::SALOME_Exception); + SALOME::Sender_ptr getSenderForNumberIndex() + throw (SALOME::SALOME_Exception); CORBA::Long getNumberOfGaussPoint(SALOME_MED::medGeometryElement geomElement) throw (SALOME::SALOME_Exception); SALOME_MED::long_array* getNumbersOfGaussPoint() @@ -75,7 +81,7 @@ public: SALOME_MED::SUPPORT_ptr myIor) throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection); - + void release(); // Cuisine interne CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception); SALOME_MED::SUPPORT::supportInfos * getSupportGlobal() throw (SALOME::SALOME_Exception); diff --git a/src/MEDMEM_I/Makefile.in b/src/MEDMEM_I/Makefile.in index 0c0ba7c63..b27d8931b 100644 --- a/src/MEDMEM_I/Makefile.in +++ b/src/MEDMEM_I/Makefile.in @@ -44,7 +44,6 @@ EXPORT_HEADERS = \ MEDMEM_Family_i.hxx \ MEDMEM_FieldDouble_i.hxx \ MEDMEM_FieldInt_i.hxx \ - MEDMEM_FieldOf_i.hxx \ MEDMEM_Field_i.hxx \ MEDMEM_Group_i.hxx \ MEDMEM_Mesh_i.hxx \ @@ -55,7 +54,7 @@ EXPORT_HEADERS = \ 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_SERVER_IDL = MED.idl -LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl +LIB_CLIENT_IDL= SALOME_Component.idl SALOMEDS.idl SALOMEDS_Attributes.idl SALOME_Exception.idl SALOME_Comm.idl # Executables targets BIN_SRC = @@ -65,7 +64,7 @@ BIN_CLIENT_IDL = CPPFLAGS+= $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome CXXFLAGS+= -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lmedmem -lOpUtil -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace +LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lmedmem -lOpUtil -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace -L${KERNEL_ROOT_DIR}/lib/salome -lSALOMELocalTrace -lSalomeCommunication #LDFLAGS+=-lmedmem -L. -lSalomeContainer -lSalomeNS -lRegistry -lOpUtil -lSalomeNotification # does we put only -lSalomeContainer and compiler retrieves -lSalomeNS -lRegistry -lOpUtil ???? diff --git a/src/MEDMEM_SWIG/libMEDMEM_Swig.i b/src/MEDMEM_SWIG/libMEDMEM_Swig.i index 70638cf17..3ca7473ab 100644 --- a/src/MEDMEM_SWIG/libMEDMEM_Swig.i +++ b/src/MEDMEM_SWIG/libMEDMEM_Swig.i @@ -1255,18 +1255,7 @@ public : PyObject *py_list; const int * connectivity = self->getConnectivity(Mode,ConnectivityType, Entity,Type); - int nbOfElm = self->getNumberOfElements(Entity,Type); - int size; - - if (Type == MED_ALL_ELEMENTS) - { - size = self->getConnectivityIndex(ConnectivityType,Entity)[nbOfElm]-1; - } - else - { - size = nbOfElm*(((int) Type)%100); - } - + int size = self->getConnectivityLength(Mode,ConnectivityType,Entity,Type); py_list = PyList_New(size); for (int i=0; i < size; i++) { @@ -1316,26 +1305,7 @@ public : PyObject *py_list; const int * reverseconnectivity = self->getReverseConnectivity(ConnectivityType,Entity); - int spaceDim = self->getSpaceDimension(); - int nb; - - if (ConnectivityType == MED_NODAL) - { - nb = (self->getNumberOfNodes()); - } - else - { - if (spaceDim == 2) - nb = (self->getNumberOfElements(MED_EDGE, - MED_ALL_ELEMENTS)); - else if (spaceDim == 3) - nb = (self->getNumberOfElements(MED_FACE, - MED_ALL_ELEMENTS)); - } - - int size = self->getReverseConnectivityIndex(ConnectivityType, - Entity)[nb]-1; - + int size = self->getReverseConnectivityLength(ConnectivityType,Entity); py_list = PyList_New(size); for (int i=0; i < size; i++) { @@ -1360,22 +1330,7 @@ public : PyObject *py_list; const int * reverseconnectivity_index = self->getReverseConnectivityIndex(ConnectivityType,Entity); - - int size; - int spaceDim = self->getSpaceDimension(); - - if (ConnectivityType == MED_NODAL) - { - size = (self->getNumberOfNodes())+1; - } - else - { - if (spaceDim == 2) - size = (self->getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS))+1; - else if (spaceDim == 3) - size = (self->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS))+1; - } - + int size=self->getReverseConnectivityIndexLength(ConnectivityType,Entity); py_list = PyList_New(size); for (int i=0; i < size; i++) { diff --git a/src/MEDMEM_SWIG/testMedMemGeneral.py b/src/MEDMEM_SWIG/testMedMemGeneral.py index e5db5c693..54e73170f 100755 --- a/src/MEDMEM_SWIG/testMedMemGeneral.py +++ b/src/MEDMEM_SWIG/testMedMemGeneral.py @@ -40,19 +40,29 @@ def add_one(i): # # med file list # +# from CODE_ASTER +# ##files.append("maill.0.med") ##meshNameFiles.append("MAILTRQU") -files.append("maillage_UniSegFam.med") -meshNameFiles.append("maillage_CHEMVAL_100elts") - -##files.append("mesh.med") -##meshNameFiles.append("Mesh 1") - ##files.append("zzzz121b.med") ##meshNameFiles.append("MUN") +# +# from the SMESH Salome Module +# + +files.append("mesh.med") +meshNameFiles.append("Mesh 1") + +# +# from other source including LGLS ones +# + +files.append("maillage_UniSegFam.med") +meshNameFiles.append("maillage_CHEMVAL_100elts") + files.append("carre_en_quad4.med") meshNameFiles.append("carre_en_quad4") @@ -389,32 +399,33 @@ for i in range(nbOfFiles): for j in range(nbElemType): print "Element",(j+1)," ",connectivity[j*nbNodesPerConst:(j+1)*nbNodesPerConst] - print "" - print "Show the Face/Edge Reverse Nodal Connectivity:" - ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL,constituent) - ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL,constituent) - print "" - for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - - print "" - try: - print "Show the Face/Edge Descending Connectivity:" - mesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent) - nbElemts = mesh.getNumberOfElements(constituent,MED_ALL_ELEMENTS) - Connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent,MED_ALL_ELEMENTS) - ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,constituent) + if (meshDim == 3): print "" - for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] + print "Show the Face/Edge Reverse Nodal Connectivity:" + ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL,constituent) + ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL,constituent) + print "" + for j in range(nbNodes): + begin = ReverseConnectivityIndex[j]-1 + end = ReverseConnectivityIndex[j+1]-1 + print "Node",(j+1),"-->",ReverseConnectivity[begin:end] print "" - except : - pass + try: + print "Show the Face/Edge Descending Connectivity:" + mesh.calculateConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent) + nbElemts = mesh.getNumberOfElements(constituent,MED_ALL_ELEMENTS) + Connectivity = mesh.getConnectivity(MED_FULL_INTERLACE,MED_DESCENDING,constituent,MED_ALL_ELEMENTS) + ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,constituent) + print "" + for j in range(nbElemts): + begin = ConnectivityIndex[j]-1 + end = ConnectivityIndex[j+1]-1 + print "Element",(j+1),"-->",Connectivity[begin:end] + + print "" + except : + pass for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: nbFam = mesh.getNumberOfFamilies(entity) @@ -537,7 +548,7 @@ for i in range(nbOfFiles): barycenter.write(idVtk) print "" - if spaceDim == 3 : + if (spaceDim == 3) and (meshDim == spaceDim) : print "Getting volume of all Cells of the mesh:" volume = mesh.getVolume(supportCell) voltot = 0. @@ -585,7 +596,7 @@ for i in range(nbOfFiles): print "but not in vtk format because vtk does not offer the possibility to view a field on edges or faces" print "" - elif spaceDim == 2: + elif (spaceDim == 2) and (meshDim == spaceDim): print "Getting area on all Cells of the mesh:" area = mesh.getArea(supportCell) areatot = 0. @@ -633,7 +644,7 @@ for i in range(nbOfFiles): print "" print "Building support on Elements of the boundary" - if spaceDim == 3 : + if (spaceDim == 3) and (meshDim == spaceDim) : suppBound = mesh.getBoundaryElements(MED_FACE) nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound @@ -645,7 +656,7 @@ for i in range(nbOfFiles): value3 = normalBoundJ[2] norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) print " * ",normalBoundJ[:spaceDim],"norm:",norm - elif spaceDim == 2: + elif (spaceDim == 2) and (meshDim == spaceDim): suppBound = mesh.getBoundaryElements(MED_EDGE) nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) print "Getting normal field on the boundary",nbElmBound diff --git a/src/Makefile.in b/src/Makefile.in index 25fc25743..e806a2374 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -31,6 +31,6 @@ VPATH=.:@srcdir@ @COMMENCE@ -SUBDIRS = MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient +SUBDIRS = MEDMEM MEDMEM_SWIG MEDMEM_I MED MEDGUI MedCorba_Swig MED_SWIG MedClient INTERPOLATION @MODULE@ diff --git a/src/MedClient/src/CONNECTIVITYClient.cxx b/src/MedClient/src/CONNECTIVITYClient.cxx index 2a33eb8ca..03d5818d5 100644 --- a/src/MedClient/src/CONNECTIVITYClient.cxx +++ b/src/MedClient/src/CONNECTIVITYClient.cxx @@ -3,6 +3,7 @@ #include "UtilClient.hxx" #include "CONNECTIVITYClient.hxx" +#include "ReceiverFactory.hxx" using namespace MEDMEM; //============================================================================= /*! @@ -50,8 +51,7 @@ CONNECTIVITYClient::~CONNECTIVITYClient() void CONNECTIVITYClient::blankCopy() { BEGIN_OF("CONNECTIVITYClient::blankCopy()"); - - SALOME_MED::MESH::connectivityInfos *all = new SALOME_MED::MESH::connectivityInfos; + SALOME_MED::MESH::connectivityInfos_var all; medEntityMesh Entity = getEntity(); try { @@ -65,7 +65,7 @@ void CONNECTIVITYClient::blankCopy() //_numberOfNodes = IOR_Mesh->getNumberOfNodes(); _numberOfNodes = all->numberOfNodes; - + _entityDimension = all->entityDimension; medGeometryElement * Types; long iT, nT; @@ -131,8 +131,7 @@ void CONNECTIVITYClient::fillCopy() int kT = Count[iT+1]-Count[iT]; SCRUTE(kT); - convertCorbaArray(pC, nC, IOR_Mesh->getConnectivity - (MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT])); + pC=(int *)ReceiverFactory::getValue(IOR_Mesh->getSenderForConnectivity(MED_FULL_INTERLACE, MED_NODAL, Entity, T[iT]),nC); SCRUTE(nC); ASSERT(nC == (T[iT]%100) * kT); diff --git a/src/MedClient/src/COORDINATEClient.cxx b/src/MedClient/src/COORDINATEClient.cxx index 2c8aa6ca9..cd9c1b3bb 100644 --- a/src/MedClient/src/COORDINATEClient.cxx +++ b/src/MedClient/src/COORDINATEClient.cxx @@ -3,6 +3,8 @@ #include "UtilClient.hxx" #include "Utils_CorbaException.hxx" +#include "ReceiverFactory.hxx" + using namespace MEDMEM; //============================================================================= /*! @@ -33,10 +35,10 @@ void COORDINATEClient::blankCopy() std::string *tA; long nA; - SALOME_MED::MESH::coordinateInfos *all = new SALOME_MED::MESH::coordinateInfos; + SALOME_MED::MESH::coordinateInfos_var all; try { - all= IOR_Mesh->getCoordGlobal(); + all = IOR_Mesh->getCoordGlobal(); } catch (const exception & ex) { @@ -78,11 +80,11 @@ void COORDINATEClient::fillCopy() long nN = IOR_Mesh->getNumberOfNodes(); double *tC; long nC; - convertCorbaArray(tC, nC, IOR_Mesh->getCoordinates(MED_FULL_INTERLACE)); + tC=(double *)ReceiverFactory::getValue(IOR_Mesh->getSenderForCoordinates(MED_FULL_INTERLACE),nC); ASSERT(nC == (getSpaceDimension() * nN)); - MEDARRAY mC(tC, getSpaceDimension(), nN); - setCoordinates(&mC); + MEDARRAY mC(tC, getSpaceDimension(), nN,MED_FULL_INTERLACE,true); + setCoordinates(&mC,true); _complete = true; diff --git a/src/MedClient/src/FIELDClient.cxx b/src/MedClient/src/FIELDClient.cxx index bc26e65ae..a859c6039 100644 --- a/src/MedClient/src/FIELDClient.cxx +++ b/src/MedClient/src/FIELDClient.cxx @@ -1,64 +1,72 @@ -#include "FIELDClient.hxx" +//#include "ReceiverFactory.hxx" -using namespace MEDMEM; +//using namespace MEDMEM; -//============================================================================= -/*! - * Transfert les valeurs du "Champ Corba" dans le "Champ local" - * (version FIELD) - */ -//============================================================================= -void FIELDClient_value(FIELD *F, const SALOME_MED::FIELD_ptr IOR_Field) +template +FIELDClient::FIELDClient(typename T2::_ptr_type ptrCorba,SUPPORT * S):_fieldPtr(T2::_duplicate(ptrCorba)),_ownSupport(false) { - BEGIN_OF("FIELDClient_value(double)"); + if (!S) + { + _ownSupport=true; + S=new SUPPORTClient(_fieldPtr->getSupport()); + } + FIELD::setSupport(S); - F->setValueType(MED_REEL64); + setName(_fieldPtr->getName()); - const SALOME_MED::FIELDDOUBLE_var IOR_FieldDouble - = SALOME_MED::FIELDDOUBLE::_narrow(IOR_Field); - SCRUTE(IOR_FieldDouble); + FIELD::setDescription(_fieldPtr->getDescription()); + int nc = _fieldPtr->getNumberOfComponents(); + FIELD::setNumberOfComponents(nc); - SALOME_MED::double_array_var v_corba - = IOR_FieldDouble->getValue(MED_FULL_INTERLACE); + FIELD::setNumberOfValues( S->getNumberOfElements(MED_ALL_ELEMENTS)); - long i, n = v_corba->length(); - SCRUTE(n); - double *v = new double[n]; + string * _s = new string[nc]; - for (i=0; i * M = new MEDARRAY - (v, F->getNumberOfComponents(),F->getNumberOfValues(), MED_FULL_INTERLACE); - F->setValue(M); + SALOME_MED::string_array_var s; + s = _fieldPtr->getComponentsNames(); + for (int i=0; i::setComponentsNames(_s); - END_OF("FIELDClient_value(double)"); -} - -//============================================================================= -/*! - * Transfert les valeurs du "Champ Corba" dans le "Champ local" - * (version FIELD) - */ -//============================================================================= -void FIELDClient_value(FIELD *F, const SALOME_MED::FIELD_ptr IOR_Field) -{ - BEGIN_OF("FIELDClient_value(int)"); + s = _fieldPtr->getComponentsDescriptions(); + for (int i=0; i::setComponentsDescriptions(_s); - F->setValueType(MED_INT32); + s = _fieldPtr->getComponentsUnits(); + for (int i=0; i::setMEDComponentsUnits(_s); - const SALOME_MED::FIELDINT_var IOR_FieldInt - = SALOME_MED::FIELDINT::_narrow(IOR_Field); + delete [] _s; - SALOME_MED::long_array_var v_corba - = IOR_FieldInt->getValue(MED_FULL_INTERLACE); +// s = _fieldPtr->getComponentsDescriptions(); +// for (int i=0; isetComponentsDescriptions(_s); + setIterationNumber(_fieldPtr->getIterationNumber()); + setTime(_fieldPtr->getTime()); + setOrderNumber(_fieldPtr->getOrderNumber()); + fillCopy(); +} - long i, n = v_corba->length(); - SCRUTE(n); - int *v = new int[n]; - for (i=0; i +void FIELDClient::fillCopy() +{ + //setValueType(typeChamps); WARNING TO DO..... + //setValueType(_fieldPtr->getValueType()); + long n; + T1 *v = (T1 *)ReceiverFactory::getValue(_fieldPtr->getSenderForValue(MED_FULL_INTERLACE),n); + MEDARRAY * M = new MEDARRAY(v, FIELD::getNumberOfComponents(),FIELD::getNumberOfValues(),MED_FULL_INTERLACE,true,true); + setValue(M); +} - MEDARRAY * M = new MEDARRAY - (v, F->getNumberOfComponents(),F->getNumberOfValues(), MED_FULL_INTERLACE); - F->setValue(M); - - END_OF("FIELDClient_value(int)"); +template +FIELDClient::~FIELDClient() +{ + _fieldPtr->release(); + CORBA::release(_fieldPtr); + if(_ownSupport) + delete FIELD::_support; } + diff --git a/src/MedClient/src/FIELDClient.hxx b/src/MedClient/src/FIELDClient.hxx index f5a476b83..08cf70ce1 100644 --- a/src/MedClient/src/FIELDClient.hxx +++ b/src/MedClient/src/FIELDClient.hxx @@ -5,63 +5,24 @@ #include #include "MEDMEM_Field.hxx" #include "SUPPORTClient.hxx" +#include "ReceiverFactory.hxx" #include CORBA_CLIENT_HEADER(MED) - - - -void FIELDClient_value(FIELD *F, - const SALOME_MED::FIELD_ptr IOR_Field); -void FIELDClient_value(FIELD *F, - const SALOME_MED::FIELD_ptr IOR_Field); - - -template -FIELD * FIELDClient(const SALOME_MED::FIELD_ptr IOR_Field, - SUPPORT * S = NULL) +//exemple _FIELDClient +//_FIELDClient +template +class FIELDClient : public FIELD { - BEGIN_OF("FIELDClient"); - - if (!S) S = new SUPPORTClient(IOR_Field->getSupport()); - - FIELD *F = new FIELD(); - F->setSupport(S); - - F->setName(IOR_Field->getName()); - SCRUTE(F->getName()); - - F->setDescription(IOR_Field->getDescription()); - SCRUTE(F->getDescription()); - - int nc = IOR_Field->getNumberOfComponents(); - F->setNumberOfComponents(nc); - SCRUTE(F->getNumberOfComponents()); - - F->setNumberOfValues(nc * S->getNumberOfElements(MED_ALL_ELEMENTS)); - SCRUTE(F->getNumberOfValues()); - - string * _s = new string[nc]; - - SALOME_MED::string_array_var s; - - s = IOR_Field->getComponentsNames(); - for (int i=0; isetComponentsNames(_s); - -// s = IOR_Field->getComponentsDescriptions(); -// for (int i=0; isetComponentsDescriptions(_s); - - F->setIterationNumber(IOR_Field->getIterationNumber()); - F->setTime(IOR_Field->getTime()); - F->setOrderNumber(IOR_Field->getOrderNumber()); - - FIELDClient_value(F, IOR_Field); - - END_OF("FIELDClient"); - return F; -} +private: + typename T2::_ptr_type _fieldPtr; + bool _ownSupport; +public: + FIELDClient(typename T2::_ptr_type ptrCorba,SUPPORT * S = NULL); + ~FIELDClient(); +private: + void fillCopy(); +}; + +#include "FIELDClient.cxx" #endif diff --git a/src/MedClient/src/FIELDDOUBLEClient.cxx b/src/MedClient/src/FIELDDOUBLEClient.cxx new file mode 100644 index 000000000..3428c2101 --- /dev/null +++ b/src/MedClient/src/FIELDDOUBLEClient.cxx @@ -0,0 +1,26 @@ +#include "FIELDDOUBLEClient.hxx" + +//============================================================================= +/*! + * Constructor with arguments + */ +//============================================================================= +FIELDDOUBLEClient::FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba, + SUPPORT * S) : + FIELDClient(ptrCorba,S) +{ + BEGIN_OF("Constructor with arguments (for Python API) FIELDDOUBLEClient"); + + END_OF("Constructor with arguments (for Python API) FIELDDOUBLEClient"); +} +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +FIELDDOUBLEClient::~FIELDDOUBLEClient() +{ + BEGIN_OF("Default Destructor (for Python API) FIELDDOUBLEClient"); + + END_OF("Default Destructor (for Python API) FIELDDOUBLEClient"); +} diff --git a/src/MedClient/src/FIELDDOUBLEClient.hxx b/src/MedClient/src/FIELDDOUBLEClient.hxx new file mode 100644 index 000000000..61252201a --- /dev/null +++ b/src/MedClient/src/FIELDDOUBLEClient.hxx @@ -0,0 +1,15 @@ +#ifndef _FIELDDOUBLECLIENT_HXX +#define _FIELDDOUBLECLIENT_HXX + +#include "FIELDClient.hxx" + +class FIELDDOUBLEClient : + public FIELDClient +{ +public: + FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba, + SUPPORT * S = NULL); + ~FIELDDOUBLEClient(); +}; + +#endif diff --git a/src/MedClient/src/FIELDINTClient.cxx b/src/MedClient/src/FIELDINTClient.cxx new file mode 100644 index 000000000..756156dd8 --- /dev/null +++ b/src/MedClient/src/FIELDINTClient.cxx @@ -0,0 +1,26 @@ +#include "FIELDINTClient.hxx" + +//============================================================================= +/*! + * Constructor with arguments + */ +//============================================================================= +FIELDINTClient::FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba, + SUPPORT * S) : + FIELDClient(ptrCorba,S) +{ + BEGIN_OF("Constructor with arguments (for Python API) FIELDINTClient"); + + END_OF("Constructor with arguments (for Python API) FIELDINTClient"); +} +//============================================================================= +/*! + * Destructor + */ +//============================================================================= +FIELDINTClient::~FIELDINTClient() +{ + BEGIN_OF("Default Destructor (for Python API) FIELDINTClient"); + + END_OF("Default Destructor (for Python API) FIELDINTClient"); +} diff --git a/src/MedClient/src/FIELDINTClient.hxx b/src/MedClient/src/FIELDINTClient.hxx new file mode 100644 index 000000000..60de96c30 --- /dev/null +++ b/src/MedClient/src/FIELDINTClient.hxx @@ -0,0 +1,15 @@ +#ifndef _FIELDINTCLIENT_HXX +#define _FIELDINTCLIENT_HXX + +#include "FIELDClient.hxx" + +class FIELDINTClient : + public FIELDClient +{ +public: + FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba, + SUPPORT * S = NULL); + ~FIELDINTClient(); +}; + +#endif diff --git a/src/MedClient/src/MESHClient.cxx b/src/MedClient/src/MESHClient.cxx index cb310f915..8fa64f3b2 100644 --- a/src/MedClient/src/MESHClient.cxx +++ b/src/MedClient/src/MESHClient.cxx @@ -55,8 +55,7 @@ GROUP * convertGroup(const SALOME_MED::GROUP_ptr &F, MESH *M) void MESHClient::blankCopy() { BEGIN_OF("MESHClient::blankCopy()"); - SALOME_MED::MESH::meshInfos * all = new SALOME_MED::MESH::meshInfos; - all = IOR_Mesh->getMeshGlobal(); + SALOME_MED::MESH::meshInfos_var all = IOR_Mesh->getMeshGlobal(); //CORBA::String_var s; //s= IOR_Mesh->getName(); _name = s; @@ -165,6 +164,7 @@ void MESHClient::fillCopy() MESHClient::~MESHClient() { BEGIN_OF("MESHClient::~MESHClient()"); + IOR_Mesh->release(); END_OF("MESHClient::~MESHClient()"); } diff --git a/src/MedClient/src/Makefile.in b/src/MedClient/src/Makefile.in index 04ae09a31..f1326db2f 100644 --- a/src/MedClient/src/Makefile.in +++ b/src/MedClient/src/Makefile.in @@ -43,6 +43,9 @@ EXPORT_HEADERS = \ FAMILYClient.hxx \ GROUPClient.hxx \ FIELDClient.hxx \ + FIELDClient.cxx \ + FIELDDOUBLEClient.hxx \ + FIELDINTClient.hxx \ libMEDClient.i SWIG_DEF = libMEDClient.i @@ -58,14 +61,16 @@ LIB_SRC = \ MESHClient.cxx \ SUPPORTClient.cxx \ FAMILYClient.cxx \ - FIELDClient.cxx \ - GROUPClient.cxx + GROUPClient.cxx \ + FIELDDOUBLEClient.cxx \ + FIELDINTClient.cxx LIB_CLIENT_IDL= \ SALOME_Component.idl \ SALOMEDS.idl \ SALOMEDS_Attributes.idl \ SALOME_Exception.idl \ + SALOME_Comm.idl \ MED.idl # Executables targets diff --git a/src/MedClient/src/MakefileForTest b/src/MedClient/src/MakefileForTest new file mode 100644 index 000000000..079683ab3 --- /dev/null +++ b/src/MedClient/src/MakefileForTest @@ -0,0 +1,52 @@ +IDL = TESTMEDCLIENT_Gen.idl + +INC_IDL = $(patsubst %.idl,%.hh, $(IDL)) + +OBJ = TESTMEDCLIENT_GenSK.o TESTMEDCLIENT_Gen_i.o MemorySpy.o + +INC = -I$(KERNEL_ROOT_DIR)/include/salome -I$(MED_ROOT_DIR)/include/salome + +LINK = -L$(MED_ROOT_DIR)/lib/salome -lmedmem -lMEDClientcmodule -lMedCorba_Swigcmodule + +OPT = -D__x86__ -D__linux__ -DPCLINUX -DCOMPAT_DOUBLE_CORBA_DOUBLE + +OPTIONIDL = -bcxx -Wbexample + +INCIDL= -I$(KERNEL_ROOT_DIR)/idl/salome -I$(MED_ROOT_DIR)/idl/salome + +OMNIIDL = omniidl + +all : libTESTMEDCLIENTEngine.so TESTMEDCLIENTCatalog.xml pyTESTMEDCLIENT + +libTESTMEDCLIENTEngine.so : $(OBJ) + g++ -shared $(OBJ) $(LINK) -o $@ + mv $@ lib/salome + +pyTESTMEDCLIENT : TESTMEDCLIENT_Gen.idl + omniidl -bpython $(INCIDL) $< + rm -rf lib/python2.2/site-packages/salome/* + mv SALOME_TESTMEDCLIENT SALOME_TESTMEDCLIENT__POA TESTMEDCLIENT_Gen_idl.py lib/python2.2/site-packages/salome + +TESTMEDCLIENTCatalog.xml : TESTMEDCLIENT_Gen.idl + omniidl -bIDLparser $(INCIDL) -Wbcatalog=$@,name='TESTMEDCLIENT',username='TESTMEDCLIENT' $^ + sed -e 's/TESTMEDCLIENT_Gen/TESTMEDCLIENT/g' $@ > toto + mv toto ./share/salome/resources/$@ + rm *.xml + +TESTMEDCLIENT_GenSK.o : $(INC_IDL) TESTMEDCLIENT_GenSK.cc + g++ -c $(INC) $(OPT) -Wno-deprecated TESTMEDCLIENT_GenSK.cc -o $@ + +%.o : %.cxx %.hxx $(INC_IDL) + g++ -c $(INC) $(OPT) -Wno-deprecated $< -o $@ + +%.o : %.cc $(INC_IDL) + g++ -c $(INC) $(OPT) -Wno-deprecated $< -o $@ + +%.hh : %.idl + $(OMNIIDL) $(OPTIONIDL) $(INCIDL) $< + +%.cc : %.idl + $(OMNIIDL) $(OPTIONIDL) $(INCIDL) $< + +clean: + rm -f *.o *.so *.hh *.cc *.xml diff --git a/src/MedClient/src/MemorySpy.cxx b/src/MedClient/src/MemorySpy.cxx new file mode 100644 index 000000000..cbf49de82 --- /dev/null +++ b/src/MedClient/src/MemorySpy.cxx @@ -0,0 +1,96 @@ +#include "MemorySpy.hxx" + +#ifdef PCLINUX +#include +#include + +#define MAXMEM 7 + +MemorySpy::MemorySpy() +{ + _currentPid=getpid(); + _sizeofPage=getpagesize(); + char workStr[38]; + sprintf( workStr, "/proc/%d/statm", _currentPid); + _statmFile=fopen ( workStr, "r" ); +} + +MemorySpy::~MemorySpy() +{ + if(_statmFile) + free(_statmFile); +} + +long MemorySpy::getCurrentMemoryUsage() +{ + if (!_statmFile) + return -1; + fseek( _statmFile, 0L, 0 ); + char workStr[52]; + if(!fread( workStr, 1, 50, _statmFile )) + return -1; + return parseString(workStr); +} + +long MemorySpy::parseString(char* line) +{ + char *po, *po2,hstr[0x100]; + int i; + long tab[MAXMEM]; + + memset( hstr, 0, sizeof( hstr )); + po2 = hstr; + po = line; + i = 0; + while ( *po != 0x0 ) + { + if ( ( *po != 0x20 ) ) + { + *po2 = *po; + po++; + po2++; + } + else + { + tab[i] = atol( hstr ) * _sizeofPage; + i++; + memset( hstr, 0, sizeof( hstr )); + while ( *po != 0x0 ) + { + if ( ( *po != 0x20 )&&( *po != '\n' ) ) + break; + po++; + } + po2 = hstr; + } + } + if ( strlen( hstr ) != 0 ) + { + tab[i] = atol( hstr ) * _sizeofPage; + } + return tab[0]; +} +#endif + +#ifdef HP +#include +#include +#include + +MemorySpy::MemorySpy() +{ +} + +MemorySpy::~MemorySpy() +{ +} + +long MemorySpy::getCurrentMemoryUsage() +{ + struct pst_dynamic dyn; + if (pstat_getdynamic(&dyn, sizeof(dyn), 1, 0) == -1) + return -1; + else { + return dyn.psd_vm * getpagesize(); +} +#endif diff --git a/src/MedClient/src/MemorySpy.hxx b/src/MedClient/src/MemorySpy.hxx new file mode 100644 index 000000000..0293621fc --- /dev/null +++ b/src/MedClient/src/MemorySpy.hxx @@ -0,0 +1,25 @@ +#ifndef __MEMORYSPY_HXX__ +#define __MEMORYSPY_HXX__ + +#include +#include + +class MemorySpy +{ +public: + MemorySpy(); + ~MemorySpy(); + long getCurrentMemoryUsage(); +#ifdef PCLINUX + //SOLARIS +private: + long parseString(char* line); +private: + int _currentPid; + long _sizeofPage; + FILE *_statmFile; +#endif +}; + +#endif + diff --git a/src/MedClient/src/README_medclient_test b/src/MedClient/src/README_medclient_test new file mode 100644 index 000000000..f6a0956f4 --- /dev/null +++ b/src/MedClient/src/README_medclient_test @@ -0,0 +1,35 @@ +TEST en construction... + +TEST des classes MedClient : +---------------------------- + +- FieldClient +- MeshClient +- SupportClient +- FamilyClient +- GroupClient + +Le test utilise un composant nommé TESTMEDCLIENT qui tire à distance sur des objets MEDMEM en utilisant les classes MedClient. + +Le test repose sur l'echange d'information entre le composant MED et le composant TESTMEDClient. + +Les objets MEDMEM (Mesh, Field, Support), plus ou moins volumineux, sont obtenus à partir des executables de générations de fichiers MED. +Ces executables sont abetenus apres compilation des fichiers : + - create_mesh_c2q4.c + - create_mesh_c2t3.c + - create_mesh_c3h8.c + - create_mesh_c2t4.c + +Le test chasse les fuites mémoires grace à un espion de mémoire dont le code est contenu dans : + - MemorySpy.hxx + - MemorySpy.cxx + +Le code du composant se trouve dans les fichiers : + - TESTMEDCLIENT_Gen.idl + - TESTMEDCLIENT_Gen_i.hxx + - TESTMEDCLIENT_Gen_i.cxx + +Le lancement du test est effectué par le script python : + - test_medclient.py + +Enfin MakefileForTest est une ébauche de Makefile nécessaire pour compiler completement le nouveau composant. \ No newline at end of file diff --git a/src/MedClient/src/SUPPORTClient.cxx b/src/MedClient/src/SUPPORTClient.cxx index 83b573981..0ed41de8d 100644 --- a/src/MedClient/src/SUPPORTClient.cxx +++ b/src/MedClient/src/SUPPORTClient.cxx @@ -2,6 +2,7 @@ #include "UtilClient.hxx" #include "SUPPORTClient.hxx" #include "MESHClient.hxx" +#include "ReceiverFactory.hxx" using namespace MEDMEM; @@ -14,15 +15,20 @@ using namespace MEDMEM; SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S, MESH * M) : SUPPORT(), - IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)) + IOR_Support(SALOME_MED::SUPPORT::_duplicate(S)), + _ownMesh(false) { BEGIN_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)"); SCRUTE(S); SCRUTE(M); - - setMesh(M ? M : new MESHClient(IOR_Support->getMesh())); - + if(M) + _mesh=M; + else + { + _mesh=new MESHClient(IOR_Support->getMesh()); + _ownMesh=true; + } blankCopy(); END_OF("SUPPORTClient::SUPPORTClient(SALOME_MED::SUPPORT_ptr m)"); @@ -38,8 +44,7 @@ void SUPPORTClient::blankCopy() try { - SALOME_MED::SUPPORT::supportInfos *all = new SALOME_MED::SUPPORT::supportInfos; - all= IOR_Support->getSupportGlobal(); + SALOME_MED::SUPPORT::supportInfos_var all = IOR_Support->getSupportGlobal(); _name = all->name; _description = all->description; @@ -67,6 +72,9 @@ void SUPPORTClient::blankCopy() nE[i] = all->nbEltTypes[i]; } setNumberOfElements(nE); + + delete [] nE; + SCRUTE(_totalNumberOfElements); _complete_support = false; } @@ -91,20 +99,15 @@ void SUPPORTClient::fillCopy() if (!_complete_support) { - int * index, * value; + const int * index, * value; long n_index, n_value; - convertCorbaArray(value, n_value, - IOR_Support->getNumber(MED_ALL_ELEMENTS)); - convertCorbaArray(index, n_index, - IOR_Support->getNumberIndex()); + value=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS),n_value); + index=(const int *)ReceiverFactory::getValue(IOR_Support->getSenderForNumberIndex(),n_index); SCRUTE(n_index); SCRUTE(n_value); - setNumber(index, value); - - delete [] index; - delete [] value; + setNumber(index, value,true); _complete_support = true; } @@ -119,7 +122,9 @@ void SUPPORTClient::fillCopy() SUPPORTClient::~SUPPORTClient() { BEGIN_OF("SUPPORTClient::~SUPPORTClient"); - + IOR_Support->release(); + if(_ownMesh) + delete _mesh; END_OF("SUPPORTClient::~SUPPORTClient"); } diff --git a/src/MedClient/src/SUPPORTClient.hxx b/src/MedClient/src/SUPPORTClient.hxx index 4018cfed9..24aa4cb9f 100644 --- a/src/MedClient/src/SUPPORTClient.hxx +++ b/src/MedClient/src/SUPPORTClient.hxx @@ -14,6 +14,8 @@ private : const SALOME_MED::SUPPORT_var IOR_Support; + bool _ownMesh; + mutable bool _complete_support; public : diff --git a/src/MedClient/src/TESTMEDCLIENT_Gen.idl b/src/MedClient/src/TESTMEDCLIENT_Gen.idl new file mode 100644 index 000000000..b9559f6b4 --- /dev/null +++ b/src/MedClient/src/TESTMEDCLIENT_Gen.idl @@ -0,0 +1,18 @@ +#ifndef _TESTMEDCLIENT_GEN_IDL_ +#define _TESTMEDCLIENT_GEN_IDL_ + +#include "SALOME_Exception.idl" +#include "SALOME_Component.idl" +#include "SALOMEDS.idl" +#include "MED.idl" + +module SALOME_TESTMEDCLIENT +{ + interface TESTMEDCLIENT_Gen : Engines::Component + { + void go(in SALOME_MED::MED objMed); + void go2(in SALOME_MED::MED objMed); + }; +}; + +#endif diff --git a/src/MedClient/src/TESTMEDCLIENT_Gen_i.cxx b/src/MedClient/src/TESTMEDCLIENT_Gen_i.cxx new file mode 100755 index 000000000..b96c87e6d --- /dev/null +++ b/src/MedClient/src/TESTMEDCLIENT_Gen_i.cxx @@ -0,0 +1,174 @@ +#define private public +#define protected public +#include "TESTMEDCLIENT_Gen_i.hxx" +#include "MESHClient.hxx" +#include "FIELDClient.hxx" +#include "MEDMEM_Support.hxx" +#include "MEDMEM_Field.hxx" + +#include "MEDMEM_Family.hxx" +#include "FAMILYClient.hxx" +#include "MEDMEM_Field.hxx" +#include "MEDMEM_Array.hxx" +#include "MEDMEM_PointerOf.hxx" + +#include "MemorySpy.hxx" + +using namespace std; + +extern "C" +{ + PortableServer::ObjectId *TESTMEDCLIENTEngine_factory(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName) + { + TESTMEDCLIENT_Gen_i *ret=new TESTMEDCLIENT_Gen_i(orb,poa,contId,instanceName,interfaceName); + return ret->getId(); + } +} + +TESTMEDCLIENT_Gen_i::TESTMEDCLIENT_Gen_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName):Engines_Component_i(orb,poa,contId,instanceName,interfaceName) +{ + _thisObj = this ; + _id = _poa->activate_object(_thisObj); +} + +TESTMEDCLIENT_Gen_i::~TESTMEDCLIENT_Gen_i() +{ +} + +void TESTMEDCLIENT_Gen_i::go(SALOME_MED::MED_ptr objMed) +{ + cerr << "Begin of test 1" << endl; + SALOME_MED::MESH_ptr maillagePtr=objMed->getMeshByName("CUBE_EN_HEXA8_QUAD4"); + MESHClient mesh(maillagePtr); + maillagePtr->setProtocol(SALOME::SOCKET_); + mesh.fillCopy(); + + long n=mesh.getNumberOfNodes(); + long dim=mesh.getMeshDimension(); + cout << "Mesh nodes nb :" << n << " dim : " << dim << endl; + const double *tabRet=mesh.getCoordinates(MED_NO_INTERLACE); + for(int k=0;kgetNumberOfElements(MED_QUAD4); + FIELD* fd=mesh.getArea(sup1); + delete sup1; + int nbOfVal=fd->getNumberOfValues(); + int nbOfCpt=fd->getNumberOfComponents(); + cout << "nbOfVal " << nbOfVal << " nbOfCpt " << nbOfCpt << endl; + const double *tabAera=fd->getValue(MED_NO_INTERLACE); + for(int m=0;mgetnumber(); + cout << "const MEDSKYLINEARRAY *numb" << endl; + cout << "Length of : " << numb->getLength() << endl; + const int *vec2=numb->getValue(); + for(int m=0;mgetLength();m++) + { + cout << vec2[m] << " " << endl; + } + const vector groups=mesh.getGroups(MED_FACE); + cout << "Nb Of FACES groups :" << groups.size() << endl; + const int * tabConec=mesh.getConnectivity(MED_FULL_INTERLACE,MED_NODAL,MED_FACE,MED_QUAD4); + for(int p=0;pgetFieldNames(); + for(int r=0;rlength();r++) + cout << (*strArray)[r] << endl; + SALOME_MED::FIELD_var myField=objMed->getField((*strArray)[1],2,-1); + if(myField==SALOME_MED::FIELD::_nil()) + cout << "big problem ... " << endl; + SALOME_MED::FIELDDOUBLE_ptr myFieldD=SALOME_MED::FIELDDOUBLE::_narrow(myField); + if(myFieldD==SALOME_MED::FIELDDOUBLE::_nil()) + cout << "not fielddouble " << (*strArray)[1] << endl; + FIELDClient myFieldDouble(myFieldD); + delete strArray; + const SUPPORT *supField=myFieldDouble.getSupport(); + int nbOfValField=supField->getNumberOfElements(MED_NONE); + + const double * values = myFieldDouble.getValue(MED_FULL_INTERLACE); + for(int r2=0;r2getMeshNames(); + cout << strA[0] << endl; + SALOME_MED::MESH_ptr maillagePtr; + MemorySpy spy; + cout << "Mem0 : " << spy.getCurrentMemoryUsage() << endl; + maillagePtr=objMed->getMeshByName("cube_tetra4"); + MESHClient* mesh=new MESHClient(maillagePtr); + cout << "Mem1 : " << spy.getCurrentMemoryUsage() << endl; + mesh->fillCopy(); + cout << "Mem2 : " << spy.getCurrentMemoryUsage() << endl; + delete mesh; + cout << "Mem3 : " << spy.getCurrentMemoryUsage() << endl; + SALOME_MED::string_array_var strB=objMed->getFieldNames(); + cout << "________________" << endl; + cout << "il y a " << strB->length() << " champs" << endl; + for(int i=0;ilength();i++) + cout << strB[i] << endl; + cout << "Field beeing get " << strB[0] << endl; + SALOME_MED::FIELD_var myField=objMed->getField(strB[0],-1,-1); + SALOME_MED::FIELDDOUBLE_ptr myFieldD=SALOME_MED::FIELDDOUBLE::_narrow(myField); + if(myFieldD==SALOME_MED::FIELDDOUBLE::_nil()) + cout << "not fielddouble " << strB[0] << endl; + else + cout << "Field " << strB[0] << " is double" << endl; + //myFieldD->setProtocol(SALOME::MPI_); + FIELDClient *myFieldDouble=new FIELDClient(myFieldD); + cout << "Mem3bis : " << spy.getCurrentMemoryUsage() << endl; + const SUPPORT *supField=myFieldDouble->getSupport(); + int nbOfValField=supField->getNumberOfElements(MED_TETRA4); + + cout << "Mem4 : " << spy.getCurrentMemoryUsage() << endl; + const double * values = myFieldDouble->getValue(MED_FULL_INTERLACE); +// values= myFieldDouble->getValue(MED_FULL_INTERLACE); +// const MEDARRAY* valAr=myFieldDouble->getvalue(); +// double* ptOf=valAr->_valuesNo._pointer; +// double* ptOf2=valAr->_valuesFull._pointer; + cout << "Mem5 : " << spy.getCurrentMemoryUsage() << " -- " << myFieldDouble->getNumberOfComponents() << " " << nbOfValField << endl; +// cout << valAr->_ldValues << " " << valAr->_lengthValues << endl; + for(int r2=0;r2getNumberOfComponents()*nbOfValField;r2++) + { +// for(int r2j=0;r2j 100.0)) + cout << val << " "; + } + } + delete myFieldDouble; + cout << "Mem6 : " << spy.getCurrentMemoryUsage() << endl; +} diff --git a/src/MedClient/src/TESTMEDCLIENT_Gen_i.hxx b/src/MedClient/src/TESTMEDCLIENT_Gen_i.hxx new file mode 100644 index 000000000..fb9b44d9e --- /dev/null +++ b/src/MedClient/src/TESTMEDCLIENT_Gen_i.hxx @@ -0,0 +1,24 @@ +#ifndef _TESTMEDCLIENT_GEN_I_HXX_ +#define _TESTMEDCLIENT_GEN_I_HXX_ + +#include +#include +#include "SALOME_Component_i.hxx" + +class TESTMEDCLIENT_Gen_i : + public virtual POA_SALOME_TESTMEDCLIENT::TESTMEDCLIENT_Gen, + public virtual Engines_Component_i +{ +public: + TESTMEDCLIENT_Gen_i(CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa, + PortableServer::ObjectId * contId, + const char *instanceName, + const char *interfaceName); + virtual ~TESTMEDCLIENT_Gen_i(); + + void go(SALOME_MED::MED_ptr objMed); + void go2(SALOME_MED::MED_ptr objMed); +}; + +#endif diff --git a/src/MedClient/src/create_mesh_c2q4.c b/src/MedClient/src/create_mesh_c2q4.c new file mode 100644 index 000000000..e52f80738 --- /dev/null +++ b/src/MedClient/src/create_mesh_c2q4.c @@ -0,0 +1,332 @@ +/* + creation d'une geometrie 2d : un cube [0,1]^2 + maillé uniformement en quadrangle reguliers; + avec n (=argv[1]) noeuds dans chaque direction. + 2 champs: + - DbleVectNode champ vectoriel reel sur les noeuds + - DbleVectCell champ vectoriel reel sur les cellules + + En sortie, il y aura production d'un fichier MED + carre_quad4_n.med qui contiendra un seul maillage et 2 champs + avec une seule famille la FAMILLE_0 +*/ + +#include +#include +#include + +#include + +int main (int argc, char **argv) +{ + med_err ret; + med_idt fid; + char maa[MED_TAILLE_NOM+1] = "carre_quad4"; + med_int mdim = 2; + int nnoe_dir; + int nelt_dir; + med_int nnoe; + int i, j, ij; + + med_float * coo; + med_int * numnoe; + med_int * nufano; + + med_float hxsize; + med_float hysize; + + med_float * DbleVectNode; + med_float * DbleVectCell; + + time_t t1; + + /* + Le maillage + */ + + char nomcoo[2*MED_TAILLE_PNOM+1] = "x y "; + char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm "; + /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ + char *nomnoe ; + + med_int nquad4; + med_int * quad4; + med_int * numquad4; + med_int * nufaquad4; + /* char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 ";*/ + char * nomquad4; + int indexN1, indexN2, indexN3, indexN4; + + char nomfam[MED_TAILLE_NOM+1]; + med_int numfam; + char attdes[MED_TAILLE_DESC+1]; + med_int natt; + med_int attide; + med_int attval; + med_int ngro; + char gro[MED_TAILLE_LNOM+1]; + int nfame = 0; + int nfamn = 0; + + char MedFile[100] = "carre_quad4_"; + char buff[100]; + + /* + Les champs + */ + + char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode"; + char compDbleVectNode[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ; + char unitDbleVectNode[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ; + + char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell"; + char compDbleVectCell[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ; + char unitDbleVectCell[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ; + + if (argc != 2) + { + printf("Usage: %s \n",argv[0]); + printf(" where\n"); + printf(" - n is the number of nodes in each direction.\n"); + printf("\n"); + printf("This program will produce a MED file carre_quad4_n.med\n"); + exit(0); + } + + nnoe_dir = atoi(argv[1]); + nelt_dir = nnoe_dir-1; + nnoe = nnoe_dir*nnoe_dir; + + coo = malloc(mdim*nnoe*sizeof(med_float)); + numnoe = malloc(nnoe*sizeof(med_int)); + nufano = malloc(nnoe*sizeof(med_int)); + nomnoe = malloc((MED_TAILLE_PNOM*nnoe+1)*sizeof(char)); + + hxsize = 1./((med_float) (nnoe_dir - 1)); + hysize = hxsize; + + nquad4 = nelt_dir*nelt_dir; + quad4 = malloc(4*nquad4*sizeof(med_int)); + numquad4 = malloc(nquad4*sizeof(med_int)); + nufaquad4 = malloc(nquad4*sizeof(med_int)); + nomquad4 = malloc((MED_TAILLE_PNOM*nquad4+1)*sizeof(char)); + + DbleVectNode = malloc(mdim*nnoe*sizeof(med_float)); + DbleVectCell = malloc(mdim*nquad4*sizeof(med_float)); + + /* + les noeuds: + */ + + for(j=0;j 0 + - les numeros de familles des elements sont < 0 + - rien d'imposer sur les noms de familles + */ + + /* la famille 0 */ + if (ret == 0) + { + strcpy(nomfam,"FAMILLE_0"); + numfam = 0; + ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0, + gro,0); + } + printf("%d \n",ret); + + /***************************************************************************/ + /* + Les Champs + */ + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode, + unitDbleVectNode,mdim); + + printf("MEDchampCr DbleVectNode : %d \n",ret); + + if (ret == 0) + { + ret = MEDchampEcr(fid, maa, champDbleVectNode, + (unsigned char *)DbleVectNode, + MED_NO_INTERLACE, nnoe, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, + 0, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectNode : %d \n",ret); + } + } + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell, + unitDbleVectCell,mdim); + + printf("MEDchampCr DbleVectCell : %d \n",ret); + + if (ret == 0) + { + ret = MEDchampEcr(fid, maa, champDbleVectCell, + (unsigned char *)DbleVectCell, + MED_NO_INTERLACE, nquad4, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_QUAD4, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectCell : %d \n",ret); + } + } + + /***************************************************************************/ + + ret = MEDfermer(fid); + printf("%d\n",ret); + + free(coo); + free(numnoe); + free(nufano); + free(nomnoe); + free(quad4); + free(numquad4); + free(nufaquad4); + free(nomquad4); + free(DbleVectNode); + free(DbleVectCell); + + return 0; +} + diff --git a/src/MedClient/src/create_mesh_c2t3.c b/src/MedClient/src/create_mesh_c2t3.c new file mode 100644 index 000000000..22036cae6 --- /dev/null +++ b/src/MedClient/src/create_mesh_c2t3.c @@ -0,0 +1,341 @@ +/* + creation d'une geometrie 2d : un cube [0,1]^2 + maillé uniformement en triangles reguliers; + avec n (=argv[1]) noeuds dans chaque direction. + 2 champs: + - DbleVectNode champ vectoriel reel sur les noeuds + - DbleVectCell champ vectoriel reel sur les cellules + + En sortie, il y aura production d'un fichier MED + carre_tria3_n.med qui contiendra un seul maillage et 2 champs + avec une seule famille la FAMILLE_0 +*/ + +#include +#include +#include + +#include + +int main (int argc, char **argv) +{ + med_err ret; + med_idt fid; + char maa[MED_TAILLE_NOM+1] = "carre_tria3"; + med_int mdim = 2; + int nnoe_dir; + int nelt_dir; + med_int nnoe; + int i, j, ij; + + med_float * coo; + med_int * numnoe; + med_int * nufano; + + med_float hxsize; + med_float hysize; + + med_float * DbleVectNode; + med_float * DbleVectCell; + + time_t t1; + + /* + Le maillage + */ + + char nomcoo[2*MED_TAILLE_PNOM+1] = "x y "; + char unicoo[2*MED_TAILLE_PNOM+1] = "cm cm "; + /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ + char *nomnoe ; + + med_int ntria3; + med_int * tria3; + med_int * numtria3; + med_int * nufatria3; + char * nomtria3; + int indexN1, indexN2, indexN3, indexN4; + + char nomfam[MED_TAILLE_NOM+1]; + med_int numfam; + char attdes[MED_TAILLE_DESC+1]; + med_int natt; + med_int attide; + med_int attval; + med_int ngro; + char gro[MED_TAILLE_LNOM+1]; + int nfame = 0; + int nfamn = 0; + + char MedFile[100] = "carre_tria3_"; + char buff[100]; + + /* + Les champs + */ + + char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode"; + char compDbleVectNode[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ; + char unitDbleVectNode[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ; + + char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell"; + char compDbleVectCell[MED_TAILLE_PNOM*2+1] = "comp1 comp2 " ; + char unitDbleVectCell[MED_TAILLE_PNOM*2+1] = "unit1 unit2 " ; + + if (argc != 2) + { + printf("Usage: %s \n",argv[0]); + printf(" where\n"); + printf(" - n is the number of nodes in each direction.\n"); + printf("\n"); + printf("This program will produce a MED file carre_tria3_n.med\n"); + exit(0); + } + + nnoe_dir = atoi(argv[1]); + nelt_dir = nnoe_dir-1; + nnoe = nnoe_dir*nnoe_dir; + + coo = malloc(mdim*nnoe*sizeof(med_float)); + numnoe = malloc(nnoe*sizeof(med_int)); + nufano = malloc(nnoe*sizeof(med_int)); + nomnoe = malloc((MED_TAILLE_PNOM*nnoe+1)*sizeof(char)); + + hxsize = 1./((med_float) (nnoe_dir - 1)); + hysize = hxsize; + + ntria3 = 2*nelt_dir*nelt_dir; + tria3 = malloc(3*ntria3*sizeof(med_int)); + numtria3 = malloc(ntria3*sizeof(med_int)); + nufatria3 = malloc(ntria3*sizeof(med_int)); + nomtria3 = malloc((MED_TAILLE_PNOM*ntria3+1)*sizeof(char)); + + DbleVectNode = malloc(mdim*nnoe*sizeof(med_float)); + DbleVectCell = malloc(mdim*ntria3*sizeof(med_float)); + + /* + les noeuds: + */ + + for(j=0;j 0 + - les numeros de familles des elements sont < 0 + - rien d'imposer sur les noms de familles + */ + + /* la famille 0 */ + if (ret == 0) + { + strcpy(nomfam,"FAMILLE_0"); + numfam = 0; + ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0, + gro,0); + } + printf("%d \n",ret); + + /***************************************************************************/ + /* + Les Champs + */ + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode, + unitDbleVectNode,mdim); + + printf("MEDchampCr DbleVectNode : %d \n",ret); + + if (ret == 0) + { + ret = MEDchampEcr(fid, maa, champDbleVectNode, + (unsigned char *)DbleVectNode, + MED_NO_INTERLACE, nnoe, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, + 0, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectNode : %d \n",ret); + } + } + + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell, + unitDbleVectCell,mdim); + + printf("MEDchampCr DbleVectCell : %d \n",ret); + + if (ret == 0) + { + ret = MEDchampEcr(fid, maa, champDbleVectCell, + (unsigned char *)DbleVectCell, + MED_NO_INTERLACE, ntria3, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_TRIA3, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectCell : %d \n",ret); + } + } + + /***************************************************************************/ + + ret = MEDfermer(fid); + printf("%d\n",ret); + + free(coo); + free(numnoe); + free(nufano); + free(nomnoe); + free(tria3); + free(numtria3); + free(nufatria3); + free(nomtria3); + free(DbleVectNode); + free(DbleVectCell); + + return 0; +} diff --git a/src/MedClient/src/create_mesh_c3h8.c b/src/MedClient/src/create_mesh_c3h8.c new file mode 100644 index 000000000..8ff563f45 --- /dev/null +++ b/src/MedClient/src/create_mesh_c3h8.c @@ -0,0 +1,358 @@ +/* + creation d'une geometrie 3d : un cube [0,1]^3 + maillé uniformement en hexahedres reguliers; + avec n (=argv[1]) noeuds dans chaque direction. + 2 champs: + - DbleVectNode champ vectoriel reel sur les noeuds + - DbleVectCell champ vectoriel reel sur les cellules + + En sortie, il y aura production d'un fichier MED + cube_hexa8_n.med qui contiendra un seul maillage et 2 champs + avec une seule famille la FAMILLE_0 +*/ + +#include +#include +#include + +#include + +int main (int argc, char **argv) +{ + med_err ret; + med_idt fid; + char maa[MED_TAILLE_NOM+1] = "cube_hexa8"; + med_int mdim = 3; + + int nnoe_dir; + int nelt_dir; + med_int nnoe; + int i, j, k, ijk; + + med_float * coo; + med_int * numnoe; + med_int * nufano; + + med_float hxsize; + med_float hysize; + med_float hzsize; + + med_float * DbleVectNode; + med_float * DbleVectCell; + + time_t t1; + + /* + Le maillage + */ + + char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z "; + char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm "; + /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ + char *nomnoe ; + + med_int nhexa8; + med_int * hexa8; + med_int * numhexa8; + med_int * nufahexa8; + + char * nomhexa8; + int indexN1, indexN2, indexN3, indexN4, indexN5, indexN6, indexN7, indexN8; + + char nomfam[MED_TAILLE_NOM+1]; + med_int numfam; + char attdes[MED_TAILLE_DESC+1]; + med_int natt; + med_int attide; + med_int attval; + med_int ngro; + char gro[MED_TAILLE_LNOM+1]; + int nfame = 0; + int nfamn = 0; + + char MedFile[100] = "cube_hexa8_"; + char buff[100]; + + /* + Les champs + */ + + char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode"; + char compDbleVectNode[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ; + char unitDbleVectNode[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ; + + char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell"; + char compDbleVectCell[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ; + char unitDbleVectCell[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ; + + if (argc != 2) + { + printf("Usage: %s \n",argv[0]); + printf(" where\n"); + printf(" - n is the number of nodes in each direction.\n"); + printf("\n"); + printf("This program will produce a MED file cube_hexa8_n.med\n"); + exit(0); + } + + nnoe_dir = atoi(argv[1]); + nelt_dir = nnoe_dir-1; + nnoe = nnoe_dir*nnoe_dir*nnoe_dir; + + coo = malloc(mdim*nnoe*sizeof(med_float)); + numnoe = malloc(nnoe*sizeof(med_int)); + nufano = malloc(nnoe*sizeof(med_int)); + nomnoe = malloc((MED_TAILLE_PNOM*nnoe+1)*sizeof(char)); + + hxsize = 1./((med_float) (nnoe_dir - 1)); + hysize = hxsize; + hzsize = hxsize; + + nhexa8 = nelt_dir*nelt_dir*nelt_dir; + hexa8 = malloc(8*nhexa8*sizeof(med_int)); + numhexa8 = malloc(nhexa8*sizeof(med_int)); + nufahexa8 = malloc(nhexa8*sizeof(med_int)); + nomhexa8 = malloc((MED_TAILLE_PNOM*nhexa8+1)*sizeof(char)); + + DbleVectNode = malloc(mdim*nnoe*sizeof(med_float)); + DbleVectCell = malloc(mdim*nhexa8*sizeof(med_float)); + + /* + les noeuds: + */ + + for(k=0;k 0 + - les numeros de familles des elements sont < 0 + - rien d'imposer sur les noms de familles + */ + + /* la famille 0 */ + if (ret == 0) + { + strcpy(nomfam,"FAMILLE_0"); + numfam = 0; + ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0, + gro,0); + } + printf("%d \n",ret); + + /***************************************************************************/ + /* + Les Champs + */ + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode, + unitDbleVectNode,mdim); + + printf("MEDchampCr DbleVectNode : %d \n",ret); + + if (ret == 0) + { + ret = MEDchampEcr(fid, maa, champDbleVectNode, + (unsigned char *)DbleVectNode, + MED_NO_INTERLACE, nnoe, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, + 0, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectNode : %d \n",ret); + } + } + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell, + unitDbleVectCell,mdim); + + printf("MEDchampCr DbleVectCell : %d \n",ret); + + if (ret == 0) + { + ret = MEDchampEcr(fid, maa, champDbleVectCell, + (unsigned char *)DbleVectCell, + MED_NO_INTERLACE, nhexa8, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_HEXA8, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectCell : %d \n",ret); + } + } + + /***************************************************************************/ + + ret = MEDfermer(fid); + printf("%d\n",ret); + + free(coo); + free(numnoe); + free(nufano); + free(nomnoe); + free(hexa8); + free(numhexa8); + free(nufahexa8); + free(nomhexa8); + free(DbleVectNode); + free(DbleVectCell); + + return 0; +} + + diff --git a/src/MedClient/src/create_mesh_c3t4.c b/src/MedClient/src/create_mesh_c3t4.c new file mode 100644 index 000000000..10e4a204a --- /dev/null +++ b/src/MedClient/src/create_mesh_c3t4.c @@ -0,0 +1,409 @@ +/* + creation d'une geometrie 3d : un cube [0,1]^3 + maillé uniformement en tetrahedres reguliers; + avec n (=argv[1]) noeuds dans chaque direction. + 2 champs: + - DbleVectNode champ vectoriel reel sur les noeuds + - DbleVectCell champ vectoriel reel sur les cellules + + En sortie, il y aura production d'un fichier MED + cube_tetra_n.med qui contiendra un seul maillage et 2 champs + avec une seule famille la FAMILLE_0 +*/ + +#include +#include +#include + +#include + +int main (int argc, char **argv) +{ + med_err ret; + med_idt fid; + char maa[MED_TAILLE_NOM+1] = "cube_tetra4"; + med_int mdim = 3; + int dimTot; + + int nnoe_dir; + int nelt_dir; + med_int nnoe; + int i, j, k, ijk; + + med_float * coo; + med_int * numnoe; + med_int * nufano; + + med_float hxsize; + med_float hysize; + med_float hzsize; + + med_float * DbleVectNode; + med_float * DbleVectCell; + + time_t t1; + + /* + Le maillage + */ + + char nomcoo[3*MED_TAILLE_PNOM+1] = "x y z "; + char unicoo[3*MED_TAILLE_PNOM+1] = "cm cm cm "; + /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ + char *nomnoe ; + + med_int ntetra4; + med_int * tetra4; + med_int * numtetra4; + med_int * nufatetra4; + + char * nomtetra4; + int indexN1, indexN2, indexN3, indexN4, indexN5, indexN6, indexN7, indexN8; + + char nomfam[MED_TAILLE_NOM+1]; + med_int numfam; + char attdes[MED_TAILLE_DESC+1]; + med_int natt; + med_int attide; + med_int attval; + med_int ngro; + char gro[MED_TAILLE_LNOM+1]; + int nfame = 0; + int nfamn = 0; + + char MedFile[100] = "cube_tetra4_"; + char buff[100]; + + /* + Les champs + */ + + char champDbleVectNode[MED_TAILLE_NOM+1] = "DbleVectNode"; + char compDbleVectNode[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ; + char unitDbleVectNode[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ; + + char champDbleVectCell[MED_TAILLE_NOM+1] = "DbleVectCell"; + char compDbleVectCell[MED_TAILLE_PNOM*3+1] = "comp1 comp2 comp3 " ; + char unitDbleVectCell[MED_TAILLE_PNOM*3+1] = "unit1 unit2 unit3 " ; + + if (argc != 2) + { + printf("Usage: %s \n",argv[0]); + printf(" where\n"); + printf(" - n is the number of nodes in each direction.\n"); + printf("\n"); + printf("This program will produce a MED file cube_tetra4_n.med\n"); + exit(0); + } + + nnoe_dir = atoi(argv[1]); + nelt_dir = nnoe_dir-1; + nnoe = (med_int) nnoe_dir*nnoe_dir*nnoe_dir; + + dimTot = (int) mdim*nnoe*sizeof(med_float); + coo = malloc(dimTot); + + dimTot = (int) (MED_TAILLE_PNOM*nnoe+1)*sizeof(char); + nomnoe = malloc(dimTot); + + dimTot = (int) nnoe*sizeof(med_int); + numnoe = malloc(dimTot); + nufano = malloc(dimTot); + + hxsize = 1./((med_float) (nnoe_dir - 1)); + hysize = hxsize; + hzsize = hxsize; + + ntetra4 = (med_int) 6*nelt_dir*nelt_dir*nelt_dir; + + dimTot = (int) 4*ntetra4*sizeof(med_int); + tetra4 = malloc(dimTot); + + dimTot = (int) (MED_TAILLE_PNOM*ntetra4+1)*sizeof(char); + nomtetra4 = malloc(dimTot); + + dimTot = (int) ntetra4*sizeof(med_int); + numtetra4 = malloc(dimTot); + nufatetra4 = malloc(dimTot); + + dimTot = (int) mdim*nnoe*sizeof(med_float); + DbleVectNode = malloc(dimTot); + + dimTot = (int) mdim*ntetra4*sizeof(med_float); + DbleVectCell = malloc(dimTot); + + /* + les noeuds: + */ + + for(k=0;k 0 + - les numeros de familles des elements sont < 0 + - rien d'imposer sur les noms de familles + */ + + /* la famille 0 */ + if (ret == 0) + { + strcpy(nomfam,"FAMILLE_0"); + numfam = 0; + ret = MEDfamCr(fid,maa,nomfam,numfam,&attide,&attval,attdes,0, + gro,0); + } + printf("%d \n",ret); + + /***************************************************************************/ + /* + Les Champs + */ + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectNode,MED_REEL64,compDbleVectNode, + unitDbleVectNode,mdim); + + printf("MEDchampCr DbleVectNode : %d \n",ret); + + if (ret == 0) + { + dimTot = (int) nnoe; + + ret = MEDchampEcr(fid, maa, champDbleVectNode, + (unsigned char *) DbleVectNode, + MED_NO_INTERLACE, dimTot, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_NOEUD, + 0, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectNode : %d \n",ret); + } + } + + if (ret == 0) + { + ret = MEDchampCr(fid,champDbleVectCell,MED_REEL64,compDbleVectCell, + unitDbleVectCell,mdim); + + printf("MEDchampCr DbleVectCell : %d \n",ret); + + if (ret == 0) + { + dimTot = (int) ntetra4; + + ret = MEDchampEcr(fid, maa, champDbleVectCell, + (unsigned char *) DbleVectCell, + MED_NO_INTERLACE, dimTot, + MED_NOPG, MED_ALL, MED_NOPFL, MED_ECRI, MED_MAILLE, + MED_TETRA4, MED_NOPDT," ", 0., MED_NONOR); + + printf("MEDchampEcr DbleVectCell : %d \n",ret); + } + } + + /***************************************************************************/ + + ret = MEDfermer(fid); + printf("%d\n",ret); + + free(coo); + free(numnoe); + free(nufano); + free(nomnoe); + free(tetra4); + free(numtetra4); + free(nufatetra4); + free(nomtetra4); + free(DbleVectNode); + free(DbleVectCell); + + return 0; +} diff --git a/src/MedClient/src/libMEDClient.i b/src/MedClient/src/libMEDClient.i index c45e79d07..e0cf95516 100644 --- a/src/MedClient/src/libMEDClient.i +++ b/src/MedClient/src/libMEDClient.i @@ -3,10 +3,11 @@ %{ #include "MESHClient.hxx" #include "SUPPORTClient.hxx" -#include "FIELDClient.hxx" +#include "FIELDDOUBLEClient.hxx" +#include "FIELDINTClient.hxx" #include CORBA_CLIENT_HEADER(MED) -#define FIELDDOUBLEClient FIELDClient -#define FIELDINTClient FIELDClient +/* #define FIELDDOUBLEClient FIELDClient */ +/* #define FIELDINTClient FIELDClient */ %} %include "libMedCorba_Swig.i" @@ -37,10 +38,34 @@ class SUPPORTClient : public SUPPORT { }; -%rename(FIELDDOUBLEClient) FIELDClient; -FIELDDOUBLE * FIELDDOUBLEClient(const SALOME_MED::FIELDDOUBLE_ptr IOR_Field, - SUPPORT * S = NULL); +class FIELDDOUBLEClient : public FIELDDOUBLE { +public: + FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba, + SUPPORT * S = NULL); -%rename(FIELDINTClient) FIELDClient; -FIELDDOUBLE * FIELDINTClient (const SALOME_MED::FIELDINT_ptr IOR_Field, - SUPPORT * S = NULL); + ~FIELDDOUBLEClient(); +}; + +class FIELDINTClient : public FIELDINT { +public: + FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba, + SUPPORT * S = NULL); + + ~FIELDINTClient(); +}; + +FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input); + +FIELDINT * getIntPointer(FIELDINTClient * input); + +%{ + FIELDDOUBLE * getDoublePointer(FIELDDOUBLEClient * input) + { + return (FIELDDOUBLE *) input; + } + + FIELDINT * getIntPointer(FIELDINTClient * input) + { + return (FIELDINT *) input; + } +%} diff --git a/src/MedClient/src/test_medclient.py b/src/MedClient/src/test_medclient.py new file mode 100644 index 000000000..ba1019984 --- /dev/null +++ b/src/MedClient/src/test_medclient.py @@ -0,0 +1,27 @@ +import salome +import SALOME_TESTMEDCLIENT +import SALOME_MED + +def getMedObjectFromStudy(): + mySO = salome.myStudy.FindObject("Objet MED") + Builder = salome.myStudy.NewBuilder() + anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR") + obj = salome.orb.string_to_object(anAttr.Value()) + myObj = obj._narrow(SALOME_MED.MED) + return myObj + +#Truc1,Truc2 are Containers launched with SALOME_Container exe. + +med_comp = salome.lcc.FindOrLoadComponent("Truc1", "MED") +my_comp = salome.lcc.FindOrLoadComponent("Truc2","TESTMEDCLIENT") +studyCurrent = salome.myStudyName + +## First test + +##med_obj = med_comp.readStructFile("cube_tetra4_12.med",studyCurrent) +##my_comp.go2(med_obj) + +## Second test + +med_obj = med_comp.readStructFile("cube_hexa8_quad4.med",studyCurrent) +my_comp.go(med_obj) -- 2.39.2