From: ageay Date: Thu, 4 Apr 2013 09:11:28 +0000 (+0000) Subject: MEDMEM suppression X-Git-Tag: EndAGWork4413~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5cc6a54bc644bd46d0abad0b7c6a0adac37711f3;p=modules%2Fmed.git MEDMEM suppression --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 514a317a7..4f89a22bb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -29,12 +29,12 @@ ENDIF(SWIG_STATUS) IF(MED_ENABLE_MED3) SET(COMMON_SUBDIRS ${COMMON_SUBDIRS} MEDLoader MEDWrapper) - SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDMEM) + SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS}) IF(CPPUNIT_IS_OK) - SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} INTERP_KERNELTest MEDMEMBinTest MEDMEMCppTest) + SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} INTERP_KERNELTest ) ENDIF(CPPUNIT_IS_OK) IF(SWIG_STATUS) - SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDMEM_SWIG) + SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS}) ENDIF(SWIG_STATUS) ENDIF(MED_ENABLE_MED3) @@ -71,15 +71,15 @@ IF(MED_ENABLE_KERNEL) SET(COMMON_SUBDIRS ${COMMON_SUBDIRS} MEDCouplingCorba) IF(SWIG_STATUS) SET(COMMON_SUBDIRS ${COMMON_SUBDIRS} MEDCouplingCorba_Swig) - SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MedCorba_Swig MED_SWIG) + SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS}) ENDIF(SWIG_STATUS) - SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MED MedClient) + SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS}) IF(MPI_IS_OK) SET(COMMON_SUBDIRS ${COMMON_SUBDIRS} ParaMEDCouplingCorba ParaMEDMEMComponent) ENDIF(MPI_IS_OK) IF(MED_ENABLE_MED3) SET(COMMON_SUBDIRS ${COMMON_SUBDIRS} MEDCalculator MEDOP) - SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDMEM_I) + SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS}) ENDIF(MED_ENABLE_MED3) IF(MED_ENABLE_GUI) SET(OLD_COMMON_SUBDIRS ${OLD_COMMON_SUBDIRS} MEDGUI) diff --git a/src/MED/CMakeLists.txt b/src/MED/CMakeLists.txt deleted file mode 100644 index ecb611c2d..000000000 --- a/src/MED/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INCLUDE_DIRECTORIES( - ${OMNIORB_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIRS} - ${XDR_INCLUDE_DIRS} - ${KERNEL_ROOT_DIR}/include/salome - ${CMAKE_CURRENT_BINARY_DIR}/../.. - ${CMAKE_CURRENT_BINARY_DIR}/../../idl - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM_I - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints -) - -SET(MEDEngine_SOURCES - Med_Gen_i.cxx - Med_Gen_Driver_i.cxx -) - -SET(COMMON_FLAGS "${OMNIORB_DEFINITIONS} ${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") -IF(WINDOWS) - SET(COMMON_FLAGS "${COMMON_FLAGS} -DNOGDI") -ENDIF(WINDOWS -) - -ADD_LIBRARY(MEDEngine SHARED ${MEDEngine_SOURCES}) -SET_TARGET_PROPERTIES(MEDEngine PROPERTIES COMPILE_FLAGS "${COMMON_FLAGS}") -TARGET_LINK_LIBRARIES(MEDEngine MEDMEMImpl SalomeIDLMED ${TOOLSDS} ${SalomeHDFPersist} - ${SalomeContainer} ${SalomeCommunication} ${SalomeLifeCycleCORBA} ${PLATFORM_LIBS}) -INSTALL(TARGETS MEDEngine DESTINATION ${MED_salomelib_LIBS}) - -SET(MED_MED_salomescript_DATA - MED_test1.py MED_test2.py Med_Gen_test.py testMedAlliances.py testMedAlliances1.py - ) - -FILE(GLOB MEDEngine_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") -INSTALL(FILES ${MEDEngine_HEADERS_HXX} DESTINATION ${MED_salomeinclude_HEADERS}) -INSTALL(FILES ${MED_MED_salomescript_DATA} DESTINATION ${MED_salomescript_DATA}) diff --git a/src/MED/MED_test1.py b/src/MED/MED_test1.py deleted file mode 100755 index 339286da5..000000000 --- a/src/MED/MED_test1.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MED : implemetation of MED idl descriptions -# File : MED_test1.py -# Author : -# Module : MED -# $Header$ -# -import salome - -med=salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") -fileName="pointe.med" -fileTout=os.path.join(filePath,fileName) - -print fileTout - -med.readStructFile(fileTout,salome.myStudyName) diff --git a/src/MED/MED_test2.py b/src/MED/MED_test2.py deleted file mode 100755 index fa6c7e871..000000000 --- a/src/MED/MED_test2.py +++ /dev/null @@ -1,69 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MED : implemetation of MED idl descriptions -# File : MED_test2.py -# Author : -# Module : MED -# $Header$ -# -import salome -import SALOME -import os - -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") -medFile=os.path.join(filePath, "mesh.med") - -med=salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -try: - mesh=med.readMeshInFile(medFile, salome.myStudyName,"Mesh 1") -except SALOME.SALOME_Exception, ex: - print ex.details - print ex.details.type - print ex.details.text - print ex.details.sourceFile - print ex.details.lineNumber - - raise - -print mesh.getName() -print mesh.getNumberOfNodes() - -medFile = os.path.join(filePath,"pointe.med") -try: - field=med.readFieldInFile(medFile,salome.myStudyName,"fieldcelldoublescalar",-1,-1) -except SALOME.SALOME_Exception, ex: - print ex.details - print ex.details.type - print ex.details.text - print ex.details.sourceFile - print ex.details.lineNumber - - raise - -print field.getName() -print field.getDescription() -print field.getNumberOfComponents() - diff --git a/src/MED/Makefile.am b/src/MED/Makefile.am deleted file mode 100644 index a6c5051f5..000000000 --- a/src/MED/Makefile.am +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MED : implemetation of MED idl descriptions -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES= libMEDEngine.la - -dist_libMEDEngine_la_SOURCES= Med_Gen_i.cxx Med_Gen_Driver_i.cxx -salomeinclude_HEADERS = Med_Gen_i.hxx Med_Gen_Driver_i.hxx - -libMEDEngine_la_CPPFLAGS= $(MED3_INCLUDES) $(HDF5_INCLUDES) ${KERNEL_CXXFLAGS} @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \ - -I$(srcdir)/../MEDMEM_I \ - -I$(top_builddir) \ - -I$(top_builddir)/idl \ - -I$(srcdir)/../MEDMEM \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/GaussPoints - -libMEDEngine_la_LDFLAGS=\ - $(top_builddir)/idl/libSalomeIDLMED.la \ - ../MEDMEM_I/libMEDMEMImpl.la \ - ${KERNEL_LDFLAGS} -lTOOLSDS -lSalomeHDFPersist -lSalomeContainer -# ${KERNEL_LDFLAGS} \ -# @CORBA_LIBS@ \ -# @CAS_OCAF@ \ -# $(HDF5_LIBS) -# -lOpUtil -lSalomeContainer -lSalomeDS -lSalomeNS -lRegistry -# -# - - - -dist_salomescript_DATA= MED_test1.py MED_test2.py Med_Gen_test.py testMedAlliances.py testMedAlliances1.py diff --git a/src/MED/Med_Gen_Driver_i.cxx b/src/MED/Med_Gen_Driver_i.cxx deleted file mode 100755 index d3955b1a2..000000000 --- a/src/MED/Med_Gen_Driver_i.cxx +++ /dev/null @@ -1,971 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// MED MED : implemetation of MED idl descriptions -// File : Med_Gen_Driver_i.cxx -// Author : Paul RASCLE, EDF -// Module : MED -// -#include "Med_Gen_Driver_i.hxx" - -#include "MEDMEM_Mesh_i.hxx" -#include "MEDMEM_Med_i.hxx" -#include "MEDMEM_FieldTemplate_i.hxx" -#include "MEDMEM_Support_i.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_DriversDef.hxx" - - -#include "Utils_SINGLETON.hxx" -#include "OpUtil.hxx" -#include "Utils_CorbaException.hxx" -#include "utilities.h" - -#include "SALOMEDS_Tool.hxx" - -#include -#include - -#include - -using namespace MEDMEM; - -// Initialisation des variables statiques -map Med_Gen_Driver_i::_MedCorbaObj; - -//============================================================================= -/*! - * default constructor: not for use - */ -//============================================================================= -Med_Gen_Driver_i::Med_Gen_Driver_i() -{ - MESSAGE("Med_Gen_Driver_i::Med_Gen_Driver_i"); -} - -//============================================================================= -/*! - * standard constructor - */ -//============================================================================= -Med_Gen_Driver_i::Med_Gen_Driver_i(CORBA::ORB_ptr orb) -{ - MESSAGE("activate object"); - _driver_orb = CORBA::ORB::_duplicate(orb); - - // get a NamingService interface - _NS = SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - _NS->init_orb( _driver_orb ); -} - -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -Med_Gen_Driver_i::~Med_Gen_Driver_i() -{ - MESSAGE("Med_Gen_Driver_i::~Med_Gen_Driver_i"); -} - -//============================================================================= -/*! - * GetMED [ static ] - * - * Get Med of the study (for persistance) - */ -//============================================================================= -MEDMEM::MED_i* Med_Gen_Driver_i::GetMED(SALOMEDS::SComponent_ptr theComponent) -{ - // we have a separate MED_i for each component in a study - SALOMEDS::Study_var study = theComponent->GetStudy(); - ostringstream os; - os << study->StudyId() << "_" << theComponent->Tag(); - string mapKey = os.str(); - - MED_i* med_i; - map ::iterator id_med; - id_med = _MedCorbaObj.find( mapKey ); - if ( id_med == _MedCorbaObj.end() ) - _MedCorbaObj[ mapKey ] = med_i = new MED_i(); - else - med_i = id_med->second; - return med_i; -} - -//============================================================================= -/*! - * CORBA: Save Mesh objects (called when a study is saved) - */ -//============================================================================= -namespace { - - // names to use instead of true and false - enum { SAVE = 1, RESTORE = 0, ASCII = 1, NON_ASCII = 0 }; - - //================================================================================ - /*! - * \brief Return path and base name of a file to store med data in - * \param theStudy - study being stored or restored - * \param theURL - path to file storing the study - * \param isMultiFile - storage mode - * \param isSave - action kind: SAVE or RESTORE - * \retval pair - path and file base name - */ - //================================================================================ - pair getPersistanceDirAndFileName(SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - const bool isMultiFile, - const bool isSave) - { - string path, file; - CORBA::String_var compName = theComponent->ComponentDataType(); - if (isMultiFile) { - // file constantly holding data - path = theURL; - SALOMEDS::Study_var study = theComponent->GetStudy(); - file = SALOMEDS_Tool::GetNameFromPath( study->URL() ); - file += string( "_" ) + string( compName ) + ".med"; - } - else { - // temporary file - path = SALOMEDS_Tool::GetTmpDir(); - if ( strcmp( "MED", compName ) != 0 ) - file = string( compName ) + "_"; // not MED - file += "tmp.med"; - } - return make_pair ( path, file ); - } - - //================================================================================ - /*! - * \brief Save med objects published in a study - * \param theStudy - study to store - * \param theURL - path to store - * \param isMultiFile - store mode - * \param isAscii - store mode: ASCII or NON_ASCII - * \retval SALOMEDS::TMPFile* - result file - */ - //================================================================================ - SALOMEDS::TMPFile* saveStudy (SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile, - bool isAscii) - { - // Write all MEDMEM objects in one med file because of problems with - // reference to external mesh when writting field in a separate file. - // Actually, writting is OK, but when reading a field, its support - // is updated using mesh data missing in the file being read - - // If arises a problem of meshes or other objects having equal names, - // the solution can be in renaming them using study entry before writting - // and renaming back during restoration, real names will be stored in - // LocalPersistentID's for example - - if (CORBA::is_nil(theComponent)) { - SALOMEDS::TMPFile_var aStreamFile; - return aStreamFile._retn(); - } - - SALOMEDS::Study_var study = theComponent->GetStudy(); - - pair aDir_aFileName = - getPersistanceDirAndFileName(theComponent, theURL, isMultiFile, SAVE ); - string& aPath = aDir_aFileName.first; - string& aBaseName = aDir_aFileName.second; - string aFile = aPath + aBaseName; - - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(1); - aSeq[0] = CORBA::string_dup(aBaseName.c_str()); - - if (isMultiFile) { // remove existing file - //cout << "-----------------Remove " << aPath<< ", "< savedMeshes; - { - SALOMEDS::ChildIterator_var anIter = study->NewChildIterator(theComponent); - anIter->InitEx(1); - for (; anIter->More(); anIter->Next()) { - SALOMEDS::SObject_var aSO = anIter->Value(); - SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow( aSO->GetObject() ); - if (! CORBA::is_nil(myField)) { - long driverId = myField->addDriver(SALOME_MED::MED_DRIVER, - aFile.c_str(), - myField->getName()); - myField->write(driverId,""); - // save mesh - SALOME_MED::SUPPORT_var sup = myField->getSupport(); - if ( !sup->_is_nil() ) { - SALOME_MED::GMESH_var mesh = sup->getMesh(); - if ( !mesh->_is_nil() ) { - CORBA::Long corbaID = mesh->getCorbaIndex(); - ::MEDMEM::GMESH* gmesh = GMESH_i::meshMap[ int(corbaID) ]; - if ( savedMeshes.insert( gmesh ).second ) { - long driverId = mesh->addDriver(SALOME_MED::MED_DRIVER, - aFile.c_str(), - mesh->getName()); - mesh->write(driverId,""); - } - } - } - } - } - } - - { - SALOMEDS::ChildIterator_var anIter = study->NewChildIterator(theComponent); - anIter->InitEx(1); - for (; anIter->More(); anIter->Next()) { - SALOMEDS::SObject_var aSO = anIter->Value(); - SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow( aSO->GetObject() ); - if (! CORBA::is_nil(myMesh)) { - CORBA::Long corbaID = myMesh->getCorbaIndex(); - ::MEDMEM::GMESH* gmesh = GMESH_i::meshMap[ int(corbaID) ]; - if ( savedMeshes.insert( gmesh ).second ) { - long driverId = myMesh->addDriver(SALOME_MED::MED_DRIVER, - aFile.c_str(), - myMesh->getName()); - myMesh->write(driverId,""); - } - } - } - } - - if ( isAscii ) - HDFascii::ConvertFromHDFToASCII( aFile.c_str(), true); - - // Convert a file to the byte stream - SALOMEDS::TMPFile_var aStreamFile; - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aPath.c_str(), aSeq.in(), isMultiFile); - - // Remove a tmp file and directory - if (!isMultiFile) { - //cout << "-----------------Remove " << aPath<< ", "<GetStudy(); - - // Get file name - pair aDir_aFileName = getPersistanceDirAndFileName - (theComponent, theURL, isMultiFile, RESTORE); - string& aPath = aDir_aFileName.first; - string& aBaseName = aDir_aFileName.second; - string aFile = aPath + aBaseName; - - SALOMEDS::ListOfFileNames_var aSeq = - SALOMEDS_Tool::PutStreamToFiles(theStream, aPath.c_str(), isMultiFile); - - string aASCIIPath, aASCIIFile; - if (isASCII) - { - aASCIIPath = HDFascii::ConvertFromASCIIToHDF(aFile.c_str()); - aASCIIFile = "hdf_from_ascii.hdf"; - aFile = aASCIIPath + aASCIIFile; - } - - MED_i* med_i = Med_Gen_Driver_i::GetMED(theComponent); - SALOME_MED::MED_var med = med_i->_this(); - - // Read all meshes with supports and all fields - try - { - //cout << "-----------------Filename " << aFile << endl; - med_i->initWithFieldType(study, MED_DRIVER, aFile, true); - - // publishing must be done by initWithFieldType according to flag - med_i->addInStudy(study, med, theComponent, 0); - } - catch (const std::exception & ex) - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to read a hdf file",SALOME::BAD_PARAM); - } - - // Remove tmp files - bool keepTmpFiles = getenv( "MEDPERSIST_KEEP_TMP_FILES" ); // DEBUG - if ( keepTmpFiles ) - cout << "TMP FILE: " << aFile << endl; - if ( !isMultiFile && !keepTmpFiles ) { - aSeq->length(1); - aSeq[0]=CORBA::string_dup(aBaseName.c_str()); - SALOMEDS_Tool::RemoveTemporaryFiles(aPath.c_str(), aSeq.in(), true); - } - if (isASCII) - { - aSeq->length(1); - aSeq[0] = CORBA::string_dup(aASCIIFile.c_str()); - //cout << "-----------------Remove " << aASCIIPath<< ", "<getName() + - // "_ORDRE_"+a.str()+ - // "_ITER_"+b.str()+".med" - int aLPIdLen = strlen(aLocalPersistentID); - const int _MEDFIELD_Len = strlen("_MEDFIELD_"); - const int _ORDRE_Len = strlen("_ORDRE_"); - const int _ITER_Len = strlen("_ITER_"); - - // Get field name: look for _ORDRE_ in aLocalPersistentID - int aFieldNameLen = 0, aFieldNameBeg = _MEDFIELD_Len, _ORDRE_Beg; - for ( _ORDRE_Beg = aFieldNameBeg; _ORDRE_Beg < aLPIdLen; ++aFieldNameLen,++_ORDRE_Beg ) - if ( strncmp( &aLocalPersistentID[ _ORDRE_Beg ], "_ORDRE_", _ORDRE_Len ) == 0 ) - break; - aFieldName = string( &(aLocalPersistentID[aFieldNameBeg]), aFieldNameLen); - - // Get orderNumber - int anOrderNumberBeg = _ORDRE_Beg + _ORDRE_Len; - aNumOrdre = atoi( & aLocalPersistentID[ anOrderNumberBeg ]); - - // Get iterationNumber: look for _ITER_ in aLocalPersistentID - int _ITER_Beg = anOrderNumberBeg; - for ( ; _ITER_Beg < aLPIdLen; ++_ITER_Beg ) - if ( strncmp( &aLocalPersistentID[ _ITER_Beg ], "_ITER_", _ITER_Len ) == 0 ) - break; - anIterNumber = atoi( & aLocalPersistentID[ _ITER_Beg + _ITER_Len ]); - } - - //================================================================================ - /*! - * \brief Retrieve from aLocalPersistentID data to get support from med - * \param aLocalPersistentID - persistent ID - * \param type - string "FAMILY", "GROUP" or "SUPPORT - * \param name - support name - * \param mesh - mesh name - * \param entity - support entity - * \retval bool - true if all data found in aLocalPersistentID - */ - //================================================================================ - bool getSupportData (string aLocalPersistentID, - string & type, - string & name, - string & mesh, - string & entity) - { - // aLocalPersistentID contains: - // _MED_[FAMILY|GROUP|SUPPORT]/support_name/ENS_MAA/mesh_name/ENTITY/entity - string::size_type slash1Pos = aLocalPersistentID.find("/"); - if ( slash1Pos == aLocalPersistentID.npos ) return false; - string::size_type ens_maaPos = aLocalPersistentID.find("/ENS_MAA/", slash1Pos); - if ( ens_maaPos == aLocalPersistentID.npos ) return false; - string::size_type entityPos = aLocalPersistentID.find("/ENTITY/", ens_maaPos); - if ( entityPos == aLocalPersistentID.npos ) return false; - - string::size_type medSize = strlen("_MED_"); - string::size_type ens_maaSize = strlen("/ENS_MAA/"); - string::size_type entitySize = strlen("/ENTITY/"); - - type = aLocalPersistentID.substr( medSize, slash1Pos - medSize ); - name = aLocalPersistentID.substr( slash1Pos + 1, ens_maaPos - slash1Pos - 1); - mesh = aLocalPersistentID.substr( ens_maaPos + ens_maaSize, - entityPos - ens_maaPos - ens_maaSize); - entity = aLocalPersistentID.substr( entityPos + entitySize ); -// cout << aLocalPersistentID << endl -// << " type: " << type -// << " name: " << name -// << " mesh: " << mesh -// << " entity: " << entity << endl; - return true; - } -} // no name namespace - -//================================================================================ -/*! - * \brief Save data published under MED component - * \param theComponent - MED component - * \param theURL - path to store - * \param isMultiFile - store mode - * \retval SALOMEDS::TMPFile* - result file - */ -//================================================================================ -SALOMEDS::TMPFile* Med_Gen_Driver_i::Save (SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile) -{ - return saveStudy ( theComponent, theURL, isMultiFile, NON_ASCII ); -} - -//================================================================================ -/*! - * \brief Save data published under MED component in ASCII file - * \param theComponent - MED component - * \param theURL - path to store - * \param isMultiFile - store mode - * \retval SALOMEDS::TMPFile* - result file - */ -//================================================================================ -SALOMEDS::TMPFile* Med_Gen_Driver_i::SaveASCII (SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile) -{ - return saveStudy ( theComponent, theURL, isMultiFile, ASCII ); -} - -//============================================================================= -/*! - * CORBA: Load Mesh objects (called when an existing study is opened) - */ -//============================================================================= - -CORBA::Boolean Med_Gen_Driver_i::Load (SALOMEDS::SComponent_ptr theComponent, - const SALOMEDS::TMPFile& theStream, - const char* theURL, - bool isMultiFile) -{ - loadStudy ( theComponent, theStream, theURL, isMultiFile, NON_ASCII ); - - return true; -} - -CORBA::Boolean Med_Gen_Driver_i::LoadASCII (SALOMEDS::SComponent_ptr theComponent, - const SALOMEDS::TMPFile& theStream, - const char* theURL, - bool isMultiFile) -{ - loadStudy ( theComponent, theStream, theURL, isMultiFile, ASCII ); - return true; -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -void Med_Gen_Driver_i::Close (SALOMEDS::SComponent_ptr theComponent) -{ - MESSAGE("Med_Gen_Driver_i::Close"); - SALOMEDS::SObject_var aMedMeshFather = theComponent->GetStudy()->FindObject("MEDMESH"); - if (!CORBA::is_nil(aMedMeshFather)) { - SALOMEDS::ChildIterator_var anIter = theComponent->GetStudy()->NewChildIterator(aMedMeshFather); - for(; anIter->More(); anIter->Next()) { - SALOMEDS::SObject_var aSO = anIter->Value(); - SALOMEDS::GenericAttribute_var anAttr; - if (aSO->FindAttribute(anAttr,"AttributeIOR")) { - CORBA::Object_var myIOR = - _driver_orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); - SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR); - // here must call method destroy of myMesh, but it not implemented yet - } - } - } -} - -//============================================================================= -/*! - * CORBA: give a persistent reference of a transient object (for study save) - */ -//============================================================================= -char* Med_Gen_Driver_i::IORToLocalPersistentID (SALOMEDS::SObject_ptr theSObject, - const char* IORString, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII) -{ - SCRUTE(IORString); - - if (string(IORString).size()==0) return CORBA::string_dup("_MED"); - // Well, we know where put object (_saveFilename) and we know object (IORString) - // cast object : - CORBA::Object_var myIOR = _driver_orb->string_to_object(IORString); - - // MED - SALOME_MED::MED_var myMed = SALOME_MED::MED::_narrow(myIOR); - if (! CORBA::is_nil(myMed)) - { - string str_MedName="_MED Objet Med + /OBJ_MED/"; - return CORBA::string_dup(str_MedName.c_str()); - } - - // MESH - SALOME_MED::MESH_var myMesh = SALOME_MED::MESH::_narrow(myIOR); - if (! CORBA::is_nil(myMesh)) - { - CORBA::String_var aName((string("_MEDMESH_")+ myMesh->getName() + ".med").c_str()); - return aName._retn(); - } - - // SUPPORT - SALOME_MED::SUPPORT_var mySupport = SALOME_MED::SUPPORT::_narrow(myIOR); - if (! CORBA::is_nil(mySupport)) - { - string type, str_SupportName; - SALOME_MED::FAMILY_var family = SALOME_MED::FAMILY::_narrow(myIOR); - if ( !family->_is_nil() ) - type = "_MED_FAMILY"; - else { - SALOME_MED::GROUP_var grp = SALOME_MED::GROUP::_narrow(myIOR); - if ( !grp->_is_nil() ) - type = "_MED_GROUP"; - else - type = "_MED_SUPPORT"; - } - try { - ostringstream os; - os << type << "/" << mySupport->getName(); - os << "/ENS_MAA/" << mySupport->getMesh()->getName(); - os << "/ENTITY/" << mySupport->getEntity(); - str_SupportName = os.str(); - } - catch(...) { - MESSAGE("Unable to save the support"); - THROW_SALOME_CORBA_EXCEPTION("Unable to save Field in Med"\ - ,SALOME::INTERNAL_ERROR); - } - return CORBA::string_dup(str_SupportName.c_str()); - } - - SALOME_MED::FIELD_var myField = SALOME_MED::FIELD::_narrow(myIOR); - if (! CORBA::is_nil(myField)) - { - string str_FieldName; - ostringstream a,b; - a<< myField->getOrderNumber(); - b<< myField->getIterationNumber(); - CORBA::String_var aName((string("_MEDFIELD_")+ myField->getName() + - string("_ORDRE_")+a.str()+ - string("_ITER_")+b.str() + - ".med").c_str()); - return aName._retn(); - } - - //THROW_SALOME_CORBA_EXCEPTION("Unable to save IOR",SALOME::BAD_PARAM); - return CORBA::string_dup("_MED"); -} - -//============================================================================= -/*! - * CORBA: give a transient reference (when loading an object, opening study) - */ -//============================================================================= -char* Med_Gen_Driver_i::LocalPersistentIDToIOR (SALOMEDS::SObject_ptr theSObject, - const char* aLocalPersistentID, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII) - throw(SALOME::SALOME_Exception) -{ - // all object are restored in Load() if their name in study coincides - // with a default one generated by object.addInStudy(...) - CORBA::String_var ior = theSObject->GetIOR(); - bool restoredByLoad = ( ior.in() && strlen( ior ) > 0 ); - - if ( !restoredByLoad ) - { - CORBA::Object_var object; - SALOMEDS::SComponent_var component = theSObject->GetFatherComponent(); - MED_i* med_i = Med_Gen_Driver_i::GetMED(component); - SALOME_MED::MED_var med = med_i->_this(); - - // MED - if (strcmp(aLocalPersistentID, "_MED Objet Med + /OBJ_MED/") == 0) - { - //object = med; - object = SALOME_MED::MED::_duplicate(med); - } - // MESH - else if (strncmp(aLocalPersistentID, "_MEDMESH_",9) == 0) - { - int aMeshNameLen = strlen(aLocalPersistentID) - 12; - string aMeshName( &(aLocalPersistentID[9]), aMeshNameLen); - aMeshName[aMeshNameLen-1] = 0; - try { - object = med->getMeshByName( aMeshName.c_str() ); - if ( CORBA::is_nil( object )) { - aMeshName = healName( aMeshName ); - object = med->getMeshByName( aMeshName.c_str() ); - } - } - catch (const std::exception & ex) { - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find a mesh by name in this file", - SALOME::INTERNAL_ERROR); - } - } - // FIELD - else if (strncmp(aLocalPersistentID, "_MEDFIELD_",10) == 0) - { - // Field Name - string aFieldName; - CORBA::Long aNumOrdre, anIterNumber; - getFieldNameAndDtIt( aLocalPersistentID, aFieldName, aNumOrdre, anIterNumber ); - // Get a field that is already read - try { - object = med->getField( aFieldName.c_str(), anIterNumber, aNumOrdre ); - if ( CORBA::is_nil( object )) { - aFieldName = healName( aFieldName ); - object = med->getField( aFieldName.c_str(), anIterNumber, aNumOrdre ); - } - } - catch (const std::exception & ex) { - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find a field by name in this file", - SALOME::INTERNAL_ERROR); - } - } - // SUPPORT? - else { - string type, name, meshName, entity; - if ( getSupportData( aLocalPersistentID, type, name, meshName, entity )) - { - MED_EN::medEntityMesh medEntity( atoi( entity.c_str() )); - - if ( type == "SUPPORT" ) { - try { - object = med_i->getSupport( meshName, medEntity ); - if ( CORBA::is_nil( object )) { - meshName = healName( meshName ); - object = med_i->getSupport( meshName, medEntity ); - } - } - catch (const std::exception & ex) { - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find support in this file", - SALOME::INTERNAL_ERROR); - } - } - else { - SALOME_MED::GMESH_var mesh; - try { - mesh = med->getMeshByName( meshName.c_str() ); - if ( mesh->_is_nil() ) { - meshName = healName( meshName ); - mesh = med->getMeshByName( meshName.c_str() ); - } - } - catch (const std::exception & ex) { - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find mesh in this file", - SALOME::INTERNAL_ERROR); - } - if ( !mesh->_is_nil() ) { - string healedName = healName( name ); - try { - if ( type == "FAMILY" ) { - SALOME_MED::Family_array_var families = mesh->getFamilies( medEntity ); - for ( int i = 0; CORBA::is_nil(object) && i <= (int)families->length(); ++i ) - if ( families[ i ]->getName() == name || - families[ i ]->getName() == healedName ) - object = SALOME_MED::FAMILY::_duplicate( families[ i ]); - } - else { - SALOME_MED::Group_array_var groups = mesh->getGroups( medEntity ); - for ( int i = 0; CORBA::is_nil(object) && i <= (int)groups->length(); ++i ) - if ( groups[ i ]->getName() == name || - groups[ i ]->getName() == healedName ) - object = SALOME_MED::GROUP::_duplicate( groups[ i ]); - } - } - catch (const std::exception & ex) { - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find support in this file", - SALOME::INTERNAL_ERROR); - } - } - } - } - } - if ( !CORBA::is_nil(object) ) - ior = _driver_orb->object_to_string( object ); - else - THROW_SALOME_CORBA_EXCEPTION("Unable to find the object in this file", - SALOME::INTERNAL_ERROR); - - } // !restoredByLoad - - return ior._retn(); -} - -//============================================================================= -/*! - * returns true, if can publish object - */ -//============================================================================= -bool Med_Gen_Driver_i::CanPublishInStudy (CORBA::Object_ptr theIOR) -{ - SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(theIOR); - if ( !aMesh->_is_nil()) - return true; - SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(theIOR); - if ( !aField->_is_nil()) - return true; - //SALOME_MED::SUPPORT_var aSupport = SALOME_MED::SUPPORT::_narrow(theIOR); - //if ( !aSupport->_is_nil()) - // return true; - return false; -} - -//============================================================================= -/*! - * publish the given object - */ -//============================================================================= -SALOMEDS::SObject_ptr Med_Gen_Driver_i::PublishInStudy (SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject, - CORBA::Object_ptr theObject, - const char* theName) - throw (SALOME::SALOME_Exception) -{ - SALOMEDS::SObject_var aResultSO; - - if (CORBA::is_nil(theObject)) return aResultSO; - if (theStudy->_is_nil()) return aResultSO; - - SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder(); - SALOMEDS::SComponent_var aFather = theStudy->FindComponent(ComponentDataType()); - - if (aFather->_is_nil()) { - aFather = aBuilder->NewComponent(ComponentDataType()); - if (aFather->_is_nil()) return aResultSO; - - SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute(aFather, "AttributeName"); - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - //NRI aName->SetValue("MED"); - - CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); - SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent(ComponentDataType()); - if (!Comp->_is_nil()) { - aName->SetValue(Comp->componentusername()); - } - - aBuilder->DefineComponentInstance(aFather, GetComponentInstance()); - } - - if (CORBA::is_nil(theSObject)) { - SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(theObject); - if (!aMesh->_is_nil()) { - aMesh->addInStudy(theStudy, aMesh); - } - else { - SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(theObject); - if (!aField->_is_nil()) { - aField->addInStudyToComponent(aFather, aField); - } - //else { - // SALOME_MED::SUPPORT_var aSupport = SALOME_MED::SUPPORT::_narrow(theObject); - // if (!aSupport->_is_nil()) - // aSupport->addInStudy(theStudy, aSupport); - //} - } - aResultSO = theStudy->FindObjectIOR(_driver_orb->object_to_string(theObject)); - } else { - //if (!theSObject->ReferencedObject(aResultSO)) - // THROW_SALOME_CORBA_EXCEPTION("Publish in study MED object error",SALOME::BAD_PARAM); - } - //aBuilder->Addreference(theObject, aResultSO); - return aResultSO._retn(); -} - -//============================================================================= -/*! - * returns true, if can copy the object - */ -//============================================================================= -CORBA::Boolean Med_Gen_Driver_i::CanCopy (SALOMEDS::SObject_ptr theObject) -{ - // Try to retrieve known by MED component mesh by given IOR - SALOMEDS::GenericAttribute_var anAttr; - if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return false; - try { - CORBA::Object_var anObj = - _driver_orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); - SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj); - // If the object is null one it can't be copied: return false - if (aMesh->_is_nil()) return false; - } catch(...) { - return false; - } - return true; -} - -//============================================================================= -/*! - * create copy of the object and put it to the stream - */ -//============================================================================= -SALOMEDS::TMPFile* Med_Gen_Driver_i::CopyFrom (SALOMEDS::SObject_ptr theObject, - CORBA::Long& theObjectID) -{ - // Declare a sequence of the byte to store the copied object - SALOMEDS::TMPFile_var aStreamFile; - - // Try to get GEOM_Shape object by given SObject - SALOMEDS::GenericAttribute_var anAttr; - if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return new SALOMEDS::TMPFile(0); - CORBA::String_var anIOR = CORBA::string_dup(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()); - CORBA::Object_var anObj = _driver_orb->string_to_object(anIOR); - SALOME_MED::MESH_var aMesh = SALOME_MED::MESH::_narrow(anObj); - if (aMesh->_is_nil()) return new SALOMEDS::TMPFile(0); - - // Get a temporary directory to store a temporary file - CORBA::String_var aTmpDir = SALOMEDS_Tool::GetTmpDir().c_str(); - // Create a list to store names of created files - SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames; - aSeq->length(1); - aSeq[0] = CORBA::string_dup(aMesh->getName()); - char* aFullName = new char[strlen(aTmpDir)+strlen(aSeq[0])+1]; - strcpy(aFullName, aTmpDir); - strcpy(aFullName+strlen(aTmpDir), aSeq[0]); - - long driverId = aMesh->addDriver(SALOME_MED::MED_DRIVER,aFullName , aMesh->getName()); - aMesh->write(driverId,""); - - // aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir.c_str(), aSeq.in(), false); - char* aFullName1 = new char[strlen(aTmpDir)+1]; - strcpy(aFullName1, aTmpDir); - aStreamFile = SALOMEDS_Tool::PutFilesToStream(aFullName1, aSeq.in(), false); - // SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); - SALOMEDS_Tool::RemoveTemporaryFiles(aFullName1, aSeq.in(), true); - - // Assign an ID = 1 the the type SALOME_MED::MESH - theObjectID = 1; - - return aStreamFile._retn(); -} - -//============================================================================= -/*! - * returns true, if can copy the object - */ -//============================================================================= -CORBA::Boolean Med_Gen_Driver_i::CanPaste (const char* theComponentName, CORBA::Long theObjectID) -{ - // The MED component can paste only objects copied by MED component - // and with the object type = 1 (mesh) - if (strcmp(theComponentName, ComponentDataType()) != 0 || theObjectID != 1) return false; - return true; -} - -//============================================================================= -/*! - * returns true, if can copy the object - */ -//============================================================================= -SALOMEDS::SObject_ptr Med_Gen_Driver_i::PasteInto (const SALOMEDS::TMPFile& theStream, - CORBA::Long theObjectID, - SALOMEDS::SObject_ptr theObject) -{ - SALOMEDS::SObject_var aResultSO = SALOMEDS::SObject::_duplicate(theObject); - if (theStream.length() == 0) return aResultSO._retn(); - - SALOMEDS::Study_var aStudy = theObject->GetStudy(); - - CORBA::String_var aTmpDir = CORBA::string_dup(SALOMEDS_Tool::GetTmpDir().c_str()); - char* aFullName2 = new char[strlen(aTmpDir)+1]; - strcpy(aFullName2,aTmpDir); - // SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false); - SALOMEDS::ListOfFileNames_var aSeq = SALOMEDS_Tool::PutStreamToFiles(theStream, aFullName2, false); - CORBA::String_var aMeshName = CORBA::string_dup(aSeq[0]); - char* aFullName = new char[strlen(aTmpDir)+strlen(aMeshName)+1]; - strcpy(aFullName, aTmpDir); - strcpy(aFullName+strlen(aTmpDir), aMeshName); - - MESH * myMesh= new MESH(); - // myMesh->setName(aMeshName.c_str()); - char* aFullMeshName = new char[strlen(aMeshName)+1]; - strcpy(aFullMeshName,aMeshName); - myMesh->setName(aFullMeshName); - MED_MESH_RDONLY_DRIVER myMeshDriver(aFullName, myMesh); - try { - myMeshDriver.setMeshName(aFullMeshName); - myMeshDriver.open(); - } catch (const std::exception & ex) { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - return aResultSO._retn(); - }; - try { - myMeshDriver.read(); - MESSAGE("apres read"); - myMeshDriver.close(); - } catch (const std::exception & ex) { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - return aResultSO._retn(); - }; - // set new mesh name, becouse now there are no possibility to operate meshes with the same names -// srand((unsigned int)time(NULL)); - int aRND = rand(); //Get a random number to present a name of a copied mesh - char aCopiedMeshName[127]; - sprintf(aCopiedMeshName,"MESH_COPY_%d",aRND); - myMesh->setName(aCopiedMeshName); - MESH_i * meshi = new MESH_i(myMesh); - SALOME_MED::MESH_ptr mesh = meshi->_this(); - // add the mesh object in study - meshi->addInStudy(aStudy,mesh); - // get the IOR attribute of just added mesh - CORBA::String_var anIORString = _driver_orb->object_to_string(mesh); - aResultSO = aStudy->FindObjectIOR(anIORString); - - char * aFullName1 = new char[strlen(aTmpDir)+1]; - strcpy(aFullName1,aTmpDir); - // SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aSeq.in(), true); - SALOMEDS_Tool::RemoveTemporaryFiles(aFullName1, aSeq.in(), true); - - return aResultSO._retn(); -} diff --git a/src/MED/Med_Gen_Driver_i.hxx b/src/MED/Med_Gen_Driver_i.hxx deleted file mode 100644 index a713233ca..000000000 --- a/src/MED/Med_Gen_Driver_i.hxx +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// MED MED : implemetation of MED idl descriptions -// File : Med_Gen_Driver_i.hxx -// Author : Paul RASCLE, EDF -// Module : MED - -#ifndef _MED_GEN_DRIVER_I_HXX_ -#define _MED_GEN_DRIVER_I_HXX_ - -#include -#include CORBA_SERVER_HEADER(MED_Gen) -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) - -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - -#include "SALOME_Component_i.hxx" -#include "SALOME_NamingService.hxx" - -#include - -namespace MEDMEM { - class MED_i; -} - -class Med_Gen_Driver_i : public virtual POA_SALOME_MED::MED_Gen_Driver -{ -private: - Med_Gen_Driver_i(); - -public: - // Constructor and Destructor - Med_Gen_Driver_i(CORBA::ORB_ptr orb); - virtual ~Med_Gen_Driver_i(); - - // Get Med object of the study (for persistance) - static MEDMEM::MED_i* GetMED(SALOMEDS::SComponent_ptr theStudy); - - // inherited methods from SALOMEDS::Driver - - SALOMEDS::TMPFile* Save(SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile); - SALOMEDS::TMPFile* SaveASCII(SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile); - - CORBA::Boolean Load(SALOMEDS::SComponent_ptr theComponent, - const SALOMEDS::TMPFile& theStream, - const char* theURL, - bool isMultiFile); - CORBA::Boolean LoadASCII(SALOMEDS::SComponent_ptr theComponent, - const SALOMEDS::TMPFile& theStream, - const char* theURL, - bool isMultiFile); - - void Close(SALOMEDS::SComponent_ptr theComponent); - - char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, - const char* IORString, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII); - char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, - const char* aLocalPersistentID, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII) - throw(SALOME::SALOME_Exception); - - bool CanPublishInStudy(CORBA::Object_ptr theIOR); - - SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject, - CORBA::Object_ptr theObject, - const char* theName) throw (SALOME::SALOME_Exception); - - CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject); - SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID); - - CORBA::Boolean CanPaste(const char* theComponentName, CORBA::Long theObjectID); - SALOMEDS::SObject_ptr PasteInto(const SALOMEDS::TMPFile& theStream, - CORBA::Long theObjectID, - SALOMEDS::SObject_ptr theObject); - - // this method of SALOMEDS::Driver must be implemented in Component - //char* ComponentDataType(); - - // to be defined in Component - virtual Engines::EngineComponent_ptr GetComponentInstance() = 0; - -private: - static std::map _MedCorbaObj; - - CORBA::ORB_ptr _driver_orb; - -protected: - SALOME_NamingService *_NS; -}; - -#endif diff --git a/src/MED/Med_Gen_i.cxx b/src/MED/Med_Gen_i.cxx deleted file mode 100755 index aa3597620..000000000 --- a/src/MED/Med_Gen_i.cxx +++ /dev/null @@ -1,623 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// MED MED : implemetation of MED idl descriptions -// File : Med_Gen_i.cxx -// Author : Paul RASCLE, EDF -// Module : MED - -#include "Med_Gen_i.hxx" -#include "MED_version.h" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Med_i.hxx" -#include "MEDMEM_FieldTemplate_i.hxx" -#include "MEDMEM_Support_i.hxx" - -#include "MEDMEM_Mesh_i.hxx" -#include "MEDMEM_Field.hxx" - -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_Grid.hxx" - - -#include "Utils_SINGLETON.hxx" -#include "OpUtil.hxx" -#include "Utils_CorbaException.hxx" -#include "utilities.h" - -#include "SALOMEDS_Tool.hxx" - -#include -#include -#include - -#include - -using namespace MEDMEM; - -// Initialisation des variables statiques -//string Med_Gen_i::_myFileName=""; -//string Med_Gen_i::_saveFileName=""; - Med_Gen_i* Med_Gen_i::_MEDGen = NULL; - -//============================================================================= -/*! - * default constructor: not for use - */ -//============================================================================= -//Med_Gen_i::Med_Gen_i() -//{ -// MESSAGE("Med_Gen_i::Med_Gen_i"); -//} - -//============================================================================= -/*! - * standard constructor - */ -//============================================================================= -Med_Gen_i::Med_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), - Med_Gen_Driver_i(orb) -{ - MESSAGE("activate object"); - _thisObj = this ; - _id = _poa->activate_object(_thisObj); - - _duringLoad=false; - // get an NamingService interface - //_NS = SINGLETON_::Instance() ; - //ASSERT(SINGLETON_::IsAlreadyExisting()) ; - //_NS->init_orb( _orb ) ; - - //_myMedI = 0; - _MEDGen = this; -} - -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -Med_Gen_i::~Med_Gen_i() -{ - MESSAGE("Med_Gen_i::~Med_Gen_i"); -} - -//============================================================================= -/*! - * GetServant [ static ] - * - * Get servant of the CORBA object - */ -//============================================================================= -PortableServer::ServantBase_var Med_Gen_i::GetServant( CORBA::Object_ptr theObject ) -{ - if( CORBA::is_nil( theObject ) || !_MEDGen || CORBA::is_nil( _MEDGen->_poa ) ) - return NULL; - try { - PortableServer::Servant aServant = _MEDGen->_poa->reference_to_servant( theObject ); - return aServant; - } - catch (...) { - INFOS( "GetServant - Unknown exception was caught!!!" ); - return NULL; - } -} - -//============================================================================= -/*! - * private method : change a study name in SALOMEDS::Study_var - */ -//============================================================================= -SALOMEDS::Study_var Med_Gen_i::studyName2Study(const char* studyName) - throw(SALOME::SALOME_Exception) -{ - string myStudyName(studyName); - - if (myStudyName.size() == 0) - THROW_SALOME_CORBA_EXCEPTION("No Study Name given", \ - SALOME::BAD_PARAM); - - // Get StudyManager Reference, current study, - - CORBA::Object_var obj = _NS->Resolve("/myStudyManager"); - SALOMEDS::StudyManager_var myStudyManager = - SALOMEDS::StudyManager::_narrow(obj); - if(CORBA::is_nil(myStudyManager)) - THROW_SALOME_CORBA_EXCEPTION("No StudyManager Found in NameService", \ - SALOME::BAD_PARAM); - - SALOMEDS::Study_var myStudy = - myStudyManager->GetStudyByName(myStudyName.c_str()); - if (CORBA::is_nil(myStudy)) - THROW_SALOME_CORBA_EXCEPTION("Wrong Study Name", \ - SALOME::BAD_PARAM); - - return SALOMEDS::Study::_duplicate(myStudy) ; -} - -//============================================================================= -/*! - * private method : add Med component in Study (Not MedGen ???) - */ -//============================================================================= -void Med_Gen_i::addInStudy(SALOMEDS::Study_var myStudy) - throw(SALOME::SALOME_Exception) -{ - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - // Create SComponent labelled 'Med' if it doesn't already exit - SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); - if ( CORBA::is_nil(medfather) ) - { - myBuilder->NewCommand(); - // mpv: component label must be created in spite of "Locked" study flag state - bool aLocked = myStudy->GetProperties()->IsLocked(); - if (aLocked) myStudy->GetProperties()->SetLocked(false); - - MESSAGE("Add Component Med"); - medfather = myBuilder->NewComponent("MED"); - SALOMEDS::GenericAttribute_var anAttr = myBuilder->FindOrCreateAttribute(medfather, "AttributeName"); - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - //NRI aName->SetValue("Med"); - - CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); - SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "MED" ); - if ( !Comp->_is_nil() ) { - aName->SetValue( Comp->componentusername() ); - } - - // Utilisation de this deconseillee par Paul ?? - // myBuilder->DefineComponentInstance(medfather,POA_Engines::MED_Gen::_this()); - CORBA::Object_var myO = _poa->id_to_reference(*_id); // this ior... - myBuilder->DefineComponentInstance(medfather,myO); - - if (aLocked) myStudy->GetProperties()->SetLocked(true); - myBuilder->CommitCommand(); - } -} - -//============================================================================= -/*! - * Lit tous les objets contenus dans un fichier med et les lit en memoire - */ -//============================================================================= -SALOME_MED::MED_ptr Med_Gen_i::readStructFile (const char* fileName, - const char* studyName) - throw(SALOME::SALOME_Exception) -{ - beginService("Med_Gen_i::readStructFile"); - - SCRUTE(fileName); - SALOMEDS::Study_var myStudy = studyName2Study(studyName) ; - //if (!_duringLoad) addInStudy(myStudy) ; - - SALOME_MED::MED_ptr myMedIOR ; - try - { - // we create a new MED_i and add in study - //SALOMEDS::SComponent_var theComponent = myStudy->FindComponent("MED"); - //MED_i * myMedI = 0; - //if (CORBA::is_nil(theComponent)) - // myMedI = new MED_i(); - //else - // myMedI = Med_Gen_Driver_i::GetMED(theComponent); - MED_i * myMedI = new MED_i(); - myMedIOR = myMedI->_this() ; -// if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR) ; -// if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,fileName) ; - // create ::MED object, read all and add in study ! - myMedI->init(myStudy,MED_DRIVER,fileName) ; - } - catch (const SALOMEDS::StudyBuilder::LockProtection & ) {} - catch(...) - { - MESSAGE("Erreur a la lecture du fichier"); - THROW_SALOME_CORBA_EXCEPTION("Unable to open File "\ - ,SALOME::BAD_PARAM); - } - - endService("Med_Gen_i::readStructFile"); - return myMedIOR; -} - -//============================================================================= -/*! - * Prepare un Maillage sans le lire en memoire avec stokage dans l'etude - * des champs avec leur type - */ -//============================================================================= -void Med_Gen_i::readStructFileWithFieldType (const char* fileName, - const char* studyName) - throw (SALOME::SALOME_Exception) -{ - beginService("Med_Gen_i::readStructFileWithFieldType"); - SCRUTE(fileName); - SALOMEDS::Study_var myStudy = studyName2Study(studyName) ; - if (!_duringLoad) addInStudy(myStudy) ; - - try - { - // we create a new MED_i and add in study - SALOMEDS::SComponent_var theComponent = myStudy->FindComponent("MED"); - //MED_i * myMedI = 0; - //if (CORBA::is_nil(theComponent)) - // myMedI = new MED_i(); - //else - // myMedI = Med_Gen_Driver_i::GetMED(theComponent); - MED_i * myMedI = new MED_i(); - SALOME_MED::MED_ptr myMedIOR = myMedI->_this(); - if (!_duringLoad) myMedI->addInStudy(myStudy,myMedIOR,theComponent,fileName); - // create ::MED object, read all and add in study ! - myMedI->initWithFieldType(myStudy,MED_DRIVER,fileName); - } - catch (const SALOMEDS::StudyBuilder::LockProtection & ) {} - catch(...) - { - MESSAGE("Erreur a la lecture du fichier"); - THROW_SALOME_CORBA_EXCEPTION("Unable to open File "\ - ,SALOME::BAD_PARAM); - } - - endService("Med_Gen_i::readStructFileWithFieldType"); -} - -//============================================================================= -/*! - * Sert un Maillage - */ -//============================================================================= -SALOME_MED::GMESH_ptr Med_Gen_i::readMeshInFile(const char* fileName, - const char* studyName, - const char* meshName) -throw (SALOME::SALOME_Exception) -{ - beginService("Med_Gen_i::readMeshInFile"); - SCRUTE(fileName); - SALOMEDS::Study_var myStudy = studyName2Study(studyName) ; - -// if (!_duringLoad) addInStudy(myStudy) ; - -// Creation du maillage - - GMESH * myMesh; - - // skl for IPAL14240 - // check mesh or grid: - try { - if ( MEDFILEBROWSER( fileName ).isStructuredMesh( meshName ) ) - myMesh = new GRID(); - else - myMesh = new MESH() ; - } - catch (const std::exception & ex) { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - myMesh = new MESH() ; - }; - - myMesh->setName(meshName); - MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh); - try - { - myMeshDriver.setMeshName(meshName); - myMeshDriver.open(); - } -#if defined(_DEBUG_) || defined(_DEBUG) - catch (const std::exception & ex) -#else - catch (const std::exception &) -#endif - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find this mesh in this file",SALOME::BAD_PARAM); - }; - try - { - myMeshDriver.read(); - MESSAGE("apres read"); - myMeshDriver.close(); - } -#if defined(_DEBUG_) || defined(_DEBUG) - catch (const std::exception & ex) -#else - catch (const std::exception &) -#endif - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to read this mesh in this file",SALOME::BAD_PARAM); - }; - - GMESH_i * meshi = new GMESH_i(myMesh); - //SALOME_MED::MESH_var mesh = SALOME_MED::MESH::_narrow(meshi->_this()); - SALOME_MED::GMESH_ptr mesh = meshi->_this(); - try - { - // add the mesh object in study -// if (!_duringLoad) meshi->addInStudy(myStudy,mesh); - } - catch (const SALOMEDS::StudyBuilder::LockProtection & ) {} - - endService("Med_Gen_i::readMeshInFile"); - return mesh; -} - -//============================================================================= -/*! - * Sert un Champ - */ -//============================================================================= -SALOME_MED::FIELD_ptr Med_Gen_i::readFieldInFile(const char* fileName, - const char* studyName, - const char* fieldName, - CORBA::Long iter, - CORBA::Long ordre) -throw (SALOME::SALOME_Exception) -{ - beginService("Med_Gen_i::readFieldInFile"); - SCRUTE(fileName); - string myStudyName(studyName); - - if (myStudyName.size() == 0) - THROW_SALOME_CORBA_EXCEPTION("No Study Name given", \ - SALOME::BAD_PARAM); - - // Get StudyManager Reference, current study, - - CORBA::Object_var obj = _NS->Resolve("/myStudyManager"); - SALOMEDS::StudyManager_var myStudyManager = - SALOMEDS::StudyManager::_narrow(obj); - ASSERT(! CORBA::is_nil(myStudyManager)); - SALOMEDS::Study_var myStudy = - myStudyManager->GetStudyByName(myStudyName.c_str()); - if (CORBA::is_nil(myStudy)) - THROW_SALOME_CORBA_EXCEPTION("Wrong Study Name", \ - SALOME::BAD_PARAM); - - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); - if (CORBA::is_nil(medfather)) - { - myBuilder->NewCommand(); - // mpv: component label must be created in spite of "Locked" study flag state - bool aLocked = myStudy->GetProperties()->IsLocked(); - if (aLocked) myStudy->GetProperties()->SetLocked(false); - - medfather = myBuilder->NewComponent("MED"); - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow( - myBuilder->FindOrCreateAttribute(medfather, "AttributeName")); - //NRI aName->SetValue("Med"); - - CORBA::Object_var objVarN = _NS->Resolve("/Kernel/ModulCatalog"); - SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN); - SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "MED" ); - if ( !Comp->_is_nil() ) { - aName->SetValue( Comp->componentusername() ); - } - - CORBA::Object_var myO = _poa->id_to_reference(*_id); // this ior... - myBuilder->DefineComponentInstance(medfather,myO); - - if (aLocked) myStudy->GetProperties()->SetLocked(true); - myBuilder->CommitCommand(); - - } - else - MESSAGE("MED dejà dans l étude"); - - MESSAGE("Lecture du fichier ") - SCRUTE(fileName); - - // Creation du champ - - FIELD_ * myField; - MEDFILEBROWSER mymed; - try - { - mymed.readFileStruct(fileName) ; - } - catch (const std::exception & ex) - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find this file ",SALOME::BAD_PARAM); - } - - try - { - vector fieldsNames = mymed.getFieldNames() ; - int numberOfFields = fieldsNames.size(); - int i; - for (i=0; i; break; - case MED_INT32: - case MED_INT64: myField = new FIELD; break; - default: - THROW_SALOME_CORBA_EXCEPTION("Invalid field type",SALOME::BAD_PARAM); - } - myField->setIterationNumber( iter ); - myField->setOrderNumber( ordre ); - myField->addDriver( MED_DRIVER, fileName, fieldName, MED_EN::RDONLY); - - } -#if defined(_DEBUG_) || defined(_DEBUG) - catch (const std::exception & ex) -#else - catch (const std::exception &) -#endif - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find this field in this file",SALOME::BAD_PARAM); - }; - - GMESH* myMesh=0; - try { - string MeshName = mymed.getMeshName( fieldName ); - myMesh = mymed.isStructuredMesh( MeshName ) ? (GMESH*) new GRID : (GMESH*) new MESH; - myMesh->addDriver(MED_DRIVER, fileName, MeshName, MED_EN::RDONLY ); - myMesh->read(); - SCRUTE(myMesh->getName()); - } -#if defined(_DEBUG_) || defined(_DEBUG) - catch (const std::exception & ex) -#else - catch (const std::exception &) -#endif - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to find associated mesh",SALOME::BAD_PARAM); - }; - - med_type_champ type = myField->getValueType() ; - switch (type) - { - case MED_EN::MED_INT32: - { - try - { - ((FIELD*)myField)->read() ; - myField->getSupport()->setMesh( myMesh ); - FIELDTEMPLATE_I * myFieldIntI = new FIELDTEMPLATE_I((FIELD*)myField); - SALOME_MED::FIELD_ptr myFieldIOR = myFieldIntI->_this(); - // if (!_duringLoad) myFieldIntI->addInStudy(myStudy,myFieldIOR) ; - endService("Med_Gen_i::readFieldInFile"); - return myFieldIOR; - } - catch (const SALOMEDS::StudyBuilder::LockProtection &) {} -#if defined(_DEBUG_) || defined(_DEBUG) - catch (const std::exception & ex) -#else - catch (const std::exception &) -#endif - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to read int field",SALOME::BAD_PARAM); - }; - break; - } - case MED_EN::MED_REEL64: - { - try - { - ((FIELD*)myField)->read() ; - myField->getSupport()->setMesh( myMesh ); - FIELDTEMPLATE_I * myFieldDoubleI = new FIELDTEMPLATE_I((FIELD*)myField); - SALOME_MED::FIELD_ptr myFieldIOR = myFieldDoubleI->_this() ; - // if (!_duringLoad) myFieldDoubleI->addInStudy(myStudy,myFieldIOR) ; - endService("Med_Gen_i::readFieldInFile"); - return myFieldIOR; - } - catch (const SALOMEDS::StudyBuilder::LockProtection &) {} - -#if defined(_DEBUG_) || defined(_DEBUG) - catch (const std::exception & ex) -#else - catch (const std::exception &) -#endif - { - MESSAGE("Exception Interceptee : "); - SCRUTE(ex.what()); - THROW_SALOME_CORBA_EXCEPTION("Unable to read double field",SALOME::BAD_PARAM); - }; - break; - } - default: - THROW_SALOME_CORBA_EXCEPTION("Not recognized type of field !",SALOME::BAD_PARAM); - } - - return SALOME_MED::FIELD::_nil(); -} - - -//============================================================================= -/*! - * from Driver - */ -//============================================================================= -Engines::EngineComponent_ptr Med_Gen_i::GetComponentInstance() -{ - return MED_Gen::_this(); -} - -char* Med_Gen_i::ComponentDataType() -{ - MESSAGE("Med_Gen_i::ComponentDataType"); - return CORBA::string_dup("MED") ; /* What is this type ? */ -} - -// Version information -char* Med_Gen_i::getVersion() -{ -#if SALOMEMED_DEVELOPMENT - return CORBA::string_dup(SALOMEMED_VERSION_STR"dev"); -#else - return CORBA::string_dup(SALOMEMED_VERSION_STR); -#endif -} - - - -//============================================================================= -/*! - * C factory, accessible with dlsym, after dlopen - */ -//============================================================================= - -extern "C" MED_EXPORT - PortableServer::ObjectId * MEDEngine_factory( - CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName) -{ - MESSAGE("PortableServer::ObjectId * MedEngine_factory()"); - SCRUTE(interfaceName); - Med_Gen_i * myMed_Gen - = new Med_Gen_i(orb, poa, contId, instanceName, interfaceName); - return myMed_Gen->getId() ; -} diff --git a/src/MED/Med_Gen_i.hxx b/src/MED/Med_Gen_i.hxx deleted file mode 100644 index 2f01b692f..000000000 --- a/src/MED/Med_Gen_i.hxx +++ /dev/null @@ -1,142 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// MED MED : implemetation of MED idl descriptions -// File : Med_Gen_i.hxx -// Author : Paul RASCLE, EDF -// Module : MED - -#ifndef _MED_GEN_I_HXX_ -#define _MED_GEN_I_HXX_ - -#include -#include -#include CORBA_SERVER_HEADER(MED_Gen) -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) - -#include "SALOME_Component_i.hxx" -#include "SALOME_NamingService.hxx" - -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - -#include "Med_Gen_Driver_i.hxx" - -namespace MEDMEM { - class MED_i; -} - -#ifdef WIN32 - #if defined MED_EXPORTS || defined MEDEngine_EXPORTS - #if defined WIN32 - #define MED_EXPORT __declspec( dllexport ) - #else - #define MED_EXPORT - #endif - #else - #if defined WIN32 - #define MED_EXPORT __declspec( dllimport ) - #else - #define MED_EXPORT - #endif - #endif -#else - #define MED_EXPORT -#endif - -class MED_EXPORT Med_Gen_i: - public POA_SALOME_MED::MED_Gen, - public Engines_Component_i, - public Med_Gen_Driver_i -{ -private: - SALOMEDS::Study_var studyName2Study(const char* studyName) - throw(SALOME::SALOME_Exception); - void addInStudy(SALOMEDS::Study_var myStudy) - throw(SALOME::SALOME_Exception); - -public: - //Med_Gen_i(); - Med_Gen_i(CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - PortableServer::ObjectId * contId, - const char *instanceName, - const char *interfaceName); - virtual ~Med_Gen_i(); - - // - SALOME_MED::GMESH_ptr readMeshInFile(const char* fileName, - const char* studyName, - const char* meshName) - throw(SALOME::SALOME_Exception); - - SALOME_MED::FIELD_ptr readFieldInFile(const char* fileName, - const char* studyName, - const char* fieldName, - CORBA::Long iter, - CORBA::Long ordre) - throw(SALOME::SALOME_Exception); - - SALOME_MED::MED_ptr readStructFile(const char* fileName, - const char* studyName) - throw(SALOME::SALOME_Exception); - - void readStructFileWithFieldType(const char* fileName, - const char* studyName) - throw(SALOME::SALOME_Exception); - - // Get last created instance of the class - static Med_Gen_i* GetMEDGen() { return _MEDGen; } - - // Get Med of the study (for persistance) - static SALOME_MED::MED_ptr GetMED(SALOMEDS::SComponent_ptr theStudy); - - // Get object of the CORBA reference - static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject ); - - template - static T DownCast(CORBA::Object_ptr theArg) - { - return dynamic_cast(GetServant(theArg).in()); - } - - // (re)defined methods of Driver - char* ComponentDataType(); - virtual Engines::EngineComponent_ptr GetComponentInstance(); - - // Version information - virtual char* getVersion(); - -private: - //static std::string _myFileName; - //static std::string _saveFileName; - static Med_Gen_i* _MEDGen; // Point to last created instance of the class - -private: - bool _duringLoad; - //int _myStudyID; - //std::string _myStudyName; - - //int myCounter; -}; - -#endif diff --git a/src/MED/Med_Gen_test.py b/src/MED/Med_Gen_test.py deleted file mode 100644 index c23018e6a..000000000 --- a/src/MED/Med_Gen_test.py +++ /dev/null @@ -1,257 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#################################################################################################### -# Test the Med Component: mounting in Memory a .med file and trying to get information through -# the CORBA Med API -#################################################################################################### -# -import string - -import salome - -import SALOME_MED - -from libSALOME_Swig import * -sg = SALOMEGUI_Swig() - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `(i+1)`+'th' - -def changeBlankToUnderScore(stringWithBlank): - blank = ' ' - underscore = '_' - decompString = string.split(stringWithBlank,blank) - length = len(decompString) - stringWithUnderScore = decompString[0] - for i in range(1,length): - stringWithUnderScore += underscore - stringWithUnderScore += decompString[i] - return stringWithUnderScore - -def getMedObjectFromStudy(file): - objNameInStudy = "MED_OBJECT_FROM_FILE_"+file - compNameInStudy= "MED" - listOfSO = salome.myStudy.FindObjectByName(objNameInStudy,compNameInStudy) - listLength = len(listOfSO) - if (listLength == 0) : - print objNameInStudy," cannot be found in the Study under the component ",compNameInStudy - return None - elif (listLength > 1) : - print "there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy - return None - mySO = listOfSO[0] - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getMeshObjectFromStudy(meshName): - objNameInStudy = "/Med/MEDMESH/"+meshName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MESH) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getSupportObjectFromStudy(meshName,supportName): - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDMESH/MEDSUPPORTS_OF_"+meshNameStudy+"/"+supportName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.SUPPORT) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getFieldObjectFromStudy(dt,it,fieldName,supportName,meshName): - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDFIELD/"+fieldName+"/("+str(dt)+","+str(it)+")_ON_"+supportName+"_OF_"+meshNameStudy - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - if (myObj == None): - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -fileName = "cube_hexa8_quad4.med" - -#fileName = "carre_en_quad4_seg2.med" - -medComp=salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -import os - -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -filePathName = os.path.join(filePath, fileName) - -print "Reading the .med file ",filePathName," and pushing corba objects in the SALOME study" -medComp.readStructFileWithFieldType(filePathName,salome.myStudyName) -sg.updateObjBrowser(1) - -print "getting the MED object from the study" -medObj = getMedObjectFromStudy(fileName) - -nbOfMeshes = medObj.getNumberOfMeshes() -meshNames = medObj.getMeshNames() - -print "in this med file there is(are) ",nbOfMeshes," mesh(es):" -for i in range(nbOfMeshes): - meshName = meshNames[i] - print " - the ",print_ord(i)," mesh is named ",meshName - print " getting the MESH object using the API of the corba object MED" - meshObj = medObj.getMeshByName(meshName) - print " getting mesh information (including corba object) using the API of the corba object MESH" - for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL, - SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - nbFam = meshObj.getNumberOfFamilies(entity) - nbGrp = meshObj.getNumberOfGroups(entity) - if (entity == SALOME_MED.MED_NODE): - print " this mesh has ",nbFam," Node Family(ies) and ",nbGrp," Node Group(s)" - elif (entity == SALOME_MED.MED_CELL): - print " ",nbFam," Cell Family(ies) and ",nbGrp," Cell Group(s)" - elif (entity == SALOME_MED.MED_FACE): - print " ",nbFam," Face Family(ies) and ",nbGrp," Face Group(s)" - elif (entity == SALOME_MED.MED_EDGE): - print " ",nbFam," Edge Family(ies) and ",nbGrp," Cell Group(s)" - - if nbFam > 0: - for j in range(nbFam): - familyObj = meshObj.getFamily(entity,j+1) - print familyObj - - if nbGrp > 0: - for j in range(nbGrp): - groupObj = meshObj.getGroup(entity,j+1) - print groupObj - - print "" - print " getting the MESH object from the Study" - meshObj = getMeshObjectFromStudy(meshName) - print meshObj - print " getting mesh information using the API of the corba object MESH but corba objects are obtained from the Study" - for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL, - SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - nbFam = meshObj.getNumberOfFamilies(entity) - nbGrp = meshObj.getNumberOfGroups(entity) - if (entity == SALOME_MED.MED_NODE): - print " this mesh has ",nbFam," Node Family(ies) and ",nbGrp," Node Group(s)" - elif (entity == SALOME_MED.MED_CELL): - print " ",nbFam," Cell Family(ies) and ",nbGrp," Cell Group(s)" - elif (entity == SALOME_MED.MED_FACE): - print " ",nbFam," Face Family(ies) and ",nbGrp," Face Group(s)" - elif (entity == SALOME_MED.MED_EDGE): - print " ",nbFam," Edge Family(ies) and ",nbGrp," Cell Group(s)" - - if nbFam > 0: - for j in range(nbFam): - familyName = (meshObj.getFamily(entity,j+1)).getName() - familyObj = getSupportObjectFromStudy(meshName,familyName) - print familyObj - - if nbGrp > 0: - for j in range(nbGrp): - groupName = (meshObj.getGroup(entity,j+1)).getName() - groupObj = getSupportObjectFromStudy(meshName,groupName) - print groupObj - - print "let's get other SUPPORT object from the Study" - for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL, - SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - - if entity == SALOME_MED.MED_NODE : - entitySupport = "MED_NOEUD" - elif entity == SALOME_MED.MED_CELL : - entitySupport = "MED_MAILLE" - elif entity == SALOME_MED.MED_FACE : - entitySuppor = "MED_FACE" - elif entity == SALOME_MED.MED_EDGE : - entitySupport = "MED_ARETE" - - supportName = "SupportOnAll_"+entitySupport - supportObj = getSupportObjectFromStudy(meshName,supportName) - -nbOfFields = medObj.getNumberOfFields() -print "in the considered .med file there is(are) ",nbOfFields," field(s):" -fieldNames = medObj.getFieldNames() -for i in range(nbOfFields): - fieldName = fieldNames[i] - nbOfIt = medObj.getFieldNumberOfIteration(fieldName) - print " - the ",print_ord(i)," field is name ",fieldName," and has ",nbOfIt," iteration(s)" - for j in range(nbOfIt): - dtitfield = medObj.getFieldIteration(fieldName,j) - dt = dtitfield[0] - it = dtitfield[1] - print " * Iteration:",dt,"Order number:",it - for k in range(nbOfMeshes): - meshName = meshNames[k] - for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL, - SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - if entity == SALOME_MED.MED_NODE : - entitySupport = "MED_NOEUD" - elif entity == SALOME_MED.MED_CELL : - entitySupport = "MED_MAILLE" - elif entity == SALOME_MED.MED_FACE : - entitySuppor = "MED_FACE" - elif entity == SALOME_MED.MED_EDGE : - entitySupport = "MED_ARETE" - supportName = "SupportOnAll_"+entitySupport - print "getting a corba object Field from the study iteration ",dt," order number ",it," on the support ",supportName," from the mesh ",meshName - fieldObj = getFieldObjectFromStudy(dt,it,fieldName,supportName,meshName) - print fieldObj - -print "" -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MED/testMedAlliances.py b/src/MED/testMedAlliances.py deleted file mode 100755 index 9f2ed2468..000000000 --- a/src/MED/testMedAlliances.py +++ /dev/null @@ -1,185 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import salome -import SALOME -import os - -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -import string - -import SALOME_MED - -from libSALOME_Swig import * -sg = SALOMEGUI_Swig() - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `(i+1)`+'th' - -def changeBlankToUnderScore(stringWithBlank): - blank = ' ' - underscore = '_' - decompString = string.split(stringWithBlank,blank) - length = len(decompString) - stringWithUnderScore = decompString[0] - for i in range(1,length): - stringWithUnderScore += underscore - stringWithUnderScore += decompString[i] - return stringWithUnderScore - -def getMedObjectFromStudy(file): - objNameInStudy = "MED_OBJECT_FROM_FILE_"+file - compNameInStudy= "MED" - listOfSO = salome.myStudy.FindObjectByName(objNameInStudy,compNameInStudy) - listLength = len(listOfSO) - if (listLength == 0) : - print objNameInStudy," cannot be found in the Study under the component ",compNameInStudy - return None - elif (listLength > 1) : - print "there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy - return None - mySO = listOfSO[0] - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getMeshObjectFromStudy(meshName): - objNameInStudy = "/Med/MEDMESH/"+meshName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MESH) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getSupportObjectFromStudy(meshName,supportName): - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDMESH/MEDSUPPORTS_OF_"+meshNameStudy+"/"+supportName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.SUPPORT) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getFieldObjectFromStudy(dt,it,fieldName,supportName,meshName): - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDFIELD/"+fieldName+"/("+str(dt)+","+str(it)+")_ON_"+supportName+"_OF_"+meshNameStudy - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - if (myObj == None): - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -medFiles = [] -medFiles.append("ChampsDarcy.med") -medFiles.append("darcy_1.1_res.med") -medFiles.append("darcy_1.3_resCASTEM.med") -medFiles.append("darcy_1.3_resPORFLOW.med") -medFiles.append("darcy_1.3_resTRACES.med") -medFiles.append("darcy2_Castem_EFMH.med") -medFiles.append("darcy2_Castem_qua_EFMH.med") -medFiles.append("darcy2_Castem_qua_VF.med") -medFiles.append("Deff_fdt_5.8_castem_efmh_diff_conc_dom.med") -medFiles.append("Deff_fdt_5.8_castem_vf_diff_conc_dom.med") -medFiles.append("extendedtransport53_triangles.med") -medFiles.append("H_CastCast_EFMH_I129_COUPLEX1.med") -medFiles.append("H_CastCast_VF_I129_COUPLEX1.med") -medFiles.append("H_CastCast_VF_Se79_COUPLEX1.med") -medFiles.append("H_CastPorf_I129_COUPLEX1.med") -medFiles.append("H_CastPorf_Se79_COUPLEX1.med") -medFiles.append("H_PorfCast_EFMH_I129_COUPLEX1.med") -medFiles.append("H_PorfCast_EFMH_Se79_COUPLEX1.med") -medFiles.append("H_PorfPorf_I129_COUPLEX1.med") -medFiles.append("H_Traces_I129_COUPLEX1.med") -medFiles.append("H_Traces_Se79_COUPLEX1.med") -medFiles.append("maillage_5_5_5.med") -medFiles.append("maillage_chemvalIV_cas1_40elts.med") -medFiles.append("Old_ChampsDarcy.med") -medFiles.append("Old_darcy_1.1_res.med") -medFiles.append("Old_darcy_1.3_resCASTEM.med") -medFiles.append("Old_darcy_1.3_resPORFLOW.med") -medFiles.append("Old_darcy_1.3_resTRACES.med") -medFiles.append("Old_darcy2_Castem_EFMH.med") -medFiles.append("Old_darcy2_Castem_qua_EFMH.med") -medFiles.append("Old_darcy2_Castem_qua_VF.med") -medFiles.append("Old_Deff_fdt_5.8_castem_efmh_diff_conc_dom.med") -medFiles.append("Old_Deff_fdt_5.8_castem_vf_diff_conc_dom.med") -medFiles.append("Old_H_CastCast_EFMH_I129_COUPLEX1.med") -medFiles.append("Old_H_CastCast_VF_I129_COUPLEX1.med") -medFiles.append("Old_H_CastCast_VF_Se79_COUPLEX1.med") -medFiles.append("Old_H_CastPorf_I129_COUPLEX1.med") -medFiles.append("Old_H_CastPorf_Se79_COUPLEX1.med") -medFiles.append("Old_H_PorfCast_EFMH_I129_COUPLEX1.med") -medFiles.append("Old_H_PorfCast_EFMH_Se79_COUPLEX1.med") -medFiles.append("Old_H_PorfPorf_I129_COUPLEX1.med") -medFiles.append("Old_H_PorfPorf_Se79_COUPLEX1.med") -medFiles.append("Old_H_Traces_I129_COUPLEX1.med") -medFiles.append("Old_H_Traces_Se79_COUPLEX1.med") -medFiles.append("Old_maillage_chemvalIV_cas1_40elts.med") - -nbOfFiles = len(medFiles) - -med = salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -for i in range(nbOfFiles): - medFile = medFiles[i] - print "Testing with the file ",medFile - medFile = os.path.join(filePath, medFile) - med.readStructFile(medFile,salome.myStudyName) - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MED/testMedAlliances1.py b/src/MED/testMedAlliances1.py deleted file mode 100755 index bbfc76269..000000000 --- a/src/MED/testMedAlliances1.py +++ /dev/null @@ -1,185 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import salome -import SALOME -import os - -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -import string - -import SALOME_MED - -from libSALOME_Swig import * -sg = SALOMEGUI_Swig() - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `(i+1)`+'th' - -def changeBlankToUnderScore(stringWithBlank): - blank = ' ' - underscore = '_' - decompString = string.split(stringWithBlank,blank) - length = len(decompString) - stringWithUnderScore = decompString[0] - for i in range(1,length): - stringWithUnderScore += underscore - stringWithUnderScore += decompString[i] - return stringWithUnderScore - -def getMedObjectFromStudy(file): - objNameInStudy = "MED_OBJECT_FROM_FILE_"+file - compNameInStudy= "MED" - listOfSO = salome.myStudy.FindObjectByName(objNameInStudy,compNameInStudy) - listLength = len(listOfSO) - if (listLength == 0) : - print objNameInStudy," cannot be found in the Study under the component ",compNameInStudy - return None - elif (listLength > 1) : - print "there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy - return None - mySO = listOfSO[0] - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getMeshObjectFromStudy(meshName): - objNameInStudy = "/Med/MEDMESH/"+meshName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MESH) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getSupportObjectFromStudy(meshName,supportName): - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDMESH/MEDSUPPORTS_OF_"+meshNameStudy+"/"+supportName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.SUPPORT) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getFieldObjectFromStudy(dt,it,fieldName,supportName,meshName): - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDFIELD/"+fieldName+"/("+str(dt)+","+str(it)+")_ON_"+supportName+"_OF_"+meshNameStudy - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - if (myObj == None): - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -medFiles = [] -medFiles.append("ChampsDarcy.med") -medFiles.append("darcy_1.1_res.med") -medFiles.append("darcy_1.3_resCASTEM.med") -medFiles.append("darcy_1.3_resPORFLOW.med") -medFiles.append("darcy_1.3_resTRACES.med") -medFiles.append("darcy2_Castem_EFMH.med") -medFiles.append("darcy2_Castem_qua_EFMH.med") -medFiles.append("darcy2_Castem_qua_VF.med") -medFiles.append("Deff_fdt_5.8_castem_efmh_diff_conc_dom.med") -medFiles.append("Deff_fdt_5.8_castem_vf_diff_conc_dom.med") -medFiles.append("extendedtransport53_triangles.med") -medFiles.append("H_CastCast_EFMH_I129_COUPLEX1.med") -medFiles.append("H_CastCast_VF_I129_COUPLEX1.med") -medFiles.append("H_CastCast_VF_Se79_COUPLEX1.med") -medFiles.append("H_CastPorf_I129_COUPLEX1.med") -medFiles.append("H_CastPorf_Se79_COUPLEX1.med") -medFiles.append("H_PorfCast_EFMH_I129_COUPLEX1.med") -medFiles.append("H_PorfCast_EFMH_Se79_COUPLEX1.med") -medFiles.append("H_PorfPorf_I129_COUPLEX1.med") -medFiles.append("H_Traces_I129_COUPLEX1.med") -medFiles.append("H_Traces_Se79_COUPLEX1.med") -medFiles.append("maillage_5_5_5.med") -medFiles.append("maillage_chemvalIV_cas1_40elts.med") -medFiles.append("Old_ChampsDarcy.med") -medFiles.append("Old_darcy_1.1_res.med") -medFiles.append("Old_darcy_1.3_resCASTEM.med") -medFiles.append("Old_darcy_1.3_resPORFLOW.med") -medFiles.append("Old_darcy_1.3_resTRACES.med") -medFiles.append("Old_darcy2_Castem_EFMH.med") -medFiles.append("Old_darcy2_Castem_qua_EFMH.med") -medFiles.append("Old_darcy2_Castem_qua_VF.med") -medFiles.append("Old_Deff_fdt_5.8_castem_efmh_diff_conc_dom.med") -medFiles.append("Old_Deff_fdt_5.8_castem_vf_diff_conc_dom.med") -medFiles.append("Old_H_CastCast_EFMH_I129_COUPLEX1.med") -medFiles.append("Old_H_CastCast_VF_I129_COUPLEX1.med") -medFiles.append("Old_H_CastCast_VF_Se79_COUPLEX1.med") -medFiles.append("Old_H_CastPorf_I129_COUPLEX1.med") -medFiles.append("Old_H_CastPorf_Se79_COUPLEX1.med") -medFiles.append("Old_H_PorfCast_EFMH_I129_COUPLEX1.med") -medFiles.append("Old_H_PorfCast_EFMH_Se79_COUPLEX1.med") -medFiles.append("Old_H_PorfPorf_I129_COUPLEX1.med") -medFiles.append("Old_H_PorfPorf_Se79_COUPLEX1.med") -medFiles.append("Old_H_Traces_I129_COUPLEX1.med") -medFiles.append("Old_H_Traces_Se79_COUPLEX1.med") -medFiles.append("Old_maillage_chemvalIV_cas1_40elts.med") - -nbOfFiles = len(medFiles) - -med=salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -for i in range(nbOfFiles): - medFile = medFiles[i] - print "Testing with the file ",medFile - medFile = os.path.join(filePath, medFile) - med.readStructFileWithFieldType(medFile,salome.myStudyName) - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEMBinTest/CMakeLists.txt b/src/MEDMEMBinTest/CMakeLists.txt deleted file mode 100644 index 2cc7ee9e6..000000000 --- a/src/MEDMEMBinTest/CMakeLists.txt +++ /dev/null @@ -1,242 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INCLUDE_DIRECTORIES( - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${XDR_INCLUDE_DIRS} - ${CPPUNIT_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints - ) - -SET(dumpInterpolation_SOURCES dumpInterpolation.cxx) - -SET(convertToPoly_SOURCES convertToPoly.cxx) - -SET(ensight2med_SOURCES ensight2med.cxx) - -SET(med2ensight_SOURCES med2ensight.cxx) - -SET(med2vtk_SOURCES med2vtk.cxx) - -SET(duplicateMED_SOURCES duplicateMED.cxx) - -SET(medmembin_test_SOURCES med_test.cxx) - -SET(duplicateMEDMESH_SOURCES duplicateMEDMESH.cxx) - -SET(test_write_groups_poly_SOURCES test_write_groups_poly.cxx) - -SET(test_MEDMEM_ModulusArray_SOURCES test_MEDMEM_ModulusArray.cxx) - -SET(test_MEDMEM_Array_SOURCES test_MEDMEM_Array.cxx) - -SET(test_MEDMEM_SkyLineArray_SOURCES test_MEDMEM_SkyLineArray.cxx) - -SET(test_MEDMEM_CellModel_SOURCES test_MEDMEM_CellModel.cxx) - -SET(testUPointerOf_SOURCES tests/testUPointerOf.cxx) - -SET(testUCoordinate_SOURCES tests/testUCoordinate.cxx) - -SET(testUUnit_SOURCES tests/testUUnit.cxx) - -SET(testUGeoNameMeshEntities_SOURCES tests/testUGeoNameMeshEntities.cxx) - -SET(testUMedException_SOURCES tests/testUMedException.cxx) - -SET(testUModulusArray_SOURCES tests/testUModulusArray.cxx) - -SET(testUSkyLineArray_SOURCES tests/testUSkyLineArray.cxx) - -SET(testUArray_SOURCES tests/testUArray.cxx) - -SET(testUCellModel_SOURCES tests/testUCellModel.cxx) - -SET(readEntete_SOURCES tests/readEntete.cxx) - -SET(readCoordinate_SOURCES tests/readCoordinate.cxx) - -SET(test_copie_field__SOURCES test_copie_field_.cxx) - -SET(test_copie_fieldT_SOURCES test_copie_fieldT.cxx) - -SET(test_copie_coordinate_SOURCES test_copie_coordinate.cxx) - -SET(test_copie_medarray_SOURCES test_copie_medarray.cxx) - -SET(test_copie_connectivity_SOURCES test_copie_connectivity.cxx) - -SET(test_copie_support_SOURCES test_copie_support.cxx) - -SET(test_copie_family_SOURCES test_copie_family.cxx) - -SET(test_copie_group_SOURCES test_copie_group.cxx) - -SET(test_copie_mesh_SOURCES test_copie_mesh.cxx) - -SET(test_affect_medarray_SOURCES test_affect_medarray.cxx) - -SET(test_MEDMEM_Meshing_SOURCES test_MEDMEM_Meshing.cxx) - -SET(test_MEDMEM_MeshingPoly_SOURCES test_MEDMEM_MeshingPoly.cxx) - -SET(test_operation_fielddouble_SOURCES test_operation_fielddouble.cxx) - -SET(test_operation_fieldint_SOURCES test_operation_fieldint.cxx) - -SET(test_gibi_driver_SOURCES test_gibi_driver.cxx) - -SET(test_porflow_driver_SOURCES test_porflow_driver.cxx) - -SET(test_grid_SOURCES test_grid.cxx) - -SET(test_MEDMEM_PolyDriverMedMeshRead_SOURCES test_MEDMEM_PolyDriverMedMeshRead.cxx) - -SET(test_MEDMEM_PolyDriverMedMeshWrite_SOURCES test_MEDMEM_PolyDriverMedMeshWrite.cxx) - -SET(test_MEDMEM_poly3D_SOURCES test_MEDMEM_poly3D.cxx) - -SET(test_MEDMEM_nArray_SOURCES test_MEDMEM_nArray.cxx) - -SET(test_MEDMEM_Meshing_poly_SOURCES test_MEDMEM_Meshing_poly.cxx) - -SET(test_profil_MedFieldDriver_SOURCES test_profil_MedFieldDriver.cxx) - -SET(test_profil_gauss_MedFieldDriver_SOURCES test_profil_gauss_MedFieldDriver.cxx) - -SET(test_GaussLocalization_SOURCES test_GaussLocalization.cxx) - -SET(testAnalFile_SOURCES testAnalFile.cxx) - -SET(test_MEDMEM_MeshingFlica_SOURCES test_MEDMEM_MeshingFlica.cxx) - -SET(testConvertPolygon_SOURCES testConvertPolygon.cxx) -SET(create_mesh_SOURCES create_mesh.c) -SET(create_mesh_c2q4s2_SOURCES create_mesh_c2q4s2.c) -SET(create_mesh_c3h8q4_SOURCES create_mesh_c3h8q4.c) -SET(create_mesh_c3h8q4_wrong_SOURCES create_mesh_c3h8q4_wrong.c) -SET(create_mesh_c2q4s2_wrong_SOURCES create_mesh_c2q4s2_wrong.c) -SET(create_grid_SOURCES create_grid.c) -SET(create_mesh_c2q4_SOURCES create_mesh_c2q4.c) -SET(create_mesh_c3h8_SOURCES create_mesh_c3h8.c) -SET(create_poly3D_SOURCES create_poly3D.c) - -SET(ALLMEDMEMBIN_TESTS - dumpInterpolation - convertToPoly - ensight2med - med2ensight - med2vtk - duplicateMED - medmembin_test - duplicateMEDMESH - test_write_groups_poly - test_MEDMEM_ModulusArray - test_MEDMEM_Array - test_MEDMEM_SkyLineArray - test_MEDMEM_CellModel - testUPointerOf - testUCoordinate - testUUnit - testUGeoNameMeshEntities - testUMedException - testUModulusArray - testUSkyLineArray - testUArray - testUCellModel - readEntete - readCoordinate - test_copie_field_ - test_copie_fieldT - test_copie_coordinate - test_copie_medarray - test_copie_connectivity - test_copie_support - test_copie_family - test_copie_group - test_copie_mesh - test_affect_medarray - test_MEDMEM_Meshing - test_MEDMEM_MeshingPoly - test_operation_fielddouble - test_operation_fieldint - test_gibi_driver - test_porflow_driver - test_grid - test_MEDMEM_PolyDriverMedMeshRead - test_MEDMEM_PolyDriverMedMeshWrite - test_MEDMEM_poly3D - test_MEDMEM_nArray - test_MEDMEM_Meshing_poly - test_profil_MedFieldDriver - test_profil_gauss_MedFieldDriver - test_GaussLocalization - testAnalFile - test_MEDMEM_MeshingFlica - testConvertPolygon - create_mesh - create_mesh_c2q4s2 - create_mesh_c3h8q4 - create_mesh_c3h8q4_wrong - create_mesh_c2q4s2_wrong - create_grid - create_mesh_c2q4 - create_mesh_c3h8 - create_poly3D - ) - -FOREACH(ALLMEDMEMBIN_TEST ${ALLMEDMEMBIN_TESTS}) - ADD_EXECUTABLE(${ALLMEDMEMBIN_TEST} ${${ALLMEDMEMBIN_TEST}_SOURCES}) - SET_TARGET_PROPERTIES(${ALLMEDMEMBIN_TEST} PROPERTIES COMPILE_FLAGS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") - TARGET_LINK_LIBRARIES(${ALLMEDMEMBIN_TEST} medmem ${PLATFORM_LIBS}) -ENDFOREACH(ALLMEDMEMBIN_TEST ${ALLMEDMEMBIN_TESTS}) - -INSTALL(TARGETS ${ALLMEDMEMBIN_TESTS} DESTINATION ${MED_salomebin_BINS}) - -SET(MEDMEMBINTEST_PYOPT_TEST -c"import sys;import os;import subprocess;os.putenv(\"srcdir\",sys.argv[1]);sys.exit(subprocess.call([\"sh\",sys.argv[2]]))") - -ADD_TEST(check_convertToPoly ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_convertToPoly) -ADD_TEST(check_duplicateMED ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_duplicateMED) -ADD_TEST(check_ensight2med ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_ensight2med) -ADD_TEST(check_med2ensight ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_med2ensight) -ADD_TEST(check_med2vtk ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_med2vtk) -ADD_TEST(check_readCoordinate ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_readCoordinate) -ADD_TEST(check_readEntete ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_readEntete) -ADD_TEST(check_testAnalFile ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_testAnalFile) -ADD_TEST(check_test_MEDMEM_PolyDriverMedMeshRead ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_MEDMEM_PolyDriverMedMeshRead) -ADD_TEST(check_test_MEDMEM_PolyDriverMedMeshWrite ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_MEDMEM_PolyDriverMedMeshWrite) -ADD_TEST(check_test_MEDMEM_poly3D ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_MEDMEM_poly3D) -ADD_TEST(check_test_copie_connectivity ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_copie_connectivity) -ADD_TEST(check_test_copie_family ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_copie_family) -ADD_TEST(check_test_copie_fieldT ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_copie_fieldT) -ADD_TEST(check_test_copie_field_ ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_copie_field_) -ADD_TEST(check_test_copie_group ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_copie_group) -ADD_TEST(check_test_copie_mesh ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_copie_mesh) -ADD_TEST(check_test_copie_support ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_copie_support) -ADD_TEST(check_test_gibi_driver ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_gibi_driver) -ADD_TEST(check_test_grid ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_grid) -ADD_TEST(check_test_operation_fielddouble ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_operation_fielddouble) -ADD_TEST(check_test_operation_fieldint ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_operation_fieldint) -ADD_TEST(check_test_porflow_driver ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_porflow_driver) -ADD_TEST(check_test_profil_MedFieldDriver ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_profil_MedFieldDriver) -ADD_TEST(check_test_profil_gauss_MedFieldDriver ${PYTHON_EXECUTABLE} ${MEDMEMBINTEST_PYOPT_TEST} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/check_test_profil_gauss_MedFieldDriver) diff --git a/src/MEDMEMBinTest/Makefile.am b/src/MEDMEMBinTest/Makefile.am deleted file mode 100644 index 9bec086a4..000000000 --- a/src/MEDMEMBinTest/Makefile.am +++ /dev/null @@ -1,211 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MEDMEM : MED files in memory -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -# first '.' says that this folder must be compiled before Test (MEDMEM/Test uses MEDMEM) -#if CPPUNIT_IS_OK -# SUBDIRS=. Test -#endif - -#DIST_SUBDIRS= Test - -#lib_LTLIBRARIES= libMEDMEMBinTest.la - - -#libmedmem_la_LDFLAGS= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -#libMEDMEMBinTest_la_CPPFLAGS= $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ -# -I$(srcdir)/../MEDWrapper/Base \ -# -I$(srcdir)/../MEDWrapper/V2_1/Core -I$(srcdir)/../INTERPOLATION - -# change motivated by the bug KERNEL4778. -#libMEDMEMBinTest_la_LDFLAGS=$(MED3_LIBS_C_ONLY) $(HDF5_LIBS) ../MEDWrapper/V2_1/Core/libmed_V2_1.la \ -# ../MEDWrapper/Base/libMEDWrapperBase.la $(STDLIB) -#if MED_ENABLE_KERNEL -# libMEDMEMBinTest_la_CPPFLAGS+= ${KERNEL_CXXFLAGS} -# libMEDMEMBinTest_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace -#endif - -AM_CPPFLAGS += $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/GaussPoints \ - -I$(srcdir)/../MEDMEM - -LDADD= $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) \ - $(STDLIB) ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la - - -if MED_ENABLE_KERNEL - AM_CPPFLAGS+= ${KERNEL_CXXFLAGS} - LDADD+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace -lSALOMEBasics -endif - - -bin_PROGRAMS= \ - ensight2med med2ensight convertToPoly dumpInterpolation \ - med2vtk duplicateMED medmembin_test duplicateMEDMESH test_write_groups_poly\ - test_MEDMEM_ModulusArray test_MEDMEM_Array test_MEDMEM_SkyLineArray \ - test_MEDMEM_CellModel testUPointerOf testUCoordinate testUUnit \ - testUGeoNameMeshEntities testUMedException testUModulusArray \ - testUSkyLineArray testUArray testUCellModel readEntete readCoordinate \ - test_copie_field_ test_copie_fieldT test_copie_coordinate \ - test_copie_medarray test_copie_connectivity test_copie_support \ - test_copie_family test_copie_group test_copie_mesh test_affect_medarray \ - test_MEDMEM_Meshing test_MEDMEM_MeshingPoly test_operation_fielddouble \ - test_operation_fieldint test_gibi_driver test_porflow_driver \ - test_grid \ - test_MEDMEM_PolyDriverMedMeshRead test_MEDMEM_PolyDriverMedMeshWrite \ - test_MEDMEM_poly3D test_MEDMEM_nArray test_MEDMEM_Meshing_poly test_profil_MedFieldDriver \ - test_profil_gauss_MedFieldDriver test_GaussLocalization testAnalFile test_MEDMEM_MeshingFlica testConvertPolygon \ - create_mesh create_mesh_c2q4s2 create_mesh_c3h8q4 create_mesh_c3h8q4_wrong \ - create_mesh_c2q4s2_wrong create_grid create_mesh_c2q4 create_mesh_c3h8 create_poly3D - -#AM_CPPFLAGS= $(libMEDMEMBinTest_la_CPPFLAGS) -#LDADD= $(libMEDMEMBinTest_la_LDFLAGS) -lm libMEDMEMBinTest.la - -TESTS = $(bin_PROGRAMS) - -# tests that fail because they require arguments -XFAIL_TESTS = \ - dumpInterpolation \ - convertToPoly \ - duplicateMED \ - duplicateMEDMESH \ - ensight2med \ - med2ensight \ - med2vtk \ - medmembin_test \ - readCoordinate \ - readEntete \ - testAnalFile \ - test_MEDMEM_PolyDriverMedMeshRead \ - test_MEDMEM_PolyDriverMedMeshWrite \ - test_MEDMEM_poly3D \ - test_copie_connectivity \ - test_copie_family \ - test_copie_fieldT \ - test_copie_field_ \ - test_copie_group \ - test_copie_mesh \ - test_copie_support \ - test_gibi_driver \ - test_grid \ - test_operation_fielddouble \ - test_operation_fieldint \ - test_porflow_driver \ - test_profil_MedFieldDriver \ - test_profil_gauss_MedFieldDriver - -# scripts running tests with appropriate arguments -SCRIPT_TESTS = \ - scripts/check_convertToPoly \ - scripts/check_duplicateMED \ - scripts/check_ensight2med \ - scripts/check_med2ensight \ - scripts/check_med2vtk \ - scripts/check_readCoordinate \ - scripts/check_readEntete \ - scripts/check_testAnalFile \ - scripts/check_test_MEDMEM_PolyDriverMedMeshRead \ - scripts/check_test_MEDMEM_PolyDriverMedMeshWrite \ - scripts/check_test_MEDMEM_poly3D \ - scripts/check_test_copie_connectivity \ - scripts/check_test_copie_family \ - scripts/check_test_copie_fieldT \ - scripts/check_test_copie_field_ \ - scripts/check_test_copie_group \ - scripts/check_test_copie_mesh \ - scripts/check_test_copie_support \ - scripts/check_test_gibi_driver \ - scripts/check_test_grid \ - scripts/check_test_operation_fielddouble \ - scripts/check_test_operation_fieldint \ - scripts/check_test_porflow_driver \ - scripts/check_test_profil_MedFieldDriver \ - scripts/check_test_profil_gauss_MedFieldDriver - -TESTS_ENVIRONMENT = $(SHELL) - -TESTS += $(SCRIPT_TESTS) - -#if MED_ENABLE_KERNEL -# LDADD+=-lSALOMEBasics -#endif - -dist_dumpInterpolation_SOURCES= dumpInterpolation.cxx -dist_convertToPoly_SOURCES= convertToPoly.cxx -dist_ensight2med_SOURCES= ensight2med.cxx -dist_med2ensight_SOURCES= med2ensight.cxx -dist_med2vtk_SOURCES= med2vtk.cxx -dist_duplicateMED_SOURCES= duplicateMED.cxx -dist_medmembin_test_SOURCES= med_test.cxx -dist_duplicateMEDMESH_SOURCES= duplicateMEDMESH.cxx -dist_test_write_groups_poly_SOURCES= test_write_groups_poly.cxx -dist_test_MEDMEM_ModulusArray_SOURCES= test_MEDMEM_ModulusArray.cxx -dist_test_MEDMEM_Array_SOURCES= test_MEDMEM_Array.cxx -dist_test_MEDMEM_SkyLineArray_SOURCES= test_MEDMEM_SkyLineArray.cxx -dist_test_MEDMEM_CellModel_SOURCES= test_MEDMEM_CellModel.cxx -dist_testUPointerOf_SOURCES= tests/testUPointerOf.cxx -dist_testUCoordinate_SOURCES= tests/testUCoordinate.cxx -dist_testUUnit_SOURCES= tests/testUUnit.cxx -dist_testUGeoNameMeshEntities_SOURCES= tests/testUGeoNameMeshEntities.cxx -dist_testUMedException_SOURCES= tests/testUMedException.cxx -dist_testUModulusArray_SOURCES= tests/testUModulusArray.cxx -dist_testUSkyLineArray_SOURCES= tests/testUSkyLineArray.cxx -dist_testUArray_SOURCES= tests/testUArray.cxx -dist_testUCellModel_SOURCES= tests/testUCellModel.cxx -dist_readEntete_SOURCES= tests/readEntete.cxx -dist_readCoordinate_SOURCES= tests/readCoordinate.cxx -dist_test_copie_field__SOURCES= test_copie_field_.cxx -dist_test_copie_fieldT_SOURCES= test_copie_fieldT.cxx -dist_test_copie_coordinate_SOURCES= test_copie_coordinate.cxx -dist_test_copie_medarray_SOURCES= test_copie_medarray.cxx -dist_test_copie_connectivity_SOURCES= test_copie_connectivity.cxx -dist_test_copie_support_SOURCES= test_copie_support.cxx -dist_test_copie_family_SOURCES= test_copie_family.cxx -dist_test_copie_group_SOURCES= test_copie_group.cxx -dist_test_copie_mesh_SOURCES= test_copie_mesh.cxx -dist_test_affect_medarray_SOURCES= test_affect_medarray.cxx -dist_test_MEDMEM_Meshing_SOURCES= test_MEDMEM_Meshing.cxx -dist_test_MEDMEM_MeshingPoly_SOURCES= test_MEDMEM_MeshingPoly.cxx -dist_test_operation_fielddouble_SOURCES= test_operation_fielddouble.cxx -dist_test_operation_fieldint_SOURCES= test_operation_fieldint.cxx -dist_test_gibi_driver_SOURCES= test_gibi_driver.cxx -dist_test_porflow_driver_SOURCES= test_porflow_driver.cxx -dist_test_grid_SOURCES= test_grid.cxx -dist_test_MEDMEM_PolyDriverMedMeshRead_SOURCES= test_MEDMEM_PolyDriverMedMeshRead.cxx -dist_test_MEDMEM_PolyDriverMedMeshWrite_SOURCES= test_MEDMEM_PolyDriverMedMeshWrite.cxx -dist_test_MEDMEM_poly3D_SOURCES= test_MEDMEM_poly3D.cxx -dist_test_MEDMEM_nArray_SOURCES= test_MEDMEM_nArray.cxx -dist_test_MEDMEM_Meshing_poly_SOURCES= test_MEDMEM_Meshing_poly.cxx -dist_test_profil_MedFieldDriver_SOURCES= test_profil_MedFieldDriver.cxx -dist_test_profil_gauss_MedFieldDriver_SOURCES= test_profil_gauss_MedFieldDriver.cxx -dist_test_GaussLocalization_SOURCES= test_GaussLocalization.cxx -dist_testAnalFile_SOURCES= testAnalFile.cxx -dist_test_MEDMEM_MeshingFlica_SOURCES= test_MEDMEM_MeshingFlica.cxx -dist_testConvertPolygon_SOURCES=testConvertPolygon.cxx - -OBSOLETE_FILES = \ - create_poly2D.c \ - testAG.cxx - -EXTRA_DIST += $(OBSOLETE_FILES) $(SCRIPT_TESTS) diff --git a/src/MEDMEMBinTest/convertToPoly.cxx b/src/MEDMEMBinTest/convertToPoly.cxx deleted file mode 100755 index cd0c36165..000000000 --- a/src/MEDMEMBinTest/convertToPoly.cxx +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Mesh.hxx" -#include - -using namespace MED_EN; -using namespace MEDMEM; -using namespace std; - -int main(int argc, char** argv) -{ - if( argc != 4 ) - { - cout << "Usage: convertToPoly input_med_file output_med_file mesh_name" << endl; - return -1; - } - else - { - string filename(argv[1]); - string meshname(argv[3]); - string outputfilename(argv[2]); - - MESH *mesh=new MESH(MED_DRIVER, filename, meshname); - - mesh->convertToPoly(); - - int id = mesh->addDriver(MED_DRIVER,outputfilename,meshname); - mesh->write(id); - mesh->removeReference(); - return 0; - } -} diff --git a/src/MEDMEMBinTest/create_grid.c b/src/MEDMEMBinTest/create_grid.c deleted file mode 100644 index e9628c987..000000000 --- a/src/MEDMEMBinTest/create_grid.c +++ /dev/null @@ -1,443 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/*---------------------------------------------------------------------------- - MED MEDMEM : MED files in memory - - File : create_grid.c - Module : MED -----------------------------------------------------------------------------*/ - -/****************************************************************************** - * - Nom du fichier : test19.c - * - * - Description : ecriture des objets MED relatifs aux grilles - * MED V2.0 - * - *****************************************************************************/ - -#include -#include -#include - -/****************************************************************************** - * - creation d'un fichier MED - * - ecriture des noeuds : coordonnees en mode MED_FULL_INTERLACE, - * noms,numeros,numeros de familles - * - ecriture des familles d'un maillage MED - * 2.0 via les routines de bas niveau - * - fermeture du fichier - *****************************************************************************/ - -int main (int argc, char **argv) -{ - - /* Ecriture d'un premier maillage non structure (test14 + test8) - ************************************************************** */ - - med_err ret; - med_idt fid; - /* la dimension du maillage */ - med_int mdim = 2; - /* nom du maillage de longueur maxi MED_TAILLE_NOM */ - char maa[MED_NAME_SIZE+1] = "maa1"; - /* description du maillage de longueur maxi MED_TAIIL_DESC */ - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage structure 2D"; - /* le nombre de noeuds */ - med_int nnoe = 4; - /* table des coordonnees - profil : (dimension * nombre de noeuds) */ - med_float coo[8] = {0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0, 1.0}; - med_int nbr[2] = {2, 2}; - /* tables des noms et des unites des coordonnees - profil : (dimension*MED_TAILLE_PNOM+1) */ - char nomcoo[2*MED_SNAME_SIZE+1] = "x y "; - char unicoo[2*MED_SNAME_SIZE+1] = "cm cm "; - - char nomcooi[MED_SNAME_SIZE+1] = "x "; - char unicooi[MED_SNAME_SIZE+1] = "cm "; - /* tables des noms, numeros, numeros de familles des noeuds - autant d'elements que de noeuds - les noms ont pout longueur - MED_SNAME_SIZE */ -// char nomnoe[4*MED_SNAME_SIZE+1] = "nom1 nom2 nom3 nom4 "; -// med_int numnoe[4] = {1,2,3,4}; - med_int nufano[4] = {0,1,2,2}; - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - int i, ip1; - int nfame = 1; - int nfamn = 2; - med_int famNodeStd[4]; - med_int famElmtStd[1]; - med_int famFaceStd[4]; - med_int famNodeCart[16]; - med_int famElmtCart[9]; - med_int famFaceCart[24]; - /* - les elements: - */ - med_int nquad4 = 1; - med_int quad4[4] = { - 1, 2, 4, 3 - }; - // char nomquad4[MED_SNAME_SIZE*1+1] = "quad1 "; - // med_int numquad4[1] = {1}; - med_int nufaquad4[1] = {-1}; - - fid = MEDfileOpen("test19.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /* creation du maillage maa de dimension 2 */ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - - /* ecriture des noeuds d'un maillage MED : - - des coo en mode MED_FULL_INTERLACE : (X1,Y1,X2,Y2,X3,Y3,...) - dans un repere cartesien - - des noms (optionnel dans un fichier MED) - - des numeros (optionnel dans un fichier MED) - - des numeros de familles des noeuds */ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("MEDelementsEcr : %d\n",ret); - - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("MEDfamCr : %d \n",ret); - - /* on cree pour correspondre aux cas tests precedents, 3 familles - d'elements (-1,-2,-3) et deux familles de noeuds (1,2) */ - if (ret == 0) - { - nfame = 1; - for (i=0;i -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "maa1"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 3D"; - med_int mdim = 3; - med_int nnoe = 19; - med_float coo[57] = { - 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 2.0, 0.0, 1.0, - 0.0, 2.0, 1.0, - -2.0, 0.0, 1.0, - 0.0, -2.0, 1.0, - 1.0, 1.0, 2.0, - -1.0, 1.0, 2.0, - -1.0, -1.0, 2.0, - 1.0, -1.0, 2.0, - 1.0, 1.0, 3.0, - -1.0, 1.0, 3.0, - -1.0, -1.0, 3.0, - 1.0, -1.0, 3.0, - 1.0, 1.0, 4.0, - -1.0, 1.0, 4.0, - -1.0, -1.0, 4.0, - 1.0, -1.0, 4.0, - 0.0, 0.0, 5.0 - }; - char nomcoo[3*MED_SNAME_SIZE+1] = "x y z "; - char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm "; - //char *nomnoe ; -// med_int numnoe[19] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; - med_int nufano[19] = {1,1,3,3,0,0,2,0,4,0,4,2,4,2,4,2,4,1,3}; - - med_int ntet4 = 12; - med_int tet4[12*4] = { - 1,2,3,6, - 1,2,4,3, - 1,2,5,4, - 1,2,6,5, - 2,7,4,3, - 2,8,5,4, - 2,9,6,5, - 2,10,3,6, - 2,7,3,10, - 2,8,4,7, - 2,9,5,8, - 2,10,6,9 - }; - //char * nomtet4 ; - // med_int numtet4[12] = {1,2,3,4,5,6,7,8,9,10,11,12}; - med_int nufatet4[12] = {-1,-1,-1,-1,0,0,0,0,0,0,-2,-3}; - - med_int npyra5 = 2; - med_int pyra5[5*2] = { - 7,8,9,10,2, - 15,18,17,16,19 - }; - // char nompyra5[MED_TAILLE_PNOM*2+1] = "pyra1 pyra2 "; - // med_int numpyra5[2] = {13,16}; - med_int nufapyra5[2] = {0,-3}; - - med_int nhexa8 = 2; - med_int hexa8[8*2] = { - 11,12,13,14,7,8,9,10, - 15,16,17,18,11,12,13,14 - }; - // char nomhexa8[MED_TAILLE_PNOM*2+1] = "hexa1 hexa2 "; - // med_int numhexa8[2] = {14,15}; - med_int nufahexa8[2] = {0,0}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char gro2[MED_LNAME_SIZE*2+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - int i; - int nfame = 3; - - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[19] = {1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[19] = {1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.}; - med_float fieldnodedouble2[19] = {1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,5.,5.,5.,6.,6.,6.,7.,7.,7.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldoublevector" ; - char champ3_comp[MED_SNAME_SIZE*3+1]="comp1 comp2 comp3 " ; - char champ3_unit[MED_SNAME_SIZE*3+1]="m/s m/s m/s " ; - med_float fieldcelldouble1[12*3] = {1.,1.,1.,2.,2.,2.,3.,3.,3.,4.,4.,4.,0.,0.,0.,1.,1.,1.,0.,0.,0.,1.,1.,1.,1.,1.,1.,0.,0.,0.,1.,1.,1.,0.,0.,0.}; - med_float fieldcelldouble2[2*3] = {5.,5.,0.,1.,0.,1.}; - med_float fieldcelldouble3[2*3] = {6.,6.,1.,0.,1.,0.}; - - char champ4[MED_NAME_SIZE+1]="fieldcelldoublescalar" ; - char champ4_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ4_unit[MED_SNAME_SIZE+1]="m/s " ; - med_float fieldcelldouble4[12] = {1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.}; - med_float fieldcelldouble5[2] = {2.,2.}; - med_float fieldcelldouble6[2] = {3.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("pointe.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - //ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - //MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - - /***************************************************************************/ - /* ecriture des mailles MED_TETRA4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_TETRA4,MED_NODAL,MED_FULL_INTERLACE, - ntet4,tet4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,ntet4,nufatet4); - printf("MEDelementsEcr : %d \n",ret); - - /* ecriture des mailles MED_PYRA5 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_PYRA5,MED_NODAL,MED_FULL_INTERLACE, - npyra5,pyra5); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_PYRA5,npyra5,nufapyra5); - printf("MEDelementsEcr : %d \n",ret); - - /* ecriture des mailles MED_HEXA8 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_HEXA8,MED_NODAL,MED_FULL_INTERLACE, - nhexa8,hexa8); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_HEXA8,nhexa8,nufahexa8); - printf("MEDelementsEcr : %d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("MEDfamCr : %d \n",ret); - - /* on cree : - - 3 familles d'elements (-1,-2,-3) et - - 2 familles de noeuds (1,2) - */ - if (ret == 0) - { - nfame = 3; - for (i=0;i -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "carre_en_quad4"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 2D"; - med_int mdim = 2; - med_int nnoe = 9; - /* - les noeuds: - */ - med_float coo[18] = { - 0.0, 0.0, - 0.5, 0.0, - 1.0, 0.0, - 0.0, 0.5, - 0.5, 0.5, - 1.0, 0.5, - 0.0, 1.0, - 0.5, 1.0, - 1.0, 1.0 - }; - char nomcoo[2*MED_SNAME_SIZE+1] = "x y "; - char unicoo[2*MED_SNAME_SIZE+1] = "cm cm "; - //char *nomnoe ; -// med_int numnoe[9] = {1,2,3,4,5,6,7,8,9}; - med_int nufano[9] = {0,0,0,0,0,0,0,0,0}; - /* - les elements: - */ - med_int nquad4 = 4; - med_int quad4[16] = { - 4, 5, 2, 1, - 5, 6, 3, 2, - 7, 8, 5, 4, - 8, 9, 6, 5 - }; - // char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 "; - // med_int numquad4[4] = {1,2,3,4}; - med_int nufaquad4[4] = {-1,-1,0,0}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.}; - med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldouble" ; - char champ3_comp[MED_SNAME_SIZE*2+1]="comp1 comp2 " ; - char champ3_unit[MED_SNAME_SIZE*2+1]="M/S m/s " ; - med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("carre_en_quad4.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("MEDelementsEcr : %d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("MEDfamCr : %d \n",ret); - - /* on cree : - - 1 familles d'elements de dimension (d) - en fait de face (-10) - */ - - if (ret == 0) - { - numfam = -1; - strcpy(nomfam,"FAMILLE_CELL_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - /***************************************************************************/ - /* - Les champs - */ - if (ret == 0) - { - ret = MEDfieldCr(fid,champ1,MED_INT32,1,champ1_comp,champ1_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ1,MED_NO_DT,MED_NO_IT,0.,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodeint); - - printf("MEDchampEcr : %d \n",ret); - } - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ2,MED_FLOAT64,1,champ2_comp,champ2_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ2,1,MED_NO_IT,1.1 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr1 : %d \n",ret); - ret = MEDfieldValueWr(fid, champ2,2,MED_NO_IT,1.2 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble2); - printf("MEDchampEcr2 : %d \n",ret); - } - } - - /* on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut ! */ - if (ret == 0) - { - ret = MEDfieldValueWr(fid, champ2,MED_NO_DT,MED_NO_IT,0. ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr : %d \n",ret); - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ3,MED_FLOAT64,2,champ3_comp,champ3_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ3,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_QUAD4,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nquad4, (unsigned char *)fieldcelldouble); - printf("MEDchampEcr : %d \n",ret); - } - } - - /***************************************************************************/ - - ret = MEDfermer(fid); - printf("MEDfermer : %d\n",ret); - - if ( getenv("srcdir") ) - /* we are in 'make check' */ - remove( "carre_en_quad4.med" ); - - return 0; -} diff --git a/src/MEDMEMBinTest/create_mesh_c2q4s2.c b/src/MEDMEMBinTest/create_mesh_c2q4s2.c deleted file mode 100644 index f56461673..000000000 --- a/src/MEDMEMBinTest/create_mesh_c2q4s2.c +++ /dev/null @@ -1,297 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - creation d'une geometrie 2d : un cube [0,1]^2 - maillé uniformement en quadrangle reguliers; - avec en plus une partie des aretes (une partie - des arretes de la frontiere) du maillage. - ATTENTION : 3 noeuds dans chaque direction -*/ - -#include -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "carre_en_quad4_seg2"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 2D"; - med_int mdim = 2; - med_int nnoe = 9; - /* - les noeuds: - */ - med_float coo[18] = { - 0.0, 0.0, - 0.5, 0.0, - 1.0, 0.0, - 0.0, 0.5, - 0.5, 0.5, - 1.0, 0.5, - 0.0, 1.0, - 0.5, 1.0, - 1.0, 1.0 - }; - char nomcoo[2*MED_SNAME_SIZE+1] = "x y "; - char unicoo[2*MED_SNAME_SIZE+1] = "cm cm "; - //char *nomnoe ; -// med_int numnoe[9] = {1,2,3,4,5,6,7,8,9}; - med_int nufano[9] = {0,0,0,0,0,0,0,0,0}; - /* - les elements: - */ - med_int nquad4 = 4; - med_int quad4[16] = { - 4, 5, 2, 1, - 5, 6, 3, 2, - 7, 8, 5, 4, - 8, 9, 6, 5 - }; - // char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 "; - // med_int numquad4[4] = {1,2,3,4}; - med_int nufaquad4[4] = {-10,-10,0,0}; - - /* - Les Faces qui dans ce cas (2D) sont des arretes - */ - - med_int nseg2 = 6; - med_int seg2[18] = { - 6, 3, 0, - 8, 9, 0, - 3, 2, 0, - 9, 6, 0, - 2, 5, 0, - 5, 8, 0 - }; - // char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 "; - // med_int numseg2[6] = {1,2,3,4,5,6}; - med_int nufaseg2[6] = {-1,-2,-1,-1,-2,-2}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.}; - med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldouble" ; - char champ3_comp[MED_SNAME_SIZE*2+1]="comp1 comp2 " ; - char champ3_unit[MED_SNAME_SIZE*2+1]="M/S m/s " ; - med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("carre_en_quad4_seg2.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("MEDelementsEcr : %d \n",ret); - - /* ecriture des mailles MED_SEG2 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE, - nseg2,seg2); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,nseg2,nufaseg2); - printf("%d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("%d \n",ret); - - /* on cree : - - 1 familles d'elements de dimension (d-1) - en fait de edge (-1) - - 1 familles d'elements de dimension (d-1) - en fait de edge (-2) - - 1 familles d'elements de dimension (d) - en fait de face (-10) - */ - - if (ret == 0) - { - numfam = -1; - strcpy(nomfam,"FAMILLE_EDGE_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe1"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - if (ret == 0) - { - numfam = -2; - strcpy(nomfam,"FAMILLE_EDGE_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe1"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - if (ret == 0) - { - numfam = -10; - strcpy(nomfam,"FAMILLE_CELL_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - /***************************************************************************/ - /* - Les champs - */ - if (ret == 0) - { - ret = MEDfieldCr(fid,champ1,MED_INT32,1,champ1_comp,champ1_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ1,MED_NO_DT,MED_NO_IT,0.,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodeint); - - printf("MEDchampEcr : %d \n",ret); - } - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ2,MED_FLOAT64,1,champ2_comp,champ2_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ2,1,MED_NO_IT,1.1 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr1 : %d \n",ret); - ret = MEDfieldValueWr(fid, champ2,2,MED_NO_IT,1.2 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble2); - printf("MEDchampEcr2 : %d \n",ret); - } - } - - /* on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !*/ - if (ret == 0) - { - ret = MEDfieldValueWr(fid, champ2,MED_NO_DT,MED_NO_IT,0. ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr : %d \n",ret); - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ3,MED_FLOAT64,2,champ3_comp,champ3_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ3,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_QUAD4,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nquad4, (unsigned char *)fieldcelldouble); - printf("MEDchampEcr : %d \n",ret); - } - } - - /***************************************************************************/ - - ret = MEDfermer(fid); - printf("%d\n",ret); - - if ( getenv("srcdir") ) - /* we are in 'make check' */ - remove( "carre_en_quad4_seg2.med" ); - - return 0; -} diff --git a/src/MEDMEMBinTest/create_mesh_c2q4s2_wrong.c b/src/MEDMEMBinTest/create_mesh_c2q4s2_wrong.c deleted file mode 100644 index c2af63ad7..000000000 --- a/src/MEDMEMBinTest/create_mesh_c2q4s2_wrong.c +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - creation d'une geometrie 2d : un cube [0,1]^2 - maillé uniformement en quadrangle reguliers; - avec en plus une partie des aretes (une partie - des arretes de la frontiere) du maillage. - ATTENTION : 3 noeuds dans chaque direction -*/ - -#include -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "carre_en_quad4_seg2_wrong"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 2D"; - med_int mdim = 2; - med_int nnoe = 9; - /* - les noeuds: - */ - med_float coo[18] = { - 0.0, 0.0, - 0.5, 0.0, - 1.0, 0.0, - 0.0, 0.5, - 0.5, 0.5, - 1.0, 0.5, - 0.0, 1.0, - 0.5, 1.0, - 1.0, 1.0 - }; - char nomcoo[2*MED_SNAME_SIZE+1] = "x y "; - char unicoo[2*MED_SNAME_SIZE+1] = "cm cm "; - /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ - //char *nomnoe ; -// med_int numnoe[9] = {1,2,3,4,5,6,7,8,9}; - med_int nufano[9] = {0,0,0,0,0,0,0,0,0}; - /* - les elements: - */ - med_int nquad4 = 4; - med_int quad4[16] = { - 4, 5, 2, 1, - 5, 6, 3, 2, - 7, 8, 5, 4, - 8, 9, 6, 5 - }; - // char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 "; - // med_int numquad4[4] = {1,2,3,4}; - med_int nufaquad4[4] = {-10,-10,0,0}; - - /* - Les Faces qui dans ce cas (2D) sont des arretes - - a face is wrongly oriented, it is just to test the applidation - duplicateMEDMESH - */ - - med_int nseg2 = 6; - med_int seg2[12] = { - 6, 3, - 8, 9, - 3, 2, - /*9, 6,*/ - 6, 9, - 2, 5, - 5, 8 - }; - // char nomseg2[MED_TAILLE_PNOM*6+1] = "seg1 seg2 seg3 seg4 seg5 seg6 "; - // med_int numseg2[6] = {1,2,3,4,5,6}; - med_int nufaseg2[6] = {-1,-2,-1,-1,-2,-2}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.}; - med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldouble" ; - char champ3_comp[MED_SNAME_SIZE*2+1]="comp1 comp2 " ; - char champ3_unit[MED_SNAME_SIZE*2+1]="M/S m/s " ; - med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("carre_en_quad4_seg2_wrong.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("MEDelementsEcr : %d \n",ret); - - /* ecriture des mailles MED_SEG2 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_SEG2,MED_NODAL,MED_FULL_INTERLACE, - nseg2,seg2); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_SEG2,nseg2,nufaseg2); - printf("MEDelementsEcr : %d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("%d \n",ret); - - /* on cree : - - 1 familles d'elements de dimension (d-1) - en fait de edge (-1) - - 1 familles d'elements de dimension (d-1) - en fait de edge (-2) - - 1 familles d'elements de dimension (d) - en fait de face (-10) - */ - - if (ret == 0) - { - numfam = -1; - strcpy(nomfam,"FAMILLE_EDGE_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe1"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - if (ret == 0) - { - numfam = -2; - strcpy(nomfam,"FAMILLE_EDGE_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe1"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - if (ret == 0) - { - numfam = -10; - strcpy(nomfam,"FAMILLE_CELL_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - /***************************************************************************/ - /* - Les champs - */ - if (ret == 0) - { - ret = MEDfieldCr(fid,champ1,MED_INT32,1,champ1_comp,champ1_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ1,MED_NO_DT,MED_NO_IT,0.,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodeint); - - printf("MEDchampEcr : %d \n",ret); - } - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ2,MED_FLOAT64,1,champ2_comp,champ2_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ2,1,MED_NO_IT,1.1 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr1 : %d \n",ret); - ret = MEDfieldValueWr(fid, champ2,2,MED_NO_IT,1.2 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble2); - printf("MEDchampEcr2 : %d \n",ret); - } - } - - /* on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut !*/ - if (ret == 0) - { - ret = MEDfieldValueWr(fid, champ2,MED_NO_DT,MED_NO_IT,0. ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr : %d \n",ret); - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ3,MED_FLOAT64,2,champ3_comp,champ3_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ3,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_QUAD4,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nquad4, (unsigned char *)fieldcelldouble); - printf("MEDchampEcr : %d \n",ret); - } - } - - /***************************************************************************/ - - ret = MEDfermer(fid); - printf("%d\n",ret); - - if ( getenv("srcdir") ) - /* we are in 'make check' */ - remove( "carre_en_quad4_seg2_wrong.med" ); - - return 0; -} diff --git a/src/MEDMEMBinTest/create_mesh_c3h8.c b/src/MEDMEMBinTest/create_mesh_c3h8.c deleted file mode 100644 index b4ae4bb62..000000000 --- a/src/MEDMEMBinTest/create_mesh_c3h8.c +++ /dev/null @@ -1,293 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - creation d'une geometrie 3d : un cube [0,1]^3 - maillé uniformement en hexahedres reguliers; - avec en plus une partie des faces (une partie - des faces de la frontiere) du maillage. - ATTENTION : 3 noeuds dans chaque direction -*/ - -#include -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "CUBE_EN_HEXA8"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 3D"; - med_int mdim = 3; - med_int nnoe = 27; - /* - les noeuds: - */ - med_float coo[81] = { - 0.0, 0.0, 0.0, - 0.5, 0.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 0.5, 0.0, - 0.5, 0.5, 0.0, - 1.0, 0.5, 0.0, - 0.0, 1.0, 0.0, - 0.5, 1.0, 0.0, - 1.0, 1.0, 0.0, - 0.0, 0.0, 0.5, - 0.5, 0.0, 0.5, - 1.0, 0.0, 0.5, - 0.0, 0.5, 0.5, - 0.5, 0.5, 0.5, - 1.0, 0.5, 0.5, - 0.0, 1.0, 0.5, - 0.5, 1.0, 0.5, - 1.0, 1.0, 0.5, - 0.0, 0.0, 1.0, - 0.5, 0.0, 1.0, - 1.0, 0.0, 1.0, - 0.0, 0.5, 1.0, - 0.5, 0.5, 1.0, - 1.0, 0.5, 1.0, - 0.0, 1.0, 1.0, - 0.5, 1.0, 1.0, - 1.0, 1.0, 1.0 - }; - char nomcoo[3*MED_SNAME_SIZE+1] = "x y z "; - char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm "; - /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ - //char *nomnoe ; -// med_int numnoe[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27}; - med_int nufano[27] = {1,1,1,1,1,1,1,1,1,3,3,3,3,0,3,3,3,3,2,2,2,2,2,2,2,2,2}; - /* - les elements: - */ - med_int nhexa8 = 8; - med_int hexa8[64] = { - 4, 13, 14, 5, 1, 10, 11, 2, - 5, 14, 15, 6, 2, 11, 12, 3, - 7, 16, 17, 8, 4, 13, 14, 5, - 8, 17, 18, 9, 5, 14, 15, 6, - 13, 22, 23, 14, 10, 19, 20, 11, - 14, 23, 24, 15, 11, 20, 21, 12, - 16, 25, 26, 17, 13, 22, 23, 14, - 17, 26, 27, 18, 14, 23, 24, 15 - }; - // char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1 hexa2 hexa3 hexa4 hexa5 hexa6 hexa7 hexa8 "; - // med_int numhexa8[8] = {1,2,3,4,5,6,7,8}; - med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - int i; - int nfame = 1; - int nfamn = 1; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[27] = {1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[27] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.}; - med_float fieldnodedouble2[27] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldouble" ; - char champ3_comp[MED_SNAME_SIZE*3+1]="comp1 comp2 comp3 " ; - char champ3_unit[MED_SNAME_SIZE*3+1]="M/S m/s m/s " ; - med_float fieldcelldouble[8*3] = {0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("cube_hexa8.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_HEXA8 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_HEXA8,MED_NODAL,MED_FULL_INTERLACE, - nhexa8,hexa8); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_HEXA8,nhexa8,nufahexa8); - printf("MEDelementsEcr : %d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("%d \n",ret); - - /* on cree : - - 2 familles d'elements (-1,-2) et - - 3 familles de noeuds (1,2,3) - */ - - if (ret == 0) - { - nfame = 2; - for (i=0;i -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "CUBE_EN_HEXA8_QUAD4"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 3D"; - med_int mdim = 3; - med_int nnoe = 27; - /* - les noeuds: - */ - med_float coo[81] = { - 0.0, 0.0, 0.0, - 0.5, 0.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 0.5, 0.0, - 0.5, 0.5, 0.0, - 1.0, 0.5, 0.0, - 0.0, 1.0, 0.0, - 0.5, 1.0, 0.0, - 1.0, 1.0, 0.0, - 0.0, 0.0, 0.5, - 0.5, 0.0, 0.5, - 1.0, 0.0, 0.5, - 0.0, 0.5, 0.5, - 0.5, 0.5, 0.5, - 1.0, 0.5, 0.5, - 0.0, 1.0, 0.5, - 0.5, 1.0, 0.5, - 1.0, 1.0, 0.5, - 0.0, 0.0, 1.0, - 0.5, 0.0, 1.0, - 1.0, 0.0, 1.0, - 0.0, 0.5, 1.0, - 0.5, 0.5, 1.0, - 1.0, 0.5, 1.0, - 0.0, 1.0, 1.0, - 0.5, 1.0, 1.0, - 1.0, 1.0, 1.0 - }; - char nomcoo[3*MED_SNAME_SIZE+1] = "x y z "; - char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm "; - /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ - //char *nomnoe ; -// med_int numnoe[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27}; - med_int nufano[27] = {1,1,1,1,1,1,1,1,1,3,3,3,3,0,3,3,3,3,2,2,2,2,2,2,2,2,2}; - /* - les elements: - */ - med_int nhexa8 = 8; - med_int hexa8[64] = { - 4, 13, 14, 5, 1, 10, 11, 2, - 5, 14, 15, 6, 2, 11, 12, 3, - 7, 16, 17, 8, 4, 13, 14, 5, - 8, 17, 18, 9, 5, 14, 15, 6, - 13, 22, 23, 14, 10, 19, 20, 11, - 14, 23, 24, 15, 11, 20, 21, 12, - 16, 25, 26, 17, 13, 22, 23, 14, - 17, 26, 27, 18, 14, 23, 24, 15 - }; - // char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1 hexa2 hexa3 hexa4 hexa5 hexa6 hexa7 hexa8 "; - // med_int numhexa8[8] = {1,2,3,4,5,6,7,8}; - med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2}; - - /* - Les Faces qui dans ce cas (2D) sont des arretes - */ - - med_int nquad4 = 8; - med_int quad4[40] = { - 20, 21, 24, 23, 0, - 22, 23, 26, 25, 0, - 19, 20, 23, 22, 0, - 23, 24, 27, 26, 0, - 1 , 4, 5, 2, 0, - 5, 8, 9, 6, 0, - 2, 5, 6, 3, 0, - 7, 8, 5, 4, 0 - }; - - // char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 "; - // med_int numquad4[8] = {1,2,3,4,5,6,7,8}; - med_int nufaquad4[8] = {-3,-3,-3,-3,-4, -4, -4 , -4}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - int i; - int nfame = 1; - int nfamn = 1; - int nfamf = 1; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[27] = {1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[27] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.}; - med_float fieldnodedouble2[27] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldouble" ; - char champ3_comp[MED_SNAME_SIZE*3+1]="comp1 comp2 comp3 " ; - char champ3_unit[MED_SNAME_SIZE*3+1]="M/S m/s m/s " ; - med_float fieldcelldouble[8*3] = {0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("cube_hexa8_quad4.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_HEXA8 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_HEXA8,MED_NODAL,MED_FULL_INTERLACE, - nhexa8,hexa8); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_HEXA8,nhexa8,nufahexa8); - printf("MEDelementsEcr : %d \n",ret); - - /* ecriture des mailles MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("%d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("%d \n",ret); - - /* on cree : - - 2 familles d'elements (-1,-2) et - - 3 familles de noeuds (1,2,3) - - 1 famille(s) d'elements de dimension (d-1) - en fait de face (-3) - */ - - if (ret == 0) - { - nfame = 2; - for (i=0;i -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "CUBE_EN_HEXA8_QUAD4_WRONG"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 3D"; - med_int mdim = 3; - med_int nnoe = 27; - /* - les noeuds: - */ - med_float coo[81] = { - 0.0, 0.0, 0.0, - 0.5, 0.0, 0.0, - 1.0, 0.0, 0.0, - 0.0, 0.5, 0.0, - 0.5, 0.5, 0.0, - 1.0, 0.5, 0.0, - 0.0, 1.0, 0.0, - 0.5, 1.0, 0.0, - 1.0, 1.0, 0.0, - 0.0, 0.0, 0.5, - 0.5, 0.0, 0.5, - 1.0, 0.0, 0.5, - 0.0, 0.5, 0.5, - 0.5, 0.5, 0.5, - 1.0, 0.5, 0.5, - 0.0, 1.0, 0.5, - 0.5, 1.0, 0.5, - 1.0, 1.0, 0.5, - 0.0, 0.0, 1.0, - 0.5, 0.0, 1.0, - 1.0, 0.0, 1.0, - 0.0, 0.5, 1.0, - 0.5, 0.5, 1.0, - 1.0, 0.5, 1.0, - 0.0, 1.0, 1.0, - 0.5, 1.0, 1.0, - 1.0, 1.0, 1.0 - }; - char nomcoo[3*MED_SNAME_SIZE+1] = "x y z "; - char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm "; - /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ - //char *nomnoe ; -// med_int numnoe[27] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27}; - med_int nufano[27] = {1,1,1,1,1,1,1,1,1,3,3,3,3,0,3,3,3,3,2,2,2,2,2,2,2,2,2}; - /* - les elements: - */ - med_int nhexa8 = 8; - med_int hexa8[64] = { - 4, 13, 14, 5, 1, 10, 11, 2, - 5, 14, 15, 6, 2, 11, 12, 3, - 7, 16, 17, 8, 4, 13, 14, 5, - 8, 17, 18, 9, 5, 14, 15, 6, - 13, 22, 23, 14, 10, 19, 20, 11, - 14, 23, 24, 15, 11, 20, 21, 12, - 16, 25, 26, 17, 13, 22, 23, 14, - 17, 26, 27, 18, 14, 23, 24, 15 - }; - // char nomhexa8[MED_TAILLE_PNOM*8+1] = "hexa1 hexa2 hexa3 hexa4 hexa5 hexa6 hexa7 hexa8 "; - // med_int numhexa8[8] = {1,2,3,4,5,6,7,8}; - med_int nufahexa8[8] = {-1,-1,-1,-1,-2,-2,-2,-2}; - - /* - Les Faces qui dans ce cas (2D) sont des arretes - - a face is wrongly oriented, it is just to test the applidation - duplicateMEDMESH - */ - - med_int nquad4 = 8; - med_int quad4[32] = { - 20, 21, 24, 23, - 22, 23, 26, 25, - 19, 20, 23, 22, - 23, 24, 27, 26, - /*1 , 4, 5, 2,*/ - 1 , 2, 5, 4, - 5, 8, 9, 6, - 2, 5, 6, 3, - 7, 8, 5, 4 - }; - - // char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 "; - // med_int numquad4[8] = {1,2,3,4,5,6,7,8}; - med_int nufaquad4[8] = {-3,-3,-3,-3,-4, -4, -4 , -4}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - int i; - int nfame = 1; - int nfamn = 1; - int nfamf = 1; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[27] = {1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5,1,1,3,2,2,3,4,4,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[27] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.,1.,3.,4.,1.,3.,4.,3.,2.,5.}; - med_float fieldnodedouble2[27] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.,1.,2.,2.,3.,3.,3.,4.,4.,5.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldouble" ; - char champ3_comp[MED_SNAME_SIZE*3+1]="comp1 comp2 comp3 " ; - char champ3_unit[MED_SNAME_SIZE*3+1]="M/S m/s m/s " ; - med_float fieldcelldouble[8*3] = {0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.,0.,1.,1.,1.,1.,2.,2.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("cube_hexa8_quad4_wrong.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_HEXA8 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_HEXA8,MED_NODAL,MED_FULL_INTERLACE, - nhexa8,hexa8); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_HEXA8,nhexa8,nufahexa8); - printf("MEDelementsEcr : %d \n",ret); - - /* ecriture des mailles MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("MEDelementsEcr : %d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("%d \n",ret); - - /* on cree : - - 2 familles d'elements (-1,-2) et - - 3 familles de noeuds (1,2,3) - - 1 famille(s) d'elements de dimension (d-1) - en fait de face (-3) - */ - - if (ret == 0) - { - nfame = 2; - for (i=0;i -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "poly2D"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 2D avec 1 polygone"; - med_int mdim = 2; - med_int nnoe = 11; - /* - les noeuds: - */ - med_float coo[22] = { - 0.0, 0.0, - 0.5, 0.0, - 1.0, 0.0, - 0.25, 0.5, - 0.5, 0.5, - 0.75, 0.5, - 0.0, 1.0, - 0.5, 1.0, - 1.0, 1.0, - 1.5, 0.0, - 1.5, 1.0 - }; - char nomcoo[2*MED_SNAME_SIZE+1] = "x y "; - char unicoo[2*MED_SNAME_SIZE+1] = "cm cm "; - /* char nomnoe[19*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ - //char *nomnoe ; -// med_int numnoe[11] = {1,2,3,4,5,6,7,8,9,10,11}; - med_int nufano[11] = {0,0,0,0,0,0,0,0,0,0,0}; - /* - les elements: - */ - med_int nquad4 = 4; - med_int quad4[16] = { - 4, 5, 2, 1, - 5, 6, 3, 2, - 7, 8, 5, 4, - 8, 9, 6, 5 - }; - // char nomquad4[MED_TAILLE_PNOM*4+1] = "quad1 quad2 quad3 quad4 "; - // med_int numquad4[4] = {1,2,3,4}; - med_int nufaquad4[4] = {-1,-1,0,0}; - - med_int ntria3 = 1; - med_int tria3[3] = { - 7, 4, 1 - }; - // char nomtria3[MED_TAILLE_PNOM+1] = "tria1 "; - // med_int numtria3[1] = {1}; - med_int nufatria3[1] = {-2}; - - med_int npoly = 1; - med_int nindexpoly = 2; - med_int indexpoly [2] = { - 1,6 - }; - med_int poly[5] = { - 9,11,10,3,6 - }; - char nompoly[MED_TAILLE_PNOM+1] = "poly "; -// med_int numpoly[1] = {1}; - med_int nufapoly[1] = {-3}; - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - med_int natt; - med_int attide; - med_int attval; - med_int ngro; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - int i; - int nfame = 2; - int nfamn = 1; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[9] = {1,1,3,2,2,3,4,4,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[9] = {1.,3.,4.,1.,3.,4.,3.,2.,5.}; - med_float fieldnodedouble2[9] = {1.,2.,2.,3.,3.,3.,4.,4.,5.}; - - char champ3[MED_NAME_SIZE+1]="fieldcelldouble" ; - char champ3_comp[MED_SNAME_SIZE*2+1]="comp1 comp2 " ; - char champ3_unit[MED_SNAME_SIZE*2+1]="M/S m/s " ; - med_float fieldcelldouble[4*2] = {0.,1.,1.,1.,1.,2.,2.,3.}; - - /***************************************************************************/ - fid = MEDfileOpen("poly2D.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des mailles MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("MEDelementsEcr for quad : %d \n",ret); - - /* ecriture des mailles MED_TRIA3 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE, - ntria3,tria3); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,ntria3,nufatria3); - printf("MEDelementsEcr for tria : %d \n",ret); - - /* ecriture des mailles MED_POLYGONE: - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles - Dans ce cas il n existe pas de routine globale (Warning !!) - */ - - if (ret == 0) - ret = MEDpolygoneConnEcr(fid,maa,indexpoly,nindexpoly,poly, - MED_CELL,MED_NOD); - printf("MEDpolygoneConnEcr: %d \n",ret); - - if (ret == 0) - MEDnomEcr(fid,maa,nompoly,npoly,MED_CELL,MED_POLYGONE); - printf("MEDnomEcr for poly : %d \n",ret); - - if (ret == 0) - MEDnumEcr(fid,maa,numpoly,npoly,MED_CELL,MED_POLYGONE); - printf("MEDnumEcr for poly : %d \n",ret); - - if (ret == 0) - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT, MED_CELL,MED_POLYGONE, npoly,nufapoly); - printf("MEDfamEcr for poly : %d \n",ret); - - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("MEDfamCr : %d \n",ret); - - /* on cree : - - 2 familles d'elements de dimension (d) - en fait de face (-10) - */ - if (ret == 0) - { - numfam = -1; - strcpy(nomfam,"FAMILLE_CELL_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - - numfam = -2; - strcpy(nomfam,"FAMILLE_CELL_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - - numfam = -3; - strcpy(nomfam,"FAMILLE_CELL_"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - - /***************************************************************************/ - /* - Les champs - */ - if (ret == 0) - { - ret = MEDfieldCr(fid,champ1,MED_INT32,1,champ1_comp,champ1_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ1,MED_NO_DT,MED_NO_IT,0.,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodeint); - - printf("MEDchampEcr : %d \n",ret); - } - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ2,MED_FLOAT64,1,champ2_comp,champ2_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ2,1,MED_NO_IT,1.1 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr1 : %d \n",ret); - ret = MEDfieldValueWr(fid, champ2,2,MED_NO_IT,1.2 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble2); - printf("MEDchampEcr2 : %d \n",ret); - } - } - - // on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut ! - if (ret == 0) - { - ret = MEDfieldValueWr(fid, champ2,MED_NO_DT,MED_NO_IT,0. ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr : %d \n",ret); - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ3,MED_FLOAT64,2,champ3_comp,champ3_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ3,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_QUAD4,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nquad4, (unsigned char *)fieldcelldouble); - printf("MEDchampEcr : %d \n",ret); - } - } - - /***************************************************************************/ - - ret = MEDfermer(fid); - printf("MEDfermer : %d\n",ret); - - return 0; -} - diff --git a/src/MEDMEMBinTest/create_poly3D.c b/src/MEDMEMBinTest/create_poly3D.c deleted file mode 100644 index 079e7f926..000000000 --- a/src/MEDMEMBinTest/create_poly3D.c +++ /dev/null @@ -1,423 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - creation d'une geometrie 3d : - maillé en : - - 2 polyedres - ayant pour faces 3 polygones - 9 quadrangles - 6 triangles - - 1 tetra4 - -*/ - -#include -#include -#include - -int main (int argc, char **argv) -{ - med_err ret; - med_idt fid; - char maa[MED_NAME_SIZE+1] = "poly3D"; - char maadesc[MED_COMMENT_SIZE+1] = "Example de maillage non structure 3D avec 2 polyedres+1tetra4 comme mailles et 3 polygones comme faces"; - med_int mdim = 3; - med_int nnoe = 19; - /* - les noeuds: - */ - med_float coo[57] = { - 2.0, 3.0, 2.0, - 3.0, 2.0, 2.0, - 4.0, 1.0, 2.0, - 2.0, 0.0, 2.0, - 0.0, 1.0, 2.0, - 1.0, 2.0, 2.0, - 2.0, 3.0, 1.0, - 3.0, 2.0, 0.0, - 4.0, 1.0, 0.0, - 2.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, 2.0, 0.0, - 5.0, 3.0, 2.0, - 7.0, 2.0, 2.0, - 6.0, 0.0, 2.0, - 6.0, 3.0, 0.0, - 7.0, 2.0, 0.0, - 6.0, 0.0, -1.0, - 5.0, 1.0, -3.0 - }; - char nomcoo[3*MED_SNAME_SIZE+1] = "x y z "; - char unicoo[3*MED_SNAME_SIZE+1] = "cm cm cm "; - /* char nomnoe[18*MED_TAILLE_PNOM+1] = "nom1 nom2 nom3 nom4";*/ - //char *nomnoe ; -// med_int numnoe[19] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19}; - med_int nufano[19] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - /* - les elements: - */ - /* Faces QUAD4 */ - med_int nquad4 = 8; - med_int quad4[32] = { - 1, 7, 8, 2, - 2, 8, 9, 3, - 4, 3, 9, 10, - 5, 4, 10, 11, - 6, 5, 11, 12, - 1, 6, 12, 7, - 14, 13, 16, 17, - 8, 9, 17, 16 - }; - // char nomquad4[MED_TAILLE_PNOM*8+1] = "quad1 quad2 quad3 quad4 quad5 quad6 quad7 quad8 "; - // med_int numquad4[9] = {2,3,4,5,6,7,12,17}; - med_int nufaquad4[9] = {-1,-1,-1,-1,-1,-1,-1,-1}; - - /* Faces TRIA3 */ - med_int ntria3 = 6; - med_int tria3[18] = { - 7, 12, 8, - 15, 14, 17, - 15, 17, 18, - 15, 18, 9, - 3, 15, 9, - 18, 17, 9 - }; - // char nomtria3[MED_TAILLE_PNOM*6+1] = "tria1 tria2 tria3 tria4 tria5 tria6 "; - // med_int numtria3[6] = {8,13,14,15,16,18}; - med_int nufatria3[6] = {-2,-2,-2,-2,-2,-2}; - - /* Faces POLYGONE */ - med_int npolygon = 3; - med_int nindexpolygon = 4; - med_int indexpolygon [4] = { - 1, 7, 12, 17 - }; - med_int polygon[16] = { - 1, 2, 3, 4, 5, 6, - 10, 9, 8, 12, 11, - 13, 14, 15, 3, 2 - }; - //char nompolygon[MED_SNAME_SIZE*3+1] = "polygon1 polygon2 polygon3 "; -// med_int numpolygon[3] = {1,9,10}; - med_int nufapolygon[3] = {-3,-3,-3}; - - /* Mailles POLYEDRE */ - med_int npolyhedron = 2; - med_int npolyhedronfaces = 19; - med_int polyhedronconnectivity[74] = {1,2,3,4,5,6,1,7,8,2,2,8,9,3,4,3,9,10,5,4,10,11,6,5,11,12,1,6,12,7,7,12,8,10,9,8,12,11, - 13,14,15,3,2,13,2,8,16,14,13,16,17,15,14,17,15,17,18,15,18,9,3,15,9,2,3,9,8,8,9,17,16,9,18,17}; - med_int polyhedronfacesindex[20] = {1,7,11,15,19,23,27,31,34, - 39,44,48,52,55,58,61,64,68,72,75}; - med_int polyhedronindex[3] = {1,10,20}; - //char nompolyhedron[MED_SNAME_SIZE*2+1] = "polyhedron1 polyhedron2 "; -// med_int numpolyhedron[2] = {2,3}; - med_int nufapolyhedron[2] = {-4,-4}; - - /* Mailles TETRA4 */ - med_int ntetra4 = 1; - med_int tetra4[4] = { - 17, 9, 18, 19 - }; - // char nomtetra4[MED_SNAME_SIZE*1+1] = "tetra1 "; - // med_int numtetra4[1] = {1}; - med_int nufatetra4[1] = {-5}; - - - char nomfam[MED_NAME_SIZE+1]; - med_int numfam; - //char attdesMED_TAILLE_DESC+1]; - //med_int attide; - //med_int attval; - char gro[MED_LNAME_SIZE+1]; - char dtunitp3[MED_LNAME_SIZE+1]=""; - - /* - Some fields : 2 on nodes : one int and one double , one on cells : double - */ - char champ1[MED_NAME_SIZE+1]="fieldnodeint" ; - char champ1_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ1_unit[MED_SNAME_SIZE+1]="M " ; - med_int fieldnodeint[19] = {1,1,3,2,2,3,4,4,5,6,6,7,8,8,9,9,9,10,5}; - - char champ2[MED_NAME_SIZE+1]="fieldnodedouble" ; - char champ2_comp[MED_SNAME_SIZE+1]="comp1 " ; - char champ2_unit[MED_SNAME_SIZE+1]="J " ; - med_float fieldnodedouble1[19] = {1.,3.,4.,1.,3.,4.,3.,2.,5.,6.,4.,3.,1.,5.,6.,4.,3.,7.,3.}; - med_float fieldnodedouble2[19] = {1.,2.,2.,3.,3.,3.,4.,4.,5.,2.,8.,9.,6.,7.,1.,2.,5.,8.,4.}; - - char champ3[MED_NAME_SIZE+1]="fieldfacedouble" ; - char champ3_comp[MED_SNAME_SIZE*2+1]="comp1 comp2 " ; - char champ3_unit[MED_SNAME_SIZE*2+1]="M/S m/s " ; - med_float fieldfacedouble[6*2] = {0.,1.,1.,1.,1.,2.,2.,3.,3.,4.,4.,6.}; - - /***************************************************************************/ - fid = MEDfileOpen("poly3D.med",MED_ACC_RDWR); - if (fid < 0) - ret = -1; - else - ret = 0; - printf("MEDouvrir : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshCr(fid,maa,mdim,mdim,MED_UNSTRUCTURED_MESH,maadesc,dtunitp3, - MED_SORT_DTIT,MED_CARTESIAN,nomcoo,unicoo); - printf("MEDmaaCr : %d\n",ret); - if (ret == 0) - ret = MEDunvCr(fid,maa); - printf("MEDunvCr : %d\n",ret); - - /***************************************************************************/ - if (ret == 0) - ret = MEDmeshNodeCoordinateWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT,MED_FULL_INTERLACE,nnoe,coo); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NODE,0,nnoe,nufano); - printf("MEDnoeudsEcr : %d\n",ret); - - /* ecriture des faces MED_QUAD4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_QUAD4,MED_NODAL,MED_FULL_INTERLACE, - nquad4,quad4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_QUAD4,nquad4,nufaquad4); - printf("MEDelementsEcr for quad : %d \n",ret); - - /* ecriture des faces MED_TRIA3 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_TRIA3,MED_NODAL,MED_FULL_INTERLACE, - ntria3,tria3); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TRIA3,ntria3,nufatria3); - printf("MEDelementsEcr for tria : %d \n",ret); - - /* ecriture des faces MED_POLYGONE : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles - Dans ce cas il n existe pas de routine globale (Warning !!) */ - if (ret == 0) - ret = MEDmeshPolygonWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, MED_CELL,MED_NODAL, nindexpolygon,indexpolygon,polygon); - printf("MEDpolygoneConnEcr: %d \n",ret); - -/* if (ret == 0) */ -/* MEDnomEcr(fid,maa,nompolygon,npolygon,MED_CELL,MED_POLYGONE); */ -/* printf("MEDnomEcr for polygon : %d \n",ret); */ - -/* if (ret == 0) */ -/* MEDnumEcr(fid,maa,numpolygon,npolygon,MED_CELL,MED_POLYGONE); */ -/* printf("MEDnumEcr for polygon : %d \n",ret); */ - - if (ret == 0) - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT, MED_CELL,MED_POLYGON, npolygon,nufapolygon); - printf("MEDfamEcr for polygon : %d \n",ret); - - /* ecriture des mailles MED_POLYEDRE : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles - Dans ce cas il n existe pas de routine globale (Warning !!) */ - if (ret == 0) - ret = MEDmeshPolyhedronWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, MED_CELL,MED_NODAL, npolyhedronfaces+1,polyhedronfacesindex,npolyhedron+1,polyhedronindex,polyhedronconnectivity); - printf("MEDpolyedreConnEcr: %d \n",ret); - -/* if (ret == 0) */ -/* ret = MEDnomEcr(fid,maa,nompolyhedron,npolyhedron,MED_CELL,MED_POLYEDRE); */ -/* printf("MEDnomEcr for polyhedron : %d \n",ret); */ - -/* if (ret == 0) */ -/* ret = MEDnumEcr(fid,maa,numpolyhedron,npolyhedron,MED_CELL,MED_POLYEDRE); */ -/* printf("MEDnumEcr for polyhedron : %d \n",ret); */ - - if (ret == 0) - ret = MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT, MED_CELL,MED_POLYHEDRON, npolyhedron,nufapolyhedron); - printf("MEDfamEcr for polyhedron : %d \n",ret); - - /* ecriture des mailles TETRA4 : - - connectivite - - noms (optionnel) - - numeros (optionnel) - - numeros des familles */ - if (ret == 0) - ret = MEDmeshElementConnectivityWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_NO_DT, - MED_CELL,MED_TETRA4,MED_NODAL,MED_FULL_INTERLACE, - ntetra4,tetra4); - MEDmeshEntityFamilyNumberWr(fid,maa,MED_NO_DT,MED_NO_IT,MED_CELL,MED_TETRA4,ntetra4,nufatetra4); - printf("MEDelementsEcr for tetra : %d \n",ret); - - /***************************************************************************/ - /* ecriture des familles */ - /* Conventions : - - toujours creer une famille de numero 0 ne comportant aucun attribut - ni groupe (famille de reference pour les noeuds ou les elements - qui ne sont rattaches a aucun groupe ni attribut) - - les numeros de familles de noeuds sont > 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 = MEDfamilyCr(fid,maa,nomfam,numfam,0,gro); - } - printf("MEDfamCr : %d \n",ret); - - /* on cree : - - 2 familles d'elements de dimension (d) - en fait de face (-10) - */ - /* - if (ret == 0) - { - numfam = -1; - strcpy(nomfam,"FAMILLE_FACE_QUAD4"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - - numfam = -2; - strcpy(nomfam,"FAMILLE_FACE_TRIA3"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - - numfam = -3; - strcpy(nomfam,"FAMILLE_FACE_POLYGONS"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - - numfam = -4; - strcpy(nomfam,"FAMILLE_MAILLE_POLYHEDRON"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - - numfam = -5; - strcpy(nomfam,"FAMILLE_MAILLE_TETRA4"); - sprintf(nomfam,"%s%d",nomfam,-numfam); - attide = 1; - attval = numfam*100; - natt = 1; - //strcpy(attdes,"description attribut"); - strcpy(gro,"groupe0"); - ngro = 1; - - ret = MEDfamilyCr(fid,maa,nomfam,numfam,ngro,gro); - printf("MEDfamCr : %d\n",ret); - } - */ - /***************************************************************************/ - /* - Les champs - */ - if (ret == 0) - { - ret = MEDfieldCr(fid,champ1,MED_INT32,1,champ1_comp,champ1_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ1,MED_NO_DT,MED_NO_IT,0.,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodeint); - - printf("MEDchampEcr : %d \n",ret); - } - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ2,MED_FLOAT64,1,champ2_comp,champ2_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ2,1,MED_NO_IT,1.1 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr1 : %d \n",ret); - ret = MEDfieldValueWr(fid, champ2,2,MED_NO_IT,1.2 ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble2); - printf("MEDchampEcr2 : %d \n",ret); - } - } - - /*/ on met champ2 sans pas de temps pour pouvoir le lire aussi par defaut ! */ - if (ret == 0) - { - ret = MEDfieldValueWr(fid, champ2,MED_NO_DT,MED_NO_IT,0. ,MED_NODE,0,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,nnoe, (unsigned char *)fieldnodedouble1); - printf("MEDchampEcr : %d \n",ret); - } - - if (ret == 0) - { - ret = MEDfieldCr(fid,champ3,MED_FLOAT64,2,champ3_comp,champ3_unit,dtunitp3,maa); - printf("MEDchampCr : %d \n",ret); - if (ret == 0) { - ret = MEDfieldValueWr(fid, champ3,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TRIA3,MED_NO_INTERLACE,MED_ALL_CONSTITUENT,ntria3, (unsigned char *)fieldfacedouble); - printf("MEDchampEcr : %d \n",ret); - } - } - /***************************************************************************/ - - ret = MEDfermer(fid); - printf("MEDfermer : %d\n",ret); - - if ( getenv("srcdir") ) - /* we are in 'make check' */ - remove( "poly3D.med" ); - - return 0; -} - diff --git a/src/MEDMEMBinTest/dumpInterpolation.cxx b/src/MEDMEMBinTest/dumpInterpolation.cxx deleted file mode 100644 index 08e7da3b5..000000000 --- a/src/MEDMEMBinTest/dumpInterpolation.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : dumpInterpolation.cxx -// Created : Mon Jan 11 16:46:10 2010 -// Author : Edward AGAPOV (eap) -// -#include -#include - -using namespace MEDMEM; -using namespace std; - - -static string getMeshName(const char* file, int mesh_index) -{ - MEDFILEBROWSER med(file); - if ( mesh_index >= med.getNumberOfMeshes() ) - { - cout << "Invalid index of mesh, it must be less than " << med.getNumberOfMeshes() << endl; - return "Invalid mesh index"; - } - vector mesh_names = med.getMeshNames(); - return mesh_names[mesh_index]; -} - -//================================================================================ -/*! - * \brief Perform interpolation of two meshes and dumps result. For format of output, - * see comment to operator<<() in InterpKernelMatrix.hxx - */ -//================================================================================ - -int main(int argc, char** argv) -{ - if( argc < 3 ) - { - cout << "Dumps result of interpolation of two meshes" << endl - << "For format of output, see comment to operator<<() in InterpKernelMatrix.hxx" < 3) ? atoi(argv[3]) : 0 ); - string mesh_name2 = getMeshName( argv[2], (argc > 4) ? atoi(argv[4]) : 0 ); - - MESH *mesh1=new MESH(MED_DRIVER, argv[1], mesh_name1.data()); - MESH *mesh2=new MESH(MED_DRIVER, argv[2], mesh_name2.data()); - - MEDMEM_REMAPPER aREMAPPER; - aREMAPPER.prepare( *mesh1, *mesh2, "P0P0" ); - aREMAPPER.printMatrixInfo(); - mesh1->removeReference(); - mesh2->removeReference(); - return 0; -} diff --git a/src/MEDMEMBinTest/duplicateMED.cxx b/src/MEDMEMBinTest/duplicateMED.cxx deleted file mode 100644 index e8b3d223e..000000000 --- a/src/MEDMEMBinTest/duplicateMED.cxx +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_MedFileBrowser.hxx" - -using namespace std; -using namespace MEDMEM; -static void usage(char * name) -{ - cout << " " << name << " " < meshNames = myMed.getMeshNames (); - for ( unsigned i = 0; i < meshNames.size(); ++i ) - { - GMESH* mesh = myMed.isStructuredMesh( meshNames[i] ) ? (GMESH*) new GRID : (GMESH*) new MESH; - int drv = mesh->addDriver(MED_DRIVER, filenameIN, meshNames[i] ); - mesh->read(drv); - drv = mesh->addDriver(MED_DRIVER, filenameOUT, meshNames[i] ); - mesh->write(drv); - mesh->removeReference(); - } - - vector FieldName = myMed.getFieldNames() ; - for (unsigned i=0; i FieldIteration = myMed.getFieldIteration(FieldName[i]) ; - for (unsigned j=0; j; break; - case MED_INT32: - case MED_INT64: myField = new FIELD; break; - default: - continue; - } - myField->setIterationNumber( FieldIteration[j].dt ); - myField->setOrderNumber ( FieldIteration[j].it ); - int drv = myField->addDriver( MED_DRIVER, filenameIN, FieldName[i]); - myField->read( drv ) ; - drv = myField->addDriver( MED_DRIVER, filenameOUT, FieldName[i]); - myField->write( drv ); - myField->removeReference(); - } - } - } catch (MEDEXCEPTION& ex) { - MESSAGE_MED(ex.what()) ; - } - -} diff --git a/src/MEDMEMBinTest/duplicateMEDMESH.cxx b/src/MEDMEMBinTest/duplicateMEDMESH.cxx deleted file mode 100644 index de8654d93..000000000 --- a/src/MEDMEMBinTest/duplicateMEDMESH.cxx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Support.hxx" - -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFileBrowser.hxx" - -using namespace std; -using namespace MEDMEM; -int main (int argc, char ** argv) -{ - if ( argc < 3 ) { - cout << "Usage: " << argv[0] << " " << endl; - return -1; - } - string filenameIN = argv[1] ; - string filenameOUT = argv[2] ; - - MEDFILEBROWSER myMed(filenameIN); - - // we read all meshes in filenameIN - try { - - // read all mesh - MESSAGE_MED("Read all meshes :") ; - int NumberOfMeshes = myMed.getNumberOfMeshes() ; - MESSAGE_MED("Number of meshes : "< meshNames = myMed.getMeshNames() ; - for (int i=0; iaddDriver(MED_DRIVER, filenameIN, meshNames[i] ); - mesh->read(drv); - MESSAGE_MED(" - Mesh "<removeReference(); - } - - } catch (MEDEXCEPTION& ex){ - MESSAGE_MED(ex.what()) ; - return -1; - } - return 0; -} diff --git a/src/MEDMEMBinTest/ensight2med.cxx b/src/MEDMEMBinTest/ensight2med.cxx deleted file mode 100644 index e06a2d7db..000000000 --- a/src/MEDMEMBinTest/ensight2med.cxx +++ /dev/null @@ -1,173 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_EnsightMedDriver.hxx" -#include "MEDMEM_EnsightFieldDriver.hxx" -#include "MEDMEM_EnsightMeshDriver.hxx" - -using namespace std; -using namespace MEDMEM; - -static void usage(char * name) -{ - cout << " ERROR ABOUT SYNTAX " << endl ; - cout << " " << name << " [I - to read into MED_INT32 fields]" - << endl ; - exit(-1); -} - -// ensight2med toto.case toto.med => input : toto.case => output : toto.med.... - -int main (int argc, char ** argv) { - - string filenameIN ; - string filenameOUT; - - if ( argc == 3 ) { - filenameIN = argv[1] ; - filenameOUT = argv[2] ; - cout << " reading all into the Ensight file " << filenameIN << " and writing all into the Med file " << filenameOUT << endl ; - - vector< FIELD_* > fields; - vector< const GMESH* > meshes; - - // Read - - ENSIGHT_MED_RDONLY_DRIVER medDriver(filenameIN, fields); - medDriver.open(); - medDriver.read(); - medDriver.close(); - if ( !fields.empty() ) - { - set uniqueMeshes; - for ( unsigned i = 0; i < fields.size(); ++i ) - uniqueMeshes.insert( fields[i]->getSupport()->getMesh() ); - meshes.assign( uniqueMeshes.begin(), uniqueMeshes.end() ); - } - else - { - // no fields but only meshes in the file - MESH* mesh = 0; - int meshIndex = 1; - do - { - mesh = new MESH; - meshes.push_back( mesh ); - ENSIGHT_MESH_RDONLY_DRIVER meshDriver( filenameIN, mesh, meshIndex++ ); - meshDriver.open(); - meshDriver.read(); - meshDriver.close(); - } while ( mesh->getNumberOfNodes() > 0 ); - meshes.back()->removeReference(); - meshes.pop_back(); - } - - // Write - - for ( unsigned i = 0; i < meshes.size(); ++i ) - { - meshes[i]->write(MED_DRIVER,filenameOUT); - } - for ( unsigned i = 0; i < fields.size(); ++i ) - { - fields[i]->write(MED_DRIVER,filenameOUT); - fields[i]->removeReference(); - } - for ( unsigned i = 0; i < meshes.size(); ++i ) - meshes[i]->removeReference(); - } - else if ( argc == 4 && strncmp(argv[3], "I", 1 )==0 ) - { - // we read all variables into INT32 fields - // (we need such fields for test_operation_fieldint) - - filenameIN = argv[1] ; - filenameOUT = argv[2] ; - - vector< FIELD_* > fields; - - // Read - - ENSIGHT_MED_RDONLY_DRIVER medDriver(filenameIN, fields); - medDriver.open(); - medDriver.readFileStruct(); - medDriver.close(); - - if ( fields.empty() ) { - cout << "No fileds found in EnSight file " << filenameIN << endl; - return -1; - } - // read-write the mesh - const GMESH* mesh = fields[0]->getSupport()->getMesh(); - const_cast( mesh )->read(); - mesh->write(MED_DRIVER, filenameOUT ); - - // read-write fields - for ( unsigned i = 0; i < fields.size(); ++i ) - { - for ( int timeStep = 1; ; ++timeStep ) - { - FIELD *intF=new FIELD; - intF->setName( fields[i]->getName() ); - try - { - ENSIGHT_FIELD_RDONLY_DRIVER fieldDriver( filenameIN, intF, timeStep ); - fieldDriver.open(); - fieldDriver.read(); - fieldDriver.close(); - // replace zero values as theses fields are used for division - int nbVals = intF->getValueLength(); - int* values = const_cast(intF->getValue()); - while ( nbVals-- ) { - if ( values[nbVals]==0 ) - values[nbVals]= nbVals%5 + 1; - } - } - catch ( const MEDEXCEPTION& ex) - { - intF->removeReference(); - intF=0; - break; - } - intF->write(MED_DRIVER,filenameOUT); - intF->removeReference(); - } - fields[i]->removeReference(); - } - mesh->removeReference(); - } - else usage(argv[0]); - -} - - diff --git a/src/MEDMEMBinTest/med2ensight.cxx b/src/MEDMEMBinTest/med2ensight.cxx deleted file mode 100644 index 6a873de53..000000000 --- a/src/MEDMEMBinTest/med2ensight.cxx +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_EnsightMedDriver.hxx" -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_EnsightMeshDriver.hxx" - -using namespace std; -using namespace MEDMEM; - -static void usage(char * name) -{ - cout << " ERROR ABOUT SYNTAX " << endl ; - cout << " " << name << " " << endl ; - exit(-1); -} - -int main (int argc, char ** argv) { - - string filenameIN ; - string filenameOUT; - - if ( argc == 3 ) { - filenameIN = argv[1] ; - filenameOUT = argv[2] ; - cout << "-> reading all into the Med file " << filenameIN << " and writing all into the Ensight file " << filenameOUT << endl ; - - MEDFILEBROWSER myMed(filenameIN) ; - - vector< FIELD_* > fields; - vector< GMESH* > meshes; - - cout << "-> Read all meshes " ; - int NumberOfMeshes = myMed.getNumberOfMeshes() ; - cout << "( "< MeshName = myMed.getMeshNames() ; - for (int i=0; iaddDriver(MED_DRIVER, filenameIN, MeshName[i], MED_EN::RDONLY); - mesh->read(); - cout << "-> Mesh "< Read all fields " ; - int NumberOfFields = myMed.getNumberOfFields() ; - cout << "( "< FieldName = myMed.getFieldNames() ; - for (int i=0; i FieldIteration = myMed.getFieldIteration(FieldName[i]) ; - cout << "-> Field "<; break; - case MED_INT32: - case MED_INT64: myField = new FIELD; break; - default: - cout << "Unknown value type - skipped" << endl; - continue; - } - myField->setIterationNumber( FieldIteration[j].dt ); - myField->setOrderNumber( FieldIteration[j].it ); - myField->addDriver( MED_DRIVER, filenameIN, FieldName[i], MED_EN::RDONLY); - myField->read() ; - cout << " * Iteration "<getSupport()->getMeshName(); - for ( unsigned i = 0; i < meshes.size(); ++ i) - if ( meshes[i]->getName() == meshName ) - myField->getSupport()->setMesh( meshes[i] ); - } - } - - if ( !fields.empty() ) - { - vector< const FIELD_* > constFields( fields.begin(), fields.end() ); - ENSIGHT_MED_WRONLY_DRIVER medDriver( filenameOUT, constFields ); - medDriver.write(); - } - else if ( !meshes.empty() ) - { - ENSIGHT_MESH_WRONLY_DRIVER meshDriver( filenameOUT, meshes[0] ); - meshDriver.write() ; - } - - for ( unsigned i = 0; i < meshes.size(); ++ i) - meshes[i]->removeReference(); - for ( unsigned i = 0; i < fields.size(); ++ i) - fields[i]->removeReference(); - } - else usage(argv[0]); -} diff --git a/src/MEDMEMBinTest/med2vtk.cxx b/src/MEDMEMBinTest/med2vtk.cxx deleted file mode 100644 index 8a7987d89..000000000 --- a/src/MEDMEMBinTest/med2vtk.cxx +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" - -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_VtkMedDriver.hxx" - -using namespace std; -using namespace MEDMEM; -static void usage(char * name) -{ - string prog = name; -#ifdef WIN32 - int pos = prog.rfind( '\\' ); -#else - int pos = prog.rfind( '/' ); -#endif - if ( pos >= 0 ) - prog = prog.substr( pos+1 ); - cout << " " << prog.c_str() << " " << endl ; - cout << " " << "Note: both file names are mandatory" << endl ; - exit(-1); -} - -int main (int argc, char ** argv) -{ - if (argc != 3) usage(argv[0]); - - string filenameIN = argv[1] ; - string filenameOUT = argv[2] ; - - try { - ///////////////////////////////////////////////// - // we read all meshes and fields in filenameIN // - ///////////////////////////////////////////////// - MEDFILEBROWSER myMed(filenameIN) ; - vector< FIELD_* > fields; - vector< GMESH* > meshes; - - // read all meshes - //////////////////// - - cout << "Read all meshes " ; - int NumberOfMeshes = myMed.getNumberOfMeshes() ; - cout << "( "< MeshName = myMed.getMeshNames() ; - for (int i=0; iaddDriver(MED_DRIVER, filenameIN, MeshName[i] ); - mesh->read(); - cout << " - Mesh "< FieldName = myMed.getFieldNames() ; - for (int i=0; i FieldIteration = myMed.getFieldIteration(FieldName[i]) ; - cout << " - Field "<; break; - case MED_INT32: - case MED_INT64: myField = new FIELD; break; - default: - cout << "Unknown value type - skipped" << endl; - continue; - } - myField->setIterationNumber( FieldIteration[j].dt ); - myField->setOrderNumber( FieldIteration[j].it ); - myField->addDriver( MED_DRIVER, filenameIN, FieldName[i]); - myField->read() ; - cout << " * Iteration "<getName() == meshName ) - myField->getSupport()->setMesh( meshes[m] ); - } - } - - ////////////////////////////////////////// - // we write all in VTK file filenameOUT // - ///////////////////////////////////////// - if ( !fields.empty() ) - { - vector< const FIELD_* > constFields( fields.begin(), fields.end() ); - VTK_MED_DRIVER medDriver( filenameOUT, constFields ); - medDriver.write(); - } - else if ( !meshes.empty() ) - { - VTK_MESH_DRIVER meshDriver( filenameOUT, meshes[0] ); - meshDriver.write() ; - } - - for ( unsigned i = 0; i < meshes.size(); ++ i) - meshes[i]->removeReference(); - for ( unsigned i = 0; i < fields.size(); ++ i) - fields[i]->removeReference(); - } - catch (MEDEXCEPTION& ex){ - cout << ex.what() << endl ; - } - -} diff --git a/src/MEDMEMBinTest/med_test.cxx b/src/MEDMEMBinTest/med_test.cxx deleted file mode 100644 index bd1c675a9..000000000 --- a/src/MEDMEMBinTest/med_test.cxx +++ /dev/null @@ -1,439 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_define.hxx" - -#include - -#include -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static double dmax(double x, double y) { return (x>y)?x:y;} - -static double dmin(double x, double y) { return (x>y)?y:x;} - -static double infty = 1.e20; - -static void affiche_support(const SUPPORT * mySupport) -{ - cout << " - Name : "<getName().c_str()<getDescription().c_str()<getEntity()<isOnAllElements())) { - int NumberOfTypes = mySupport->getNumberOfTypes() ; - cout<<" - NumberOfTypes : "<getTypes() ; - for (int j=0;jgetNumberOfElements(Types[j]) ; - const int * Number = mySupport->getNumber(Types[j]) ; - for (int k=0; kgetNumberOfFamilies(Entity) ; - cout << "NumberOfFamilies : "<getFamily(Entity,i); - affiche_support(myFamily); - cout << " - Identifier : "<getIdentifier()<getNumberOfAttributes() ; - cout << " - Attributes ("<getAttributeIdentifier(j)<<" : "<getAttributeValue(j)<<", "<getAttributeDescription(j).c_str()<getNumberOfGroups() ; - cout << " - Groups ("<getGroupName(j).c_str()<getNumberOfGroups(Entity) ; - cout << "NumberOfGroups : "<getGroup(Entity,i); - affiche_support(myGroup); - int NumberOfFamillies = myGroup->getNumberOfFamilies() ; - cout << " - Families ("<getFamily(j)->getName().c_str()<getSpaceDimension() ; - int MeshDimension = myMesh->getMeshDimension() ; - int NumberOfNodes = myMesh->getNumberOfNodes() ; - - cout << "Space Dimension : " << SpaceDimension << endl << endl ; - - cout << "Mesh Dimension : " << MeshDimension << endl << endl ; - - const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ; - - cout << "Show Nodes Coordinates : " << endl ; - - cout << "Name :" << endl ; - const string * CoordinatesNames = myMesh->getCoordinatesNames() ; - for(int i=0; igetCoordinatesUnits() ; - for(int i=0; igetNumberOfTypes(MED_CELL) ; - const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; - - cout << "Show Connectivity (Nodal) :" << endl ; - for (int i=0; igetNumberOfElements(MED_CELL,Types[i]); - const int * connectivity = myMesh->getConnectivity(MED_NODAL,MED_CELL,Types[i]); - int NomberOfNodesPerCell = Types[i]%100 ; - for (int j=0;jgetReverseConnectivity(MED_NODAL) ; - const int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ; - for (int i=0; icalculateConnectivity(MED_DESCENDING,MED_CELL); - try { - NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); - connectivity = myMesh->getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS); - connectivity_index = myMesh->getConnectivityIndex(MED_DESCENDING,MED_CELL); - } - catch (MEDEXCEPTION& m) { - cout << m.what() << endl ; - exit (-1) ; - } - for (int j=0;jgetReverseConnectivity(MED_DESCENDING) ; - const int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ; - - int NumberOfConstituents = 0; - string constituent ; - medEntityMesh constituentEntity ; - - if (MeshDimension==3) { - constituent = "Face" ; - constituentEntity = MED_FACE ; - } - - if (MeshDimension==2) { - constituent = "Edge" ; - constituentEntity = MED_EDGE ; - } - - if (MeshDimension==1) { - INFOS_MED("ERROR : MeshDimension = 1 !"); - INFOS_MED("We could not see Reverse Descending Connectivity.") ; - } else { - NumberOfConstituents = myMesh->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS); - for (int i=0; igetConnectivity(MED_NODAL,constituentEntity,MED_ALL_ELEMENTS); - const int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity); - for (int i=0; igetSupportOnAll(constituentEntity); - cout << "Building of the Support on all cells dimensionned (Meshdim-1) of the mesh :"<< endl ; - cout << "Face in 3D or Edge in 2D" << endl; - - cout << "Getting the normal of each face of this support !" << endl ; - - FIELD* normal = myMesh->getNormal(support1); - - double normal_square, norm ; - double maxnorm=-infty; - double minnorm=infty; - double tmp_value ; - for (int i = 1; i<=NumberOfConstituents;i++) - { - normal_square = 0. ; - cout << "Normal " << i << " " ; - for (int j=1; j<=SpaceDimension; j++) - { - tmp_value = normal->getValueIJ(i,j) ; - normal_square += tmp_value*tmp_value ; - cout << tmp_value << " " ; - } - norm = sqrt(normal_square); - maxnorm = dmax(maxnorm,norm); - minnorm = dmin(minnorm,norm); - cout << ", Norm = " << norm << endl; - } - cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl; - - if(normal) - normal->removeReference() ; - - if (SpaceDimension == 2) - { - cout << "Getting the length of each edge !" << endl ; - - FIELD* length = myMesh->getLength(support1); - - double length_value,maxlength,minlength; - maxlength = -infty; - minlength = infty; - for (int i = 1; i<=NumberOfConstituents;i++) - { - length_value = length->getValueIJ(i,1) ; - cout << "Length " << i << " " << length_value << endl; - maxlength = dmax(maxlength,length_value); - minlength = dmin(minlength,length_value); - } - cout << "Max Length " << maxlength << " Min Length " << minlength << endl; - if(length) - length->removeReference(); - } - - cout << "Building of the Support on all space-dimensionned cells of the mesh :"<< endl ; - const SUPPORT * support = myMesh->getSupportOnAll( MED_CELL ); - - cout << "Getting the barycenter of each element of this support !" << endl ; - - FIELD* barycenter = myMesh->getBarycenter(support); - NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); - - for (int i = 1; i<=NumberOfElements;i++) - { - if (SpaceDimension == 3) - cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) << endl; - - if (SpaceDimension == 2) - cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << endl; - } - if(barycenter) - barycenter->removeReference(); - - if (SpaceDimension == 3) - { - cout << "Getting the Volume of each element of this support which is a 3D one !" << endl; - - FIELD* volume = myMesh->getVolume(support); - - double maxvol,minvol,voltot; - maxvol = -infty; - minvol = infty; - voltot = 0.0; - for (int i = 1; i<=NumberOfElements;i++) - { - cout << "Volume " << i << " " << volume->getValueIJ(i,1) << endl; - maxvol = dmax(maxvol,volume->getValueIJ(i,1)); - minvol = dmin(minvol,volume->getValueIJ(i,1)); - voltot = voltot + volume->getValueIJ(i,1); - } - - cout << "Max Volume " << maxvol << " Min Volume " << minvol << endl; - cout << "Support Volume " << voltot << endl; - if(volume) - volume->removeReference() ; - } - else if (SpaceDimension == 2) - { - cout << "Getting the Area of each element of this support which is a 2D one !" << endl; - - FIELD* area = myMesh->getArea(support); - - double maxarea,minarea,areatot; - maxarea = -infty; - minarea = infty; - areatot = 0.0; - for (int i = 1; i<=NumberOfElements;i++) - { - cout << "Area " << i << " " << area->getValueIJ(i,1) << endl; - maxarea = dmax(maxarea,area->getValueIJ(i,1)); - minarea = dmin(minarea,area->getValueIJ(i,1)); - areatot = areatot + area->getValueIJ(i,1); - } - - cout << "Max Area " << maxarea << " Min Area " << minarea << endl; - cout << "Support Area " << areatot << endl; - if(area) - area->removeReference(); - } - - if (argc < 4) return 0; - - // read field : - - if (argc != 4) exit(0) ; - // else we have a field ! - - string fieldname = argv[3]; - - const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_CELL); - FIELD * myField= new FIELD() ; - - myField->setName(fieldname); - myField->setSupport(mySupport); - MED_FIELD_RDONLY_DRIVER myFieldDriver(filename,myField) ; - myFieldDriver.setFieldName(fieldname); - myFieldDriver.open() ; - - try - { - myFieldDriver.read() ; - } - catch (...) - { - mySupport = myMesh->getSupportOnAll(MED_NODE); - myField->setSupport(mySupport); - try - { - myFieldDriver.read() ; - } - catch (...) - { - cout << "Field " << fieldname << " not found !!!" << endl ; - exit (-1) ; - } - } - - myFieldDriver.close() ; - - cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; - for (int i=1; igetComponentName(i)<< endl; - cout << " - description : "<getComponentDescription(i) << endl; - cout << " - units : "<getMEDComponentUnit(i) << endl; - } - cout << "- iteration :" << endl ; - cout << " - numero : " << myField->getIterationNumber()<< endl ; - cout << " - ordre : " << myField->getOrderNumber()<< endl ; - cout << " - temps : " << myField->getTime()<< endl ; - - cout << "- Valeurs :"<getNumberOfElements(MED_ALL_ELEMENTS); - MEDMEM_Array * myvalue = myField->getArrayNoGauss(); - const double * value ; - for (int i=1; igetRow(i) ; - for (int j=0; jremoveReference(); - myMesh->removeReference(); - - return 0; -} diff --git a/src/MEDMEMBinTest/scripts/check_convertToPoly b/src/MEDMEMBinTest/scripts/check_convertToPoly deleted file mode 100644 index 370291833..000000000 --- a/src/MEDMEMBinTest/scripts/check_convertToPoly +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/BoxTetra2.med - -outfile=$outdir/convertToPoly_BoxTetra2.med - -./convertToPoly $infile $outfile BoxTetra2 > /dev/null 2>&1 - -ok=$? - -rm $outfile - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_duplicateMED b/src/MEDMEMBinTest/scripts/check_duplicateMED deleted file mode 100644 index f19490e26..000000000 --- a/src/MEDMEMBinTest/scripts/check_duplicateMED +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -outfile=$outdir/duplicateMED_pointe.med - -./duplicateMED $infile $outfile > /dev/null 2>&1 - -ok=$? - -rm $outfile - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_ensight2med b/src/MEDMEMBinTest/scripts/check_ensight2med deleted file mode 100644 index 7967a9990..000000000 --- a/src/MEDMEMBinTest/scripts/check_ensight2med +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/blow5_ascii.case - -outfile=${outdir}/ensight2med.med - -./ensight2med $infile $outfile > /dev/null 2>&1 - -ok=$? - -rm $outfile - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_med2_1_To_med2_2 b/src/MEDMEMBinTest/scripts/check_med2_1_To_med2_2 deleted file mode 100644 index 412e1ef19..000000000 --- a/src/MEDMEMBinTest/scripts/check_med2_1_To_med2_2 +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -outfile=./pointe.med2.3 - -./med2_1_To_med2_2 $infile > /dev/null 2>&1 - -ok=$? - -rm $outfile - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_med2ensight b/src/MEDMEMBinTest/scripts/check_med2ensight deleted file mode 100644 index 22c7e5cb6..000000000 --- a/src/MEDMEMBinTest/scripts/check_med2ensight +++ /dev/null @@ -1,48 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -outfile=${outdir}/pointe.case - -./med2ensight $infile $outfile > /dev/null 2>&1 - -ok=$? - -rm $outfile -rm ${outdir}/pointe.geo -rm ${outdir}/pointe.fieldcelldoublescalar -rm ${outdir}/pointe.fieldcelldoublevector -rm ${outdir}/pointe.fieldnodedouble000 -rm ${outdir}/pointe.fieldnodedouble001 -rm ${outdir}/pointe.fieldnodedouble002 -rm ${outdir}/pointe.fieldnodeint - - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_med2vtk b/src/MEDMEMBinTest/scripts/check_med2vtk deleted file mode 100644 index a24235d6b..000000000 --- a/src/MEDMEMBinTest/scripts/check_med2vtk +++ /dev/null @@ -1,40 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -outfile=$outdir/pointe.vtk - -./med2vtk $infile $outfile > /dev/null 2>&1 - -ok=$? - -rm $outfile - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_readCoordinate b/src/MEDMEMBinTest/scripts/check_readCoordinate deleted file mode 100644 index 1146d8088..000000000 --- a/src/MEDMEMBinTest/scripts/check_readCoordinate +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./readCoordinate $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_readEntete b/src/MEDMEMBinTest/scripts/check_readEntete deleted file mode 100644 index a1bcd4105..000000000 --- a/src/MEDMEMBinTest/scripts/check_readEntete +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./readEntete $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_testAnalFile b/src/MEDMEMBinTest/scripts/check_testAnalFile deleted file mode 100644 index 8ee0ece05..000000000 --- a/src/MEDMEMBinTest/scripts/check_testAnalFile +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -initfile=${srcdir}/../../resources/TimeStamps.med -infile=$outdir/testAnalFile.med - -# convert med file from non-suported version -#medimport $initfile $infile -cp $initfile $infile - -./testAnalFile $infile > /dev/null 2>&1 - -ok=$? - -\rm -f $infile -\rm -f $outdir/testAnalFileAnal_V21.med -\rm -f $outdir/testAnalFileAnal_V22.med - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshRead b/src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshRead deleted file mode 100644 index 053c2b697..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshRead +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_MEDMEM_PolyDriverMedMeshRead $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshWrite b/src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshWrite deleted file mode 100644 index 3fa459043..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_MEDMEM_PolyDriverMedMeshWrite +++ /dev/null @@ -1,43 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -initfile=${srcdir}/../../resources/pointe.med -infile=$outdir/test_MEDMEM_PolyDriverMedMeshWrite.med -outfile=$outdir/test_MEDMEM_PolyDriverMedMeshWrite.med_copy - -cp $initfile $infile - -./test_MEDMEM_PolyDriverMedMeshWrite $infile maa1 > /dev/null 2>&1 - -ok=$? - -\rm -f $infile -\rm -f $outfile - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_test_MEDMEM_poly3D b/src/MEDMEMBinTest/scripts/check_test_MEDMEM_poly3D deleted file mode 100644 index f62b0c784..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_MEDMEM_poly3D +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/poly3D.med - -./test_MEDMEM_poly3D $infile poly3D > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_copie_connectivity b/src/MEDMEMBinTest/scripts/check_test_copie_connectivity deleted file mode 100644 index d9b3f6f9b..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_copie_connectivity +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_copie_connectivity $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_copie_family b/src/MEDMEMBinTest/scripts/check_test_copie_family deleted file mode 100644 index 63b2cc46e..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_copie_family +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_copie_family $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_copie_fieldT b/src/MEDMEMBinTest/scripts/check_test_copie_fieldT deleted file mode 100644 index 001349ded..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_copie_fieldT +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_copie_fieldT $infile maa1 fieldcelldoublescalar > /dev/null 2>&1 - -if test $? -ne 0; then exit -1;fi - -./test_copie_fieldT $infile maa1 fieldnodedouble > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_copie_field_ b/src/MEDMEMBinTest/scripts/check_test_copie_field_ deleted file mode 100644 index b63faa79b..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_copie_field_ +++ /dev/null @@ -1,39 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_copie_field_ $infile maa1 fieldcelldoublevector > /dev/null 2>&1 - -if test $? -ne 0; then exit -1;fi - -./test_copie_field_ $infile maa1 fieldnodeint > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_copie_group b/src/MEDMEMBinTest/scripts/check_test_copie_group deleted file mode 100644 index 169f7df6e..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_copie_group +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_copie_group $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_copie_mesh b/src/MEDMEMBinTest/scripts/check_test_copie_mesh deleted file mode 100644 index a1c65b2d2..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_copie_mesh +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_copie_mesh $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_copie_support b/src/MEDMEMBinTest/scripts/check_test_copie_support deleted file mode 100644 index 3285086f7..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_copie_support +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_copie_support $infile maa1 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_gibi_driver b/src/MEDMEMBinTest/scripts/check_test_gibi_driver deleted file mode 100644 index 1d94b52ad..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_gibi_driver +++ /dev/null @@ -1,44 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -initfile=${srcdir}/../../resources/mail-test1-4-1.sauve -infile=${outdir}/test_gibi_driver.sauve - -cp $initfile $infile - -./test_gibi_driver $infile > /dev/null 2>&1 - -ok=$? - -\rm -f $infile -\rm -f ${outdir}/test_gibi_driver.vtk -\rm -f ${outdir}/test_gibi_driver_V21.med -\rm -f ${outdir}/test_gibi_driver_V22.med - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_test_grid b/src/MEDMEMBinTest/scripts/check_test_grid deleted file mode 100644 index 351ba9990..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_grid +++ /dev/null @@ -1,24 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -./test_grid 3 5 > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_operation_fielddouble b/src/MEDMEMBinTest/scripts/check_test_operation_fielddouble deleted file mode 100644 index 1e1962704..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_operation_fielddouble +++ /dev/null @@ -1,35 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -infile=${srcdir}/../../resources/pointe.med - -./test_operation_fielddouble $infile maa1 fieldcelldoublescalar > /dev/null 2>&1 - -exit - diff --git a/src/MEDMEMBinTest/scripts/check_test_operation_fieldint b/src/MEDMEMBinTest/scripts/check_test_operation_fieldint deleted file mode 100755 index aa70ee410..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_operation_fieldint +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -# make med file containing int field on cells from ensight file - -infile=${srcdir}/../../resources/blow5_ascii.case -outfile=${outdir}/test_operation_fieldint.med - -./ensight2med $infile $outfile I > /dev/null 2>&1 - -# main test -./test_operation_fieldint $outfile EnsightMesh displacement_c > /dev/null 2>&1 - -ok=$? - -echo $outfile -rm $outfile - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_test_porflow_driver b/src/MEDMEMBinTest/scripts/check_test_porflow_driver deleted file mode 100644 index 7321efce7..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_porflow_driver +++ /dev/null @@ -1,49 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -initfile=${srcdir}/../../resources/cube.inp -xyzfile=${srcdir}/../../resources/cube.xyz -cncfile=${srcdir}/../../resources/cube.cnc -infile=${outdir}/test_porflow_driver.inp - -cp $initfile $infile -cp $xyzfile ${outdir}/cube.xyz -cp $cncfile ${outdir}/cube.cnc - -./test_porflow_driver $infile > /dev/null 2>&1 - -ok=$? - -\rm -f $infile -\rm -f ${outdir}/cube.xyz -\rm -f ${outdir}/cube.cnc -\rm -f ${outdir}/test_porflow_driver.med -\rm -f ${outdir}/test_porflow_driver.vtk - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_test_profil_MedFieldDriver b/src/MEDMEMBinTest/scripts/check_test_profil_MedFieldDriver deleted file mode 100644 index ef0744e9f..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_profil_MedFieldDriver +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -initfile=${srcdir}/../../resources/zzzz121b_without_tr6.med -infile=test_profil_MedFieldDriver.med - -curdir=`pwd` -cp $initfile $outdir/$infile -cd $outdir - -$curdir/test_profil_MedFieldDriver $infile RESUZERODEPL____________________ 1 1 > /dev/null 2>&1 - -ok=$? - -\rm -f $infile -\rm -f Copy_withmesh_test_profil_MedFieldDriver.med -\rm -f Copy_nomesh_test_profil_MedFieldDriver.med - -exit $ok diff --git a/src/MEDMEMBinTest/scripts/check_test_profil_gauss_MedFieldDriver b/src/MEDMEMBinTest/scripts/check_test_profil_gauss_MedFieldDriver deleted file mode 100644 index a49d5d6ae..000000000 --- a/src/MEDMEMBinTest/scripts/check_test_profil_gauss_MedFieldDriver +++ /dev/null @@ -1,45 +0,0 @@ -#! /bin/sh -f -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -outdir="/tmp" -if test "z$TMP" != "z" && test -e $TMP; then - outdir=$TMP -else - if test "z$TMPDIR" != "z" && test -e $TMPDIR; then - outdir=$TMPDIR - fi -fi - -initfile=${srcdir}/../../resources/zzzz121b_without_tr6.med -infile=test_profil_gauss_MedFieldDriver.med - -curdir=`pwd` -cp $initfile $outdir/$infile -cd $outdir - -$curdir/test_profil_gauss_MedFieldDriver $infile RESUZEROSIEF_ELGA_DEPL__________ 1 1 > /dev/null 2>&1 - -ok=$? - -\rm -f $infile -\rm -f Copy_withmesh_test_profil_gauss_MedFieldDriver.med -\rm -f Copy_nomesh_test_profil_gauss_MedFieldDriver.med - -exit $ok diff --git a/src/MEDMEMBinTest/testAG.cxx b/src/MEDMEMBinTest/testAG.cxx deleted file mode 100644 index 232432ec0..000000000 --- a/src/MEDMEMBinTest/testAG.cxx +++ /dev/null @@ -1,127 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_MedMeshDriver22.hxx" - -using namespace MED_EN; -using namespace std; -using namespace MEDMEM; - -void addMedFacesGroup( MESHING& meshing, int nFaces, int *groupValue,string groupName) - { - GROUP faces ; - int myNumberOfElements[1]; - medGeometryElement mytypes[1]; - int index[2]; - int nbOfGeomTypes; - faces.setName(groupName) ; - faces.setMesh(&meshing) ; - faces.setEntity(MED_EN::MED_FACE) ; - faces.setNumberOfGeometricType(1) ; - mytypes[0]=MED_EN::MED_POLYGON; - faces.setGeometricType(mytypes); - myNumberOfElements[0]=nFaces; - faces.setNumberOfElements(myNumberOfElements) ; - index[0]=1; index[1]=nFaces; - faces.setNumber(index, groupValue) ; - meshing.addGroup(faces) ; - } - -const int NB_OF_HEXA=1; -const int NB_OF_CELL_AXIAL=1; -char NomBottom[]="Bottom"; - -int main() -{ - MESHING *pmesh=new MESHING; - pmesh->setName( "RJHMESH" ) ; - - double coord3DTab[36]={0.024155000000000003, 0.041837687256826218, -0.30499999999999999, 0.048310000000000013, -1.015761910347357e-17, -0.30499999999999999, 0.096620000000000011, -1.8329792978583059e-18, - -0.30499999999999999, 0.12077499999999999, 0.041837687256826225, -0.30499999999999999, 0.096620000000000011, 0.083675374513652451, -0.30499999999999999, 0.048310000000000013, 0.083675374513652465, - -0.30499999999999999, 0.024155000000000003, 0.041837687256826218, -0.2863, 0.048310000000000013, -1.015761910347357e-17, -0.2863, 0.096620000000000011, -1.8329792978583059e-18, -0.2863, - 0.12077499999999999, 0.041837687256826225, -0.2863, 0.096620000000000011, 0.083675374513652451, -0.2863, 0.048310000000000013, 0.083675374513652465, -0.2863}; - vector coords3D(coord3DTab,coord3DTab+36); - unsigned nNodes=coords3D.size()/3; - pmesh->setCoordinates(3, nNodes, &(coords3D[0]), "CARTESIAN",MED_EN::MED_FULL_INTERLACE); - string coordname[3] = { "x", "y", "z" } ; - pmesh->setCoordinatesNames(coordname) ; - // Set coordinates units - string coordunit[3] = { "cm", "cm", "cm" } ; - pmesh->setCoordinatesUnits(coordunit) ; - - medGeometryElement mytypes3D[1]={MED_POLYHEDRA}; - medGeometryElement mytypes2D[2]={MED_QUAD4,MED_POLYGON}; - pmesh->setNumberOfTypes(1, MED_EN::MED_CELL); - pmesh->setNumberOfTypes(2,MED_EN::MED_FACE); - pmesh->setTypes(mytypes3D,MED_EN::MED_CELL); - pmesh->setTypes(mytypes2D,MED_EN::MED_FACE); - // - const int nbPolyH = 1; - int polyHInd[2]={1, 9}; - int polyHFaceConn[43]={8, 9, 10, 11, 12, 7, -1, - 2, 1, 6, 5, 4, 3, -1, - 2, 3, 9, 8, -1, - 3, 4, 10, 9, -1, - 4, 5, 11, 10, -1, - 5, 6, 12, 11, -1, - 6, 1, 7, 12, -1, - 1, 2, 8, 7}; - // - int conn2DClassicalTab[24]={2, 3, 9, 8, 3, 4, 10, 9, 4, 5, 11, 10, 5, 6, 12, 11, 6, 1, 7, 12, 1, 2, 8, 7}; - vector conn2DClassical(conn2DClassicalTab,conn2DClassicalTab+24); - // - int conn2DPolyIndTab[3]={1, 7, 13}; - vector conn2DPolyInd(conn2DPolyIndTab,conn2DPolyIndTab+3); - int conn2DPolyTab[12]={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; - // - int nbOfElemsFace[] = { conn2DClassical.size()/4, conn2DPolyInd.size()-1 }; - pmesh->setNumberOfElements(&nbPolyH,MED_EN::MED_CELL); - pmesh->setNumberOfElements(nbOfElemsFace,MED_EN::MED_FACE); - // - // - pmesh->setConnectivity(MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA, polyHFaceConn,polyHInd); - pmesh->setConnectivity(MED_EN::MED_FACE, MED_EN::MED_QUAD4,&conn2DClassical[0]); - pmesh->setConnectivity(MED_EN::MED_FACE, MED_EN::MED_POLYGON,&conn2DPolyInd[0],conn2DPolyIndTab); - int bottom=7; - addMedFacesGroup(*pmesh,1,&bottom,NomBottom); - int id = pmesh->addDriver(MED_DRIVER, "coeur.med", pmesh->getName()); - pmesh->write(id) ; - pmesh->rmDriver(id); - delete pmesh; - // - - MESH mesh;//(MED_DRIVER,,"RJHMESH");//"/home/geay/test_FGUI.med","FluidMesh_1");//../STEP3/coeur.med","RJHMESH"); - mesh.setName("RJHMESH"); - MED_MESH_RDONLY_DRIVER22 *drv=new MED_MESH_RDONLY_DRIVER22("coeur.med",&mesh); - drv->desactivateFacesComputation(); - int newDrv=mesh.addDriver(*drv); - delete drv; - mesh.read(newDrv); - cout << " *** " << mesh.getNumberOfTypes(MED_EN::MED_FACE) << endl; - cout << "Expected 8 - having " << mesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS) << endl; - cout << "Expected 6 - having " << mesh.getNumberOfElements(MED_FACE,MED_QUAD4) << endl; - cout << "Expected 1 - having " << mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) << endl; - return 0; -} diff --git a/src/MEDMEMBinTest/testAnalFile.cxx b/src/MEDMEMBinTest/testAnalFile.cxx deleted file mode 100644 index 49640a3ce..000000000 --- a/src/MEDMEMBinTest/testAnalFile.cxx +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include -#include -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_DriverFactory.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -int main(int argc, char *argv[]) -{ - if (argc !=2) - { - cerr << "Usage : " << argv[0] - << " fileName.med where fileName.med should be a med file" << endl; - cerr << " It will then generate med file fileNameAnal.med" << endl << endl; - exit(-1); - } - - int i; - // This test program is more or less designed to work with file TimeStamps.med - // If you want to use it for other Med files, you have to alter the mounting in memory of the fields f1 and f2 - //string fileIn="/export/home/geay32/SALOME225/KERNEL_SRC/examples/TimeStamps.med"; - - string fileIn = argv[1] ; - const string ext=".med"; - string::size_type pos=fileIn.find(ext,0); - string baseName (fileIn, 0, pos); // nom sans extension - string fileOut=baseName + "Anal_V22.med"; - - MEDFILEBROWSER *myMed=new MEDFILEBROWSER(fileIn); - int nbOfMeshes=myMed->getNumberOfMeshes(); - int nbOfFields=myMed->getNumberOfFields(); - cout << nbOfMeshes << " --- " << nbOfFields << endl; - vector names=myMed->getMeshNames(); - for(i=0;i names2=myMed->getFieldNames(); - for(i=0;i iterations=myMed->getFieldIteration(names2[2]); - cout << iterations.size() << endl; - FIELD *f1s=new FIELD(MED_DRIVER,fileIn,names2[2], - iterations[0].dt,iterations[0].it,mesh); - FIELD *f2s=new FIELD(MED_DRIVER,fileIn,names2[2], - iterations[1].dt,iterations[1].it,mesh); - int id=mesh->addDriver(MED_DRIVER,fileOut,mesh->getName()); - mesh->write(id); - id=f1s->addDriver(MED_DRIVER, fileOut, f1s->getName()); - f1s->write(id); - id=f2s->addDriver(MED_DRIVER, fileOut, f2s->getName()); - f2s->write(id); - - f1s->removeReference(); - f2s->removeReference(); - mesh->removeReference(); - delete myMed; - return 0; -} - diff --git a/src/MEDMEMBinTest/testConvertPolygon.cxx b/src/MEDMEMBinTest/testConvertPolygon.cxx deleted file mode 100644 index 81a4fdf0a..000000000 --- a/src/MEDMEMBinTest/testConvertPolygon.cxx +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Mesh.hxx" -#ifdef WIN32 -#include -#define access _access -#define W_OK 02 -#else -#include -#endif - -int main() -{ - // Get file to convert. - string file; - // During 'make check' $srcdir exists - if ( getenv("srcdir") ) { - file = string( getenv("srcdir")) + "/../../resources/"; - } - else if ( getenv( "MED_ROOT_DIR")) { - // after installation - file = string( getenv( "MED_ROOT_DIR" )) + "/share/salome/resources/med/"; - } - else - { - return -1; - } - file += "BoxTetra2.med"; - cout << "File to cnvert: " << file << endl; - // convertion - MEDMEM::MESH *mesh=new MEDMEM::MESH(MEDMEM::MED_DRIVER, file.c_str(), "BoxTetra2"); - mesh->convertToPoly(); - - // File to store conversion result - if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 ) - file = getenv("TMP"); - else if ( getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 ) - file = getenv("TMPDIR"); - else - file = "/tmp"; - file += "/pointe_testConvertPolygon.med"; - - int id=mesh->addDriver(MEDMEM::MED_DRIVER,file.c_str(),"mesh"); - mesh->write(id); - mesh->removeReference(); - - remove(file.c_str()); - - return 0; -} diff --git a/src/MEDMEMBinTest/test_GaussLocalization.cxx b/src/MEDMEMBinTest/test_GaussLocalization.cxx deleted file mode 100644 index 6794393c6..000000000 --- a/src/MEDMEMBinTest/test_GaussLocalization.cxx +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include -#include - -#define INTERLACING_TAG FullInterlace - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_GaussLocalization.hxx" -#include "MEDMEM_ArrayInterface.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -#define _a 0.446948490915965 -#define _b 0.091576213509771 -#define _p1 0.11169079483905 -#define _p2 0.0549758718227661 - -int main (int argc, char ** argv) { - - typedef MEDMEM_ArrayInterface::Array Array; - - - /* Caractéristiques du model n° 1 de localisation des points de gauss pour le champ n°1*/ - MED_EN::medGeometryElement typeGeo = MED_TRIA6; - - int ngauss1_1 = 6; - string gauss1_1("Model n1"); - double refcoo1 [12] = { -1.0,1.0, -1.0,-1.0, 1.0,-1.0, -1.0,0.0, 0.0,-1.0, 0.0,0.0 }; - - double gscoo1_1[12] = { 2*_b-1, 1-4*_b, 2*_b-1, 2*_b-1, 1-4*_b, - 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 }; - double wg1_1[6] = { 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 }; - - - assert( ( (typeGeo%100)*(typeGeo/100) ) == 12 ); - - GAUSS_LOCALIZATION myloc1 = GAUSS_LOCALIZATION(gauss1_1,typeGeo,ngauss1_1, - Array(refcoo1,typeGeo/100,(typeGeo%100) ), - Array(gscoo1_1,typeGeo/100,ngauss1_1), - vector (wg1_1,wg1_1+ngauss1_1) - ); - GAUSS_LOCALIZATION myloc1bis = GAUSS_LOCALIZATION(gauss1_1,typeGeo,ngauss1_1, - refcoo1,gscoo1_1, - wg1_1); - - cout << "myloc1 == myloc1bis " << (myloc1 == myloc1bis) << endl; - cout << "myloc1 : " << endl << myloc1 << endl; -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_Array.cxx b/src/MEDMEMBinTest/test_MEDMEM_Array.cxx deleted file mode 100644 index 16f89a30d..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_Array.cxx +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Array.hxx" - -using namespace std; -using namespace MEDMEM; -int main (int argc, char ** argv) { - - int SpaceDimension = 3 ; - int NumberOfNodes = 4 ; - MEDARRAY * myArray = new MEDARRAY(SpaceDimension,NumberOfNodes,MED_EN::MED_FULL_INTERLACE) ; - - //const int * value = myArray->get(MED_FULL_INTERLACE) ; - for (int i=1; i<=NumberOfNodes; i++) - for (int j=1; j<=SpaceDimension; j++) - myArray->setIJ(i,j,i) ; - - int numberof ; - MESSAGE_MED("Show all 1 :"); - numberof = myArray->getLeadingValue() ; - for (int i=1; i<=myArray->getLengthValue() ; i++) { - //int * node = myArray->getI(MED_FULL_INTERLACE,i) ; - const int * node = myArray->getRow(i) ; - cout << " - " ; - for (int j=0;jgetLengthValue() ; - for (int i=1; i<=myArray->getLeadingValue() ; i++) { - //int * node = myArray->getJ(MED_NO_INTERLACE,i) ; - const int * node = myArray->getColumn(i) ; - cout << " - " ; - for (int j=0;jgetLeadingValue() ; - for (int i=1; i<=myArray->getLengthValue() ; i++) { - cout << " - " ; - for (int j=1;jgetIJ(i,j) << " " ; - cout << endl ; - } - - MESSAGE_MED("Show all 0 :"); - numberof = myArray->getLeadingValue() ; - int length = myArray->getLengthValue() ; - const int * NoInterlaceArray = myArray->get(MED_EN::MED_NO_INTERLACE) ; - for (int i=0; i geomList = meshEntities[MED_CELL] ; - list::iterator itGeomList ; - for(itGeomList=geomList.begin();itGeomList!=geomList.end();itGeomList++) { - CELLMODEL myCellModel((MED_EN::medGeometryElement)(*itGeomList)) ; - - cout << "First CellModel :" << endl << endl ; - - cout << myCellModel << endl ; - - cout << "Number of constituents type : "< geomType = myCellModel.getAllConstituentsType() ; - set ::iterator geomTypeIt ; - cout << "Types list : " ; - for(geomTypeIt=geomType.begin();geomTypeIt!=geomType.end();geomTypeIt++) - cout << (*geomTypeIt) << " " ; - cout << endl; - - map myMap = myCellModel.getNumberOfConstituentsForeachType() ; - map ::iterator myMapIt ; - for(myMapIt=myMap.begin();myMapIt!=myMap.end();myMapIt++) - cout << " - " << (*myMapIt).second << " constituent(s) of type " << (*myMapIt).first << endl ; - cout << endl; - - cout << "Second CellModel :" << endl << endl ; - CELLMODEL myCellModel2=myCellModel ; - cout << myCellModel2 << endl ; - - cout << "Third CellModel :" << endl << endl ; - CELLMODEL myCellModel3 ; - myCellModel3=myCellModel ; - cout << myCellModel3 << endl ; - } -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_Meshing.cxx b/src/MEDMEMBinTest/test_MEDMEM_Meshing.cxx deleted file mode 100644 index 4f0cc8124..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_Meshing.cxx +++ /dev/null @@ -1,708 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//#define protected public -//#define private public -// -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Field.hxx" -#ifdef WIN32 -#include -#define access _access -#define W_OK 02 -#endif - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; -using namespace DRIVERFACTORY; - -int main (int argc, char ** argv) -{ - if (argc >2) - { - cerr << "Usage : " << argv[0] - << " filenameRoot" << endl; - cerr << " where filenameRoot is a root filename, the program will produce" << endl; - cerr << " 3 files filenameRoot21.med filenameRoot22.med and filenameRoot.vtk" << endl << endl; - exit(-1); - } - - string filenameRoot; - if (argc==1) - { - // filename to save the generated MESH - if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 ) - filenameRoot=getenv("TMP"); - else if (getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 ) - filenameRoot=getenv("TMPDIR"); - else - filenameRoot="/tmp"; - filenameRoot += "/test_MEDMEM_Meshing" ; - } - else - filenameRoot=argv[1]; - - string filenameMed21 = filenameRoot+"_V21.med"; - string filenameMed22 = filenameRoot+"_V22.med"; - string filenameVtk = filenameRoot+".vtk"; - - MESHING *myMeshing=new MESHING; - myMeshing->setName("meshing") ; - - // define coordinates - - int SpaceDimension = 3 ; - int NumberOfNodes = 19 ; - double Coordinates[57] = - { - 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 2.0, 0.0, 1.0, - 0.0, 2.0, 1.0, - -2.0, 0.0, 1.0, - 0.0, -2.0, 1.0, - 1.0, 1.0, 2.0, - -1.0, 1.0, 2.0, - -1.0, -1.0, 2.0, - 1.0, -1.0, 2.0, - 1.0, 1.0, 3.0, - -1.0, 1.0, 3.0, - -1.0, -1.0, 3.0, - 1.0, -1.0, 3.0, - 1.0, 1.0, 4.0, - -1.0, 1.0, 4.0, - -1.0, -1.0, 4.0, - 1.0, -1.0, 4.0, - 0.0, 0.0, 5.0 - }; - - myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE); - - string Names[3] = - { - "X","Y","Z" - } ; - myMeshing->setCoordinatesNames(Names); - - string Units[3] = - { - "cm","cm","cm" - } ; - myMeshing->setCoordinatesUnits(Units) ; - - // define conectivities - - // cell part - - const int NumberOfTypes = 3 ; - medGeometryElement Types[NumberOfTypes] = - { - MED_TETRA4,MED_PYRA5,MED_HEXA8 - } ; - const int NumberOfElements[NumberOfTypes] = - { - 12,2,2 - } ; - - myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL); - myMeshing->setTypes(Types,MED_CELL); - myMeshing->setNumberOfElements(NumberOfElements,MED_CELL); - - const int sizeTetra = 12*4 ; - int ConnectivityTetra[sizeTetra]= - { - 1,2,3,6, - 1,2,4,3, - 1,2,5,4, - 1,2,6,5, - 2,7,4,3, - 2,8,5,4, - 2,9,6,5, - 2,10,3,6, - 2,7,3,10, - 2,8,4,7, - 2,9,5,8, - 2,10,6,9 - }; - - myMeshing->setConnectivity(MED_CELL,MED_TETRA4,ConnectivityTetra); - - int ConnectivityPyra[2*5]= - { - 7,8,9,10,2, - 15,18,17,16,19 - }; - - myMeshing->setConnectivity(MED_CELL,MED_PYRA5,ConnectivityPyra); - - int ConnectivityHexa[2*8]= - { - 11,12,13,14,7,8,9,10, - 15,16,17,18,11,12,13,14 - }; - - myMeshing->setConnectivity(MED_CELL,MED_HEXA8,ConnectivityHexa); - - // face part - - const int NumberOfFacesTypes = 2 ; - medGeometryElement FacesTypes[NumberOfFacesTypes] = - { - MED_TRIA3,MED_QUAD4 - } ; - const int NumberOfFacesElements[NumberOfFacesTypes] = - { - 4,4 - } ; - - myMeshing->setNumberOfTypes(NumberOfFacesTypes,MED_FACE); - myMeshing->setTypes(FacesTypes,MED_FACE); - myMeshing->setNumberOfElements(NumberOfFacesElements,MED_FACE); - - const int sizeTria = 3*4 ; - int ConnectivityTria[sizeTria]= - { - 1,4,3, - 1,5,4, - 1,6,5, - 1,3,6 - }; - myMeshing->setConnectivity(MED_FACE,MED_TRIA3,ConnectivityTria); - - int ConnectivityQua[4*4]= - { - 7,8,9,10, - 11,12,13,14, - 11,7,8,12, - 12,8,9,13 - }; - - myMeshing->setConnectivity(MED_FACE,MED_QUAD4,ConnectivityQua); - - // edge part - - // not yet implemented : if set, results are unpredictable. - - // Some groups : - - // Node : - - GROUP *partialGroupOnNodes=new GROUP; - { - partialGroupOnNodes->setName("SomeNodes"); - partialGroupOnNodes->setMesh(myMeshing); - partialGroupOnNodes->setEntity(MED_NODE); - partialGroupOnNodes->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_NONE - }; - partialGroupOnNodes->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 4 - } ; - partialGroupOnNodes->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,5 - } ; - const int value[4]= - { - 1,4,5,7 - } ; - partialGroupOnNodes->setNumber(index,value); - } - GROUP *partialGroupOnNodes2=new GROUP; - { - partialGroupOnNodes2->setName("OtherNodes"); - partialGroupOnNodes2->setMesh(myMeshing); - partialGroupOnNodes2->setEntity(MED_NODE); - partialGroupOnNodes2->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_NONE - }; - partialGroupOnNodes2->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 3 - } ; - partialGroupOnNodes2->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,4 - } ; - const int value[3]= - { - 2,3,6 - } ; - partialGroupOnNodes2->setNumber(index,value); - } - myMeshing->addGroup(*partialGroupOnNodes2); - - - // Cell : - - GROUP *partialGroupOnCells=new GROUP; - { - partialGroupOnCells->setName("SomeCells"); - partialGroupOnCells->setMesh(myMeshing); - partialGroupOnCells->setEntity(MED_CELL); - partialGroupOnCells->setNumberOfGeometricType(3); - medGeometryElement myTypes[3] = - { - MED_TETRA4,MED_PYRA5,MED_HEXA8 - }; - partialGroupOnCells->setGeometricType(myTypes); - const int myNumberOfElements[3] = - { - 4,1,2 - } ; - partialGroupOnCells->setNumberOfElements(myNumberOfElements); - const int index[3+1] = - { - 1,5,6,8 - } ; - const int value[4+1+2]= - { - 2,7,8,12, - 13, - 15,16 - }; - partialGroupOnCells->setNumber(index,value); - } - myMeshing->addGroup(*partialGroupOnCells); - - - GROUP *partialGroupOnCells2=new GROUP; - { - partialGroupOnCells2->setName("OtherCells"); - partialGroupOnCells2->setMesh(myMeshing); - partialGroupOnCells2->setEntity(MED_CELL); - partialGroupOnCells2->setNumberOfGeometricType(2); - medGeometryElement myTypes[] = - { - MED_TETRA4,MED_PYRA5 - }; - partialGroupOnCells2->setGeometricType(myTypes); - const int myNumberOfElements[] = - { - 4,1 - } ; - partialGroupOnCells2->setNumberOfElements(myNumberOfElements); - const int index[2+1] = - { - 1,5,6 - } ; - const int value[4+1]= - { - 3,4,5,9, - 14 - }; - partialGroupOnCells2->setNumber(index,value); - } - myMeshing->addGroup(*partialGroupOnCells2); - - // Face : - - GROUP *partialGroupOnFaces=new GROUP; - { - partialGroupOnFaces->setName("SomeFaces"); - partialGroupOnFaces->setMesh(myMeshing); - partialGroupOnFaces->setEntity(MED_FACE); - partialGroupOnFaces->setNumberOfGeometricType(2); - medGeometryElement myTypes[2] = - { - MED_TRIA3,MED_QUAD4 - }; - partialGroupOnFaces->setGeometricType(myTypes); - const int myNumberOfElements[2] = - { - 2,3 - } ; - partialGroupOnFaces->setNumberOfElements(myNumberOfElements); - const int index[2+1] = - { - 1,3,6 - } ; - const int value[2+3]= - { - 2,4, - 5,6,8 - } ; - partialGroupOnFaces->setNumber(index,value); - } - myMeshing->addGroup(*partialGroupOnFaces); - - - GROUP *partialGroupOnFaces2=new GROUP; - { - partialGroupOnFaces2->setName("OtherFaces"); - partialGroupOnFaces2->setMesh(myMeshing); - partialGroupOnFaces2->setEntity(MED_FACE); - medGeometryElement myTypes[1] = - { - MED_TRIA3 - }; - int myNumberOfElements[1] = - { - 2 - } ; - int value[2]= - { - 1,3 - } ; - // partialGroupOnFaces2->setNumber(index,value); - partialGroupOnFaces2->setpartial("description",1,2,myTypes,myNumberOfElements,value); - } - myMeshing->addGroup(*partialGroupOnFaces2); - - // all right, we save it in Med 2.1 2.2 and vtk ! - - int idMed22 = myMeshing->addDriver(MED_DRIVER,filenameMed22,myMeshing->getName()); - myMeshing->write(idMed22) ; - - int idVtk = myMeshing->addDriver(VTK_DRIVER,filenameVtk,myMeshing->getName()); - myMeshing->write(idVtk) ; - - // we build now 8 fields : 4 fields double (integer) : - // 2 fields on nodes (cells) : - // 1 scalar (vector) - - const SUPPORT * supportOnNodes = myMeshing->getSupportOnAll(MED_NODE); - int numberOfNodes = supportOnNodes->getNumberOfElements(MED_ALL_ELEMENTS); - - const SUPPORT * supportOnCells = myMeshing->getSupportOnAll(MED_CELL); - myMeshing->removeReference(); - int numberOfCells = supportOnCells->getNumberOfElements(MED_ALL_ELEMENTS); - - FIELD * fieldDoubleScalarOnNodes = new FIELD(supportOnNodes,1); - fieldDoubleScalarOnNodes->setName("fieldScalarDoubleNode"); - fieldDoubleScalarOnNodes->setIterationNumber(-1); - fieldDoubleScalarOnNodes->setOrderNumber(-1); - fieldDoubleScalarOnNodes->setTime(0.0); - - fieldDoubleScalarOnNodes->setComponentName(1,"Vx"); - fieldDoubleScalarOnNodes->setComponentDescription(1,"comp1"); - fieldDoubleScalarOnNodes->setMEDComponentUnit(1,"unit1"); - FIELD* fieldDoubleScalarOnPartialNodes = new FIELD(partialGroupOnNodes,1); - fieldDoubleScalarOnPartialNodes->setName("fieldScalarDoublePartialNodes"); - fieldDoubleScalarOnPartialNodes->setIterationNumber(-1); - fieldDoubleScalarOnPartialNodes->setOrderNumber(-1); - fieldDoubleScalarOnPartialNodes->setTime(0.0); - fieldDoubleScalarOnPartialNodes->setComponentName(1,"Vx"); - fieldDoubleScalarOnPartialNodes->setComponentDescription(1,"comp1"); - fieldDoubleScalarOnPartialNodes->setMEDComponentUnit(1,"unit1"); - - - FIELD * fieldDoubleVectorOnNodes = new FIELD(supportOnNodes,SpaceDimension); - fieldDoubleVectorOnNodes->setName("fieldVectorDoubleNode"); - fieldDoubleVectorOnNodes->setIterationNumber(-1); - fieldDoubleVectorOnNodes->setOrderNumber(-1); - fieldDoubleVectorOnNodes->setTime(0.0); - - fieldDoubleVectorOnNodes->setComponentName(1,"Vx"); - fieldDoubleVectorOnNodes->setComponentDescription(1,"comp1"); - fieldDoubleVectorOnNodes->setMEDComponentUnit(1,"unit1"); - fieldDoubleVectorOnNodes->setComponentName(2,"Vy"); - fieldDoubleVectorOnNodes->setComponentDescription(2,"comp2"); - fieldDoubleVectorOnNodes->setMEDComponentUnit(2,"unit2"); - fieldDoubleVectorOnNodes->setComponentName(3,"Vz"); - fieldDoubleVectorOnNodes->setComponentDescription(3,"comp3"); - fieldDoubleVectorOnNodes->setMEDComponentUnit(3,"unit3"); - - FIELD * fieldDoubleScalarOnCells = new FIELD(supportOnCells,1); - fieldDoubleScalarOnCells->setName("fieldScalarDoubleCell"); - fieldDoubleScalarOnCells->setIterationNumber(-1); - fieldDoubleScalarOnCells->setOrderNumber(-1); - fieldDoubleScalarOnCells->setTime(0.0); - - fieldDoubleScalarOnCells->setComponentName(1,"Vx"); - fieldDoubleScalarOnCells->setComponentDescription(1,"comp1"); - fieldDoubleScalarOnCells->setMEDComponentUnit(1,"unit1"); - - - FIELD * fieldDoubleScalarOnPartialCells = new FIELD(partialGroupOnCells,1); - fieldDoubleScalarOnPartialCells->setName("fieldScalarDoublePartialCell"); - fieldDoubleScalarOnPartialCells->setIterationNumber(-1); - fieldDoubleScalarOnPartialCells->setOrderNumber(-1); - fieldDoubleScalarOnPartialCells->setTime(0.0); - - fieldDoubleScalarOnPartialCells->setComponentName(1,"Vx"); - fieldDoubleScalarOnPartialCells->setComponentDescription(1,"comp1"); - fieldDoubleScalarOnPartialCells->setMEDComponentUnit(1,"unit1"); - - FIELD * fieldDoubleScalarOnPartialFaces = new FIELD(partialGroupOnFaces,1); - fieldDoubleScalarOnPartialFaces->setName("fieldScalarDoublePartialFace"); - fieldDoubleScalarOnPartialFaces->setIterationNumber(-1); - fieldDoubleScalarOnPartialFaces->setOrderNumber(-1); - fieldDoubleScalarOnPartialFaces->setTime(0.0); - fieldDoubleScalarOnPartialFaces->setComponentName(1,"Vx"); - fieldDoubleScalarOnPartialFaces->setComponentDescription(1,"comp1"); - fieldDoubleScalarOnPartialFaces->setMEDComponentUnit(1,"unit1"); - - FIELD * fieldDoubleVectorOnPartialFaces = new FIELD(partialGroupOnFaces2,2); - fieldDoubleVectorOnPartialFaces->setName("fieldVectorDoublePartialFace"); - fieldDoubleVectorOnPartialFaces->setIterationNumber(-1); - fieldDoubleVectorOnPartialFaces->setOrderNumber(-1); - fieldDoubleVectorOnPartialFaces->setTime(0.0); - fieldDoubleVectorOnPartialFaces->setComponentName(1,"Vx"); - fieldDoubleVectorOnPartialFaces->setComponentName(2,"Vy"); - - fieldDoubleVectorOnPartialFaces->setComponentDescription(1,"comp1"); - fieldDoubleVectorOnPartialFaces->setComponentDescription(2,"comp2"); - - fieldDoubleVectorOnPartialFaces->setMEDComponentUnit(1,"unit1"); - fieldDoubleVectorOnPartialFaces->setMEDComponentUnit(2,"unit2"); - - - FIELD * fieldDoubleVectorOnCells = new FIELD(supportOnCells,SpaceDimension); - fieldDoubleVectorOnCells->setName("fieldVectorrDoubleCell"); - fieldDoubleVectorOnCells->setIterationNumber(-1); - fieldDoubleVectorOnCells->setOrderNumber(-1); - fieldDoubleVectorOnCells->setTime(0.0); - - fieldDoubleVectorOnCells->setComponentName(1,"Vx"); - fieldDoubleVectorOnCells->setComponentDescription(1,"comp1"); - fieldDoubleVectorOnCells->setMEDComponentUnit(1,"unit1"); - fieldDoubleVectorOnCells->setComponentName(2,"Vy"); - fieldDoubleVectorOnCells->setComponentDescription(2,"comp2"); - fieldDoubleVectorOnCells->setMEDComponentUnit(2,"unit2"); - fieldDoubleVectorOnCells->setComponentName(3,"Vz"); - fieldDoubleVectorOnCells->setComponentDescription(3,"comp3"); - fieldDoubleVectorOnCells->setMEDComponentUnit(3,"unit3"); - - FIELD * fieldIntScalarOnNodes = new FIELD(supportOnNodes,1); - fieldIntScalarOnNodes->setName("fieldScalarIntNode"); - fieldIntScalarOnNodes->setIterationNumber(-1); - fieldIntScalarOnNodes->setOrderNumber(-1); - fieldIntScalarOnNodes->setTime(0.0); - - fieldIntScalarOnNodes->setComponentName(1,"Vx"); - fieldIntScalarOnNodes->setComponentDescription(1,"comp1"); - fieldIntScalarOnNodes->setMEDComponentUnit(1,"unit1"); - - FIELD * fieldIntVectorOnNodes = new FIELD(supportOnNodes,SpaceDimension); - fieldIntVectorOnNodes->setName("fieldVectorIntNode"); - fieldIntVectorOnNodes->setIterationNumber(-1); - fieldIntVectorOnNodes->setOrderNumber(-1); - fieldIntVectorOnNodes->setTime(0.0); - - fieldIntVectorOnNodes->setComponentName(1,"Vx"); - fieldIntVectorOnNodes->setComponentDescription(1,"comp1"); - fieldIntVectorOnNodes->setMEDComponentUnit(1,"unit1"); - fieldIntVectorOnNodes->setComponentName(2,"Vy"); - fieldIntVectorOnNodes->setComponentDescription(2,"comp2"); - fieldIntVectorOnNodes->setMEDComponentUnit(2,"unit2"); - fieldIntVectorOnNodes->setComponentName(3,"Vz"); - fieldIntVectorOnNodes->setComponentDescription(3,"comp3"); - fieldIntVectorOnNodes->setMEDComponentUnit(3,"unit3"); - - FIELD * fieldIntScalarOnCells = new FIELD(supportOnCells,1); - fieldIntScalarOnCells->setName("fieldScalarIntCell"); - fieldIntScalarOnCells->setIterationNumber(-1); - fieldIntScalarOnCells->setOrderNumber(-1); - fieldIntScalarOnCells->setTime(0.0); - - fieldIntScalarOnCells->setComponentName(1,"Vx"); - fieldIntScalarOnCells->setComponentDescription(1,"comp1"); - fieldIntScalarOnCells->setMEDComponentUnit(1,"unit1"); - - FIELD * fieldIntVectorOnCells = new FIELD(supportOnCells,SpaceDimension); - fieldIntVectorOnCells->setName("fieldVectorrIntCell"); - fieldIntVectorOnCells->setIterationNumber(-1); - fieldIntVectorOnCells->setOrderNumber(-1); - fieldIntVectorOnCells->setTime(0.0); - - fieldIntVectorOnCells->setComponentName(1,"Vx"); - fieldIntVectorOnCells->setComponentDescription(1,"comp1"); - fieldIntVectorOnCells->setMEDComponentUnit(1,"unit1"); - fieldIntVectorOnCells->setComponentName(2,"Vy"); - fieldIntVectorOnCells->setComponentDescription(2,"comp2"); - fieldIntVectorOnCells->setMEDComponentUnit(2,"unit2"); - fieldIntVectorOnCells->setComponentName(3,"Vz"); - fieldIntVectorOnCells->setComponentDescription(3,"comp3"); - fieldIntVectorOnCells->setMEDComponentUnit(3,"unit3"); - - for (int i = 0; isetValueIJ(i+1,1,valueDbl1); - - fieldIntScalarOnNodes->setValueIJ(i+1,1,valueInt1); - - fieldDoubleVectorOnNodes->setValueIJ(i+1,1,valueDbl1); - fieldDoubleVectorOnNodes->setValueIJ(i+1,2,valueDbl2); - fieldDoubleVectorOnNodes->setValueIJ(i+1,3,valueDbl3); - - fieldIntVectorOnNodes->setValueIJ(i+1,1,valueInt1); - fieldIntVectorOnNodes->setValueIJ(i+1,2,valueInt2); - fieldIntVectorOnNodes->setValueIJ(i+1,3,valueInt3); - } - - for (int i = 0; isetValueIJ(i+1,1,valueDbl1); - - fieldIntScalarOnCells->setValueIJ(i+1,1,valueInt1); - - fieldDoubleVectorOnCells->setValueIJ(i+1,1,valueDbl1); - fieldDoubleVectorOnCells->setValueIJ(i+1,2,valueDbl2); - fieldDoubleVectorOnCells->setValueIJ(i+1,3,valueDbl3); - - fieldIntVectorOnCells->setValueIJ(i+1,1,valueInt1); - fieldIntVectorOnCells->setValueIJ(i+1,2,valueInt2); - fieldIntVectorOnCells->setValueIJ(i+1,3,valueInt3); - } - - for (int i=0; igetNumberOfElements(MED_ALL_ELEMENTS); i++) - { - const int* number=partialGroupOnNodes->getNumber(MED_ALL_ELEMENTS); - fieldDoubleScalarOnPartialNodes->setValueIJ(number[i],1,i+1); - } - - for (int i=0; igetNumberOfElements(MED_ALL_ELEMENTS); i++) - { - const int* number=partialGroupOnCells->getNumber(MED_ALL_ELEMENTS); - fieldDoubleScalarOnPartialCells->setValueIJ(number[i],1,i+1); - } - - for (int i=0; igetNumberOfElements(MED_ALL_ELEMENTS); i++) - { - const int* number=partialGroupOnFaces->getNumber(MED_ALL_ELEMENTS); - fieldDoubleScalarOnPartialFaces->setValueIJ(number[i],1,i+1); - } - - for (int i=0; igetNumberOfElements(MED_ALL_ELEMENTS); i++) - { - const int* number=partialGroupOnFaces2->getNumber(MED_ALL_ELEMENTS); - fieldDoubleVectorOnPartialFaces->setValueIJ(number[i],1,i+1); - fieldDoubleVectorOnPartialFaces->setValueIJ(number[i],2,-i-1); - } - - idMed22 = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnNodes->getName()); - fieldDoubleScalarOnNodes->write(idMed22) ; - - idMed22 = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnNodes->getName()); - fieldIntScalarOnNodes->write(idMed22) ; - - idMed22 = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnNodes->getName()); - fieldDoubleVectorOnNodes->write(idMed22) ; - - idMed22 = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnNodes->getName()); - fieldIntVectorOnNodes->write(idMed22) ; - - idMed22 = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnCells->getName()); - fieldDoubleScalarOnCells->write(idMed22) ; - - idMed22 = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnCells->getName()); - fieldIntScalarOnCells->write(idMed22) ; - - idMed22 = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnCells->getName()); - fieldDoubleVectorOnCells->write(idMed22) ; - - idMed22 = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnCells->getName()); - fieldIntVectorOnCells->write(idMed22) ; - - idMed22 = fieldDoubleScalarOnPartialNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialNodes->getName()); - fieldDoubleScalarOnPartialNodes->write(idMed22) ; - - idMed22 = fieldDoubleScalarOnPartialCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialCells->getName()); - fieldDoubleScalarOnPartialCells->write(idMed22) ; - - idMed22 = fieldDoubleScalarOnPartialFaces->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialFaces->getName()); - fieldDoubleScalarOnPartialFaces->write(idMed22) ; - - idMed22 = fieldDoubleVectorOnPartialFaces->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnPartialFaces->getName()); - fieldDoubleVectorOnPartialFaces->write(idMed22) ; - - - idVtk = fieldDoubleScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnNodes->getName()); - fieldDoubleScalarOnNodes->writeAppend(idVtk) ; - - idVtk = fieldIntScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnNodes->getName()); - fieldIntScalarOnNodes->writeAppend(idVtk) ; - - idVtk = fieldDoubleVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnNodes->getName()); - fieldDoubleVectorOnNodes->writeAppend(idVtk) ; - - idVtk = fieldIntVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnNodes->getName()); - fieldIntVectorOnNodes->writeAppend(idVtk) ; - - idVtk = fieldDoubleScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnCells->getName()); - fieldDoubleScalarOnCells->writeAppend(idVtk) ; - - idVtk = fieldIntScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnCells->getName()); - fieldIntScalarOnCells->writeAppend(idVtk) ; - - idVtk = fieldDoubleVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnCells->getName()); - fieldDoubleVectorOnCells->writeAppend(idVtk) ; - - idVtk = fieldIntVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnCells->getName()); - fieldIntVectorOnCells->writeAppend(idVtk) ; - - if (argc==1) - { - cout << "Remove generated files" << endl; - remove(filenameMed21.c_str()); - remove(filenameMed22.c_str()); - remove(filenameVtk.c_str()); - } - - fieldDoubleScalarOnNodes->removeReference(); - fieldIntScalarOnNodes->removeReference(); - fieldDoubleVectorOnNodes->removeReference(); - fieldIntVectorOnNodes->removeReference(); - fieldDoubleScalarOnCells->removeReference(); - fieldIntScalarOnCells->removeReference(); - fieldDoubleVectorOnCells->removeReference(); - fieldIntVectorOnCells->removeReference(); - fieldDoubleScalarOnPartialCells->removeReference(); - fieldDoubleScalarOnPartialNodes->removeReference(); - fieldDoubleScalarOnPartialFaces->removeReference(); - fieldDoubleVectorOnPartialFaces->removeReference(); - - partialGroupOnNodes->removeReference(); - partialGroupOnNodes2->removeReference(); - partialGroupOnCells->removeReference(); - partialGroupOnCells2->removeReference(); - partialGroupOnFaces->removeReference(); - partialGroupOnFaces2->removeReference(); -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_MeshingFlica.cxx b/src/MEDMEMBinTest/test_MEDMEM_MeshingFlica.cxx deleted file mode 100644 index 6156e4305..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_MeshingFlica.cxx +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Group.hxx" -#ifdef WIN32 -#include -#define access _access -#define W_OK 02 -#else -#include -#endif - -double coords[108]= - {0, 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, 0, - 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, 0, - 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, 0, - 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, - //coordY - 0, 0, 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, 0, 0, - 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, 0, 0, - 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, 0, 0, - 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, - //coordZ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.15677, 0.15677, - 0.15677, 0.15677, 0.15677, - 0.15677, 0.15677, 0.15677, - 0.15677, 0.1934, 0.1934, - 0.1934, 0.1934, 0.1934, - 0.1934, 0.1934, 0.1934, - 0.1934, 0.3485, 0.3485, - 0.3485, 0.3485, 0.3485, - 0.3485, 0.3485, 0.3485, - 0.3485}; - -int connNodalCellClassical[48]= - { 1, 2, 3, 4, 10, 11, 12, 13, - 4, 3, 7, 8, 13, 12, 16, 17, - 10, 11, 12, 13, 19, 20, 21, 22, - 13, 12, 16, 17, 22, 21, 25, 26, - 19, 20, 21, 22, 28, 29, 30, 31, - 22, 21, 25, 26, 31, 30, 34, 35 }; - -int polyHedraInd[7]={1, 30, 59, 88, 117, 146, 175}; - -int polyHedraConn[174]={ - 2, 3, 6, 5, -1, 11, 14, 15, 12, -1, 2, 5, 14, 11, -1, 5, 6, 15, 14, -1, 6, 3, 12, 15, -1, 3, 2, 11, 12, - 3, 7, 9, 6, -1, 12, 15, 18, 16, -1, 3, 6, 15, 12, -1, 6, 9, 18, 15, -1, 9, 7, 16, 18, -1, 7, 3, 12, 16, - 11, 12, 15, 14, -1, 20, 23, 24, 21, -1, 11, 14, 23, 20, -1, 14, 15, 24, 23, -1, 15, 12, 21, 24, -1, 12, 11, 20, 21, - 12, 16, 18, 15, -1, 21, 24, 27, 25, -1, 12, 15, 24, 21, -1, 15, 18, 27, 24, -1, 18, 16, 25, 27, -1, 16, 12, 21, 25, - 20, 21, 24, 23, -1, 29, 32, 33, 30, -1, 20, 23, 32, 29, -1, 23, 24, 33, 32, -1, 24, 21, 30, 33, -1, 21, 20, 29, 30, - 21, 25, 27, 24, -1, 30, 33, 36, 34, -1, 21, 24, 33, 30, -1, 24, 27, 36, 33, -1, 27, 25, 34, 36, -1, 25, 21, 30, 34 }; - -int connNodalFaceClassical[116]= - { 1, 2, 3, 4, - 10, 13, 12, 11, - 1, 2, 11, 10, - 2, 3, 12, 11, - 3, 4, 13, 12, - 4, 1, 10, 13, - 4, 3, 7, 8, - 13, 17, 16, 12, - 3, 7, 16, 12, - 7, 8, 17, 16, - 8, 4, 13, 17, - 19, 22, 21, 20, - 10, 11, 20, 19, - 11, 12, 21, 20, - 12, 13, 22, 21, - 13, 10, 19, 22, - 22, 26, 25, 21, - 12, 16, 25, 21, - 16, 17, 26, 25, - 17, 13, 22, 26, - 28, 31, 30, 29, - 19, 20, 29, 28, - 20, 21, 30, 29, - 21, 22, 31, 30, - 22, 19, 28, 31, - 31, 35, 34, 30, - 21, 25, 34, 30, - 25, 26, 35, 34, - 26, 22, 31, 35}; - -int cpolygonsIndex[24]= - { 1, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, - 73, 77, 81, 85, 89, 93}; - -int cpolygonsValue[92]= - {2, 5, 6, 3, - 11, 12, 15, 14, - 2, 5, 14, 11, - 5, 6, 15, 14, - 6, 3, 12, 15, - 3, 6, 9, 7, - 12, 16, 18, 15, - 6, 9, 18, 15, - 9, 7, 16, 18, - 20, 21, 24, 23, - 11, 14, 23, 20, - 14, 15, 24, 23, - 15, 12, 21, 24, - 21, 25, 27, 24, - 15, 18, 27, 24, - 18, 16, 25, 27, - 29, 30, 33, 32, - 20, 23, 32, 29, - 23, 24, 33, 32, - 24, 21, 30, 33, - 30, 34, 36, 33, - 24, 27, 36, 33, - 27, 25, 34, 36}; - -int bottom[4]={1,7,30,35}; -MED_EN::medGeometryElement bottomTypes[2]={MED_EN::MED_QUAD4, MED_EN::MED_POLYGON }; -int bottomIndex[3]={1,3,5}; -int bottomNbOfElts[2]={2,2}; -int top[4]={21,26,46,50}; -MED_EN::medGeometryElement topTypes[2]={MED_EN::MED_QUAD4, MED_EN::MED_POLYGON }; -int topIndex[3]={1,3,5}; -int topNbOfElts[2]={2,2}; -int side[24]={ 3, 6, 10, 11, 13, 16, 19, 20, 22, 25, 28, 29, 32, 33, 37, 38, 40, 41, 44, 45, 47, 48, 51, 52}; -MED_EN::medGeometryElement sideTypes[2]={MED_EN::MED_QUAD4, MED_EN::MED_POLYGON }; -int sideIndex[3]={1,13,25}; -int sideNbOfElts[2]={12,12}; - -using namespace MEDMEM; - -static void addMedFacesGroup( MESHING& meshing, int nFaces, const int *groupValue, - string groupName, const MED_EN::medGeometryElement *mytypes, const int *index, const int *myNumberOfElements, int nbOfGeomTypes) - { - GROUP *faces=new GROUP; - faces->setName(groupName) ; - faces->setMesh(&meshing) ; - faces->setEntity(MED_EN::MED_FACE) ; - faces->setNumberOfGeometricType(nbOfGeomTypes) ; - faces->setGeometricType(mytypes); - faces->setNumberOfElements(myNumberOfElements) ; - faces->setNumber(index, groupValue) ; - meshing.addGroup(*faces) ; - faces->removeReference(); - } - -int main() -{ - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=36; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN", - MED_EN::MED_NO_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = { "m", "m", "m" }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[2]={MED_EN::MED_HEXA8,MED_EN::MED_POLYHEDRA}; - const int nbOfCellElts[2]={6,6}; - meshing->setNumberOfTypes(2,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //Face connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesFace[2]={MED_EN::MED_QUAD4,MED_EN::MED_POLYGON}; - const int nbOfFaceElts[2]={29,23}; - meshing->setNumberOfTypes(2,MED_EN::MED_FACE); - meshing->setTypes(classicalTypesFace,MED_EN::MED_FACE); - meshing->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_HEXA8,connNodalCellClassical); - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA,polyHedraConn,polyHedraInd); - //All face conn - meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_QUAD4,connNodalFaceClassical); - meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_POLYGON, cpolygonsValue,cpolygonsIndex); - //Adding some groups on faces - addMedFacesGroup( *meshing, 4, bottom, "BottomFaces",bottomTypes,bottomIndex,bottomNbOfElts,2) ; - addMedFacesGroup( *meshing, 4, top, "TopFaces",topTypes,topIndex,topNbOfElts,2) ; - addMedFacesGroup( *meshing, 24, side, "SideFaces",sideTypes,sideIndex,sideNbOfElts,2) ; - //writing... - string medfile = "/tmp"; - if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 ) - medfile=getenv("TMP"); - else if (getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 ) - medfile=getenv("TMPDIR"); - medfile += "/totoFlica_V22.med"; - - int id=meshing->addDriver(MED_DRIVER,medfile.c_str()); - meshing->write(id); - meshing->removeReference(); - - if ( getenv("srcdir") ) - remove(medfile.c_str()); - - return 0; -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_MeshingPoly.cxx b/src/MEDMEMBinTest/test_MEDMEM_MeshingPoly.cxx deleted file mode 100644 index f073db20c..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_MeshingPoly.cxx +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Field.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -int main (int argc, char ** argv) -{ - double Coordinates[57] = - { - 2.0, 3.0, 2.0, - 3.0, 2.0, 2.0, - 4.0, 1.0, 2.0, - 2.0, 0.0, 2.0, - 0.0, 1.0, 2.0, - 1.0, 2.0, 2.0, - 2.0, 3.0, 1.0, - 3.0, 2.0, 0.0, - 4.0, 1.0, 0.0, - 2.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, 2.0, 0.0, - 5.0, 3.0, 2.0, - 7.0, 2.0, 2.0, - 6.0, 0.0, 2.0, - 6.0, 3.0, 0.0, - 7.0, 2.0, 0.0, - 6.0, 0.0, -1.0, - 5.0, 1.0, -3.0 - }; - - const int REFnodalConnOfFaces[91] = - { - 1, 2, 3, 4, 5, 6, -1,// Polyhedron 1 - 1, 7, 8, 2, -1, - 2, 8, 9, 3, -1, - 4, 3, 9, 10, -1, - 5, 4, 10, 11, -1, - 6, 5, 11, 12, -1, - 1, 6, 12, 7, -1, - 7, 12, 8, -1, - 10, 9, 8, 12, 11, - - 13, 14, 15, 3, 2, -1, // Polyhedron 2 - 13, 2, 8, 16, -1, - 14, 13, 16, 17, -1, - 15, 14, 17, -1, - 15, 17, 18, -1, - 15, 18, 9, -1, - 3, 15, 9, -1, - 2, 3, 9, 8, -1, - 8, 9, 17, 16, -1, - 9, 18, 17 - }; - - const int REFpolyIndex[3] = - { - 1, 47, 92 - }; - - double PolygonCoordinates[27] = - { - 2.0, 3.0, 12.0, - 3.0, 2.0, 12.0, - 4.0, 1.0, 12.0, - 2.0, 0.0, 12.0, - 0.0, 1.0, 12.0, - 1.0, 2.0, 12.0, - 5.0, 3.0, 12.0, - 7.0, 2.0, 12.0, - 6.0, 0.0, 12.0 - }; - - const int REFpolygonFaces[11] = - { - 1, 2, 3, 4, 5, 6, // Polygon 1 - 7, 8, 9, 3, 2 // Polygon 2 - }; - - const int REFpolygonIndex[3] = - { - 1, 7, 12 - }; - - MESHING *myMeshing=new MESHING; - myMeshing->setName("meshing"); - - int NumberOfNodes = 19; - int SpaceDimension = 3; - - const int NumberOfTypes = 2; - medGeometryElement Types[NumberOfTypes] = - { - MED_TETRA4, MED_POLYHEDRA - }; - const int NumberOfElements[NumberOfTypes] = - { - 1,2 - }; - - myMeshing->setNumberOfTypes(NumberOfTypes, MED_CELL); - - myMeshing->setCoordinates(SpaceDimension, NumberOfNodes, Coordinates, - "CARTESIAN", MED_FULL_INTERLACE); - myMeshing->setTypes(Types, MED_CELL); - myMeshing->setNumberOfElements(NumberOfElements, MED_CELL); - - string Names[3] = - { - "X","Y","Z" - }; - myMeshing->setCoordinatesNames(Names); - - string Units[3] = - { - "cm","cm","cm" - }; - myMeshing->setCoordinatesUnits(Units); - - const int sizeTetra = 4*1 ; - int ConnectivityTetra[sizeTetra]= - { - 17, 9, 18, 19 - }; - - myMeshing->setConnectivity(MED_CELL, MED_TETRA4, ConnectivityTetra); - - myMeshing->setConnectivity(MED_CELL, MED_POLYHEDRA, REFnodalConnOfFaces, REFpolyIndex); - - - MESHING *myPolygonMeshing=new MESHING; - myPolygonMeshing->setName("PolygonMeshing"); - - NumberOfNodes = 9; - SpaceDimension = 3; - medGeometryElement PolygonTypes[NumberOfTypes] = - { - MED_TRIA3,MED_POLYGON - }; - const int PolygonNumberOfElements[NumberOfTypes] = - { - 2,2 - }; - - myPolygonMeshing->setNumberOfTypes(NumberOfTypes, MED_CELL); - - myPolygonMeshing->setCoordinates(SpaceDimension, NumberOfNodes, PolygonCoordinates, - "CARTESIAN", MED_FULL_INTERLACE); - myPolygonMeshing->setTypes(PolygonTypes, MED_CELL); - myPolygonMeshing->setNumberOfElements(PolygonNumberOfElements, MED_CELL); - - myPolygonMeshing->setCoordinatesNames(Names); - myPolygonMeshing->setCoordinatesUnits(Units); - - const int sizeTri = 3*2 ; - int ConnectivityTri[sizeTri]= - { - 1, 7, 2, 3, 9, 4 - }; - - myPolygonMeshing->setConnectivity(MED_CELL, MED_TRIA3, ConnectivityTri); - myPolygonMeshing->setConnectivity(MED_CELL, MED_POLYGON, REFpolygonFaces, REFpolygonIndex); - FIELD *areas = myPolygonMeshing->getArea(myPolygonMeshing->getSupportOnAll( MED_CELL )); - myPolygonMeshing->removeReference(); - const double *vals2 = areas->getValue(); - const double REFAreaOfPolyg[4] = - { - 1.5, 2, 6, 6.5 - }; - int nbPts=0; - int i; - for(i=0;i<4;i++) - if(fabs(REFAreaOfPolyg[i]-vals2[i])<1e-12) - nbPts++; - areas->removeReference(); - - const SUPPORT *sup = myMeshing->getSupportOnAll(MED_CELL); - FIELD *vols = myMeshing->getVolume(sup,false); - const double *vals = vols->getValue(); - const double REFVolOfPolyHedron[3] = - { - 2.333333333333333, -11.66666666666666, -13.83224131414673 - }; - for(i=0;i<3;i++) - if(fabs(REFVolOfPolyHedron[i]-vals[i])<1e-12) - nbPts++; - - vols->removeReference(); - if(nbPts==7) - { - cout << "ALL TESTS OK !!!" << endl; - } - else - { - cout << "TEST FAILS !!!" << endl; - return -1; - } - cout << "Writing test " << endl; - myMeshing->write(MED_DRIVER,"totoPoly_V22.med"); - myMeshing->removeReference(); - if ( getenv("srcdir") ) // performing 'make check'? - remove("totoPoly_V22.med"); - return 0; -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_Meshing_poly.cxx b/src/MEDMEMBinTest/test_MEDMEM_Meshing_poly.cxx deleted file mode 100644 index aea1c5f04..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_Meshing_poly.cxx +++ /dev/null @@ -1,155 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_DriverFactory.hxx" -#ifdef WIN32 -#include -#define access _access -#define W_OK 02 -#endif - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; -using namespace DRIVERFACTORY; - -int main (int argc, char ** argv) -{ - // Traitement arguments - if (argc > 2) - { - cerr << "Usage : " << argv[0] - << " filenameRoot" << endl << endl - << "-> creer un maillage et le sauve dans le fichier filenameRoot22.med sous le format Med Fichier V2.2 car il contient un polygon." << endl; - exit(-1); - } - - string filenameRoot; - if (argc==2) - filenameRoot= argv[1] ; - else { - if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 ) - filenameRoot=getenv("TMP"); - else if (getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 ) - filenameRoot=getenv("TMPDIR"); - else - filenameRoot="/tmp"; - filenameRoot+="/testMeshingPoly"; - } - - string medfilename = filenameRoot + "22.med"; - - // Creation maillage - //*********************************************************************************** - - MESHING *myMeshing=new MESHING; - myMeshing->setName("myMeshing"); - - // define coordinates - - int SpaceDimension = 2; - int NumberOfNodes = 11; - double Coordinates[2*11] = { - 0.0, 0.0, - 0.5, 0.0, - 1.0, 0.0, - 0.25, 0.5, - 0.5, 0.5, - 0.75, 0.5, - 0.0, 1.0, - 0.5, 1.0, - 1.0, 1.0, - 1.5, 0.0, - 1.5, 1.0, - }; - - myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE); - - string Names[3] = { "X","Y","Z" }; - myMeshing->setCoordinatesNames(Names); - - string Units[3] = { "cm","cm","cm" }; - myMeshing->setCoordinatesUnits(Units); - - // define conectivities of classic types - - // cell part - - const int NumberOfTypes = 3; - medGeometryElement Types[NumberOfTypes] = {MED_TRIA3,MED_QUAD4,MED_POLYGON}; - const int NumberOfElements[NumberOfTypes] = {1,4,1}; - - myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL); - myMeshing->setTypes(Types,MED_CELL); - myMeshing->setNumberOfElements(NumberOfElements,MED_CELL); - - int ConnectivityTria[1*3]= - { - 7,4,1 - }; - - myMeshing->setConnectivity(MED_CELL,MED_TRIA3,ConnectivityTria); - - int ConnectivityQuad[4*4]= - { - 4,5,2,1, - 5,6,3,2, - 7,8,5,4, - 8,9,6,5 - }; - - myMeshing->setConnectivity(MED_CELL,MED_QUAD4,ConnectivityQuad); - - // then define eventuel polygonal cells - - int ConnectivityPolygon[1*5]= - { - 9,11,10,3,6 - }; - int ConnectivityPolygonIndex[2]= - { - 1,6 - }; - - myMeshing->setConnectivity(MED_CELL,MED_POLYGON,ConnectivityPolygon,ConnectivityPolygonIndex); - - // Ecriture fichier - - int idMed22 = myMeshing->addDriver(MED_DRIVER,medfilename,myMeshing->getName()); - myMeshing->write(idMed22) ; - - // int idVtk = myMeshing->addDriver(VTK_DRIVER,"toto.vtk",myMeshing->getName()); - // myMeshing->write(idVtk) ; - myMeshing->removeReference(); - - //************************************************************************************ - - // impression de controle - cout << endl; - cout << "Impression de MESHING : " << endl; - cout << myMeshing; - - if (argc==1) { - cout << "Remove generated file" << endl; - remove( medfilename.c_str() ); - } -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_ModulusArray.cxx b/src/MEDMEMBinTest/test_MEDMEM_ModulusArray.cxx deleted file mode 100644 index e0c2f5927..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_ModulusArray.cxx +++ /dev/null @@ -1,136 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_ModulusArray.hxx" - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char ** argv) { - using namespace std ; - - int array[5]={0,1,2,1,4} ; - MEDMODULUSARRAY modulusArray(5,array); - - cout<<"ModuloArray :"<setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshReadDriver(filename,myMesh); - myMeshReadDriver.setMeshName(meshname); - myMeshReadDriver.open(); - myMeshReadDriver.read(); - myMeshReadDriver.close(); - - cout << * myMesh << endl; - - myMesh->removeReference(); - return 0; -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_PolyDriverMedMeshWrite.cxx b/src/MEDMEMBinTest/test_MEDMEM_PolyDriverMedMeshWrite.cxx deleted file mode 100644 index 7e92a3044..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_PolyDriverMedMeshWrite.cxx +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -using namespace std; -using namespace MEDMEM; - - -int main (int argc, char ** argv) -{ - if (argc <3) // after 3, ignored ! - { - cerr << "Usage : " << argv[0] - << " filename meshname" << endl << endl; - exit(-1); - } - - string filename = argv[1]; - string meshname = argv[2]; - - // Lecture d'un fichier MED - MESH * myMesh = new MESH; - myMesh->setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshReadDriver(filename,myMesh); - myMeshReadDriver.setMeshName(meshname); - myMeshReadDriver.open(); - myMeshReadDriver.read(); - myMeshReadDriver.close(); - - // Ecriture dans un fichier MED - string filename2 = filename + "_copy"; - MED_MESH_WRONLY_DRIVER myMeshWriteDriver(filename2,myMesh); - myMeshWriteDriver.setMeshName(meshname); - myMeshWriteDriver.open(); - myMeshWriteDriver.write(); - myMeshWriteDriver.close(); - - - myMesh->removeReference(); - return 0; -} diff --git a/src/MEDMEMBinTest/test_MEDMEM_SkyLineArray.cxx b/src/MEDMEMBinTest/test_MEDMEM_SkyLineArray.cxx deleted file mode 100644 index 3d920a75f..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_SkyLineArray.cxx +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_SkyLineArray.hxx" - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char ** argv) { - int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle - int Size = 10 ; // 10 nodes - - int * index = new int[NumberOfCell+1] ; - index[0]=1; - index[1]=4; - index[2]=8; - index[3]=11; - int * value = new int[Size] ; - value[0]=1; // first - value[1]=2; - value[2]=5; - value[3]=2; // second - value[4]=3; - value[5]=5; - value[6]=6; - value[7]=3; // thirst - value[8]=4; - value[9]=6; - // value[]=; // forth - - MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ; - - cout << "Show all 1 :" << endl ; - for (int i=1; igetI(i) ; - int numberof = myArray->getNumberOfI(i) ; - cout << " - " ; - for (int j=0;jgetNumberOfI(i) ; - for (int j=1;jgetIJ(i,j) << " " ; - cout << endl ; - } - - MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ; - delete myArray ; - - cout << "Show all 3 :" << endl ; - const int * index2 = myArray2->getIndex() ; - for (int i=1; i<=NumberOfCell ; i++) { - cout << " - " ; - for (int j=index2[i-1];jgetIndexValue(j) << " " ; - cout << endl ; - } - - delete myArray2 ; - delete[] index ; - delete[] value ; - - return 0 ; -} - diff --git a/src/MEDMEMBinTest/test_MEDMEM_nArray.cxx b/src/MEDMEMBinTest/test_MEDMEM_nArray.cxx deleted file mode 100644 index ea942031f..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_nArray.cxx +++ /dev/null @@ -1,433 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include -#include -#include - -#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_IndexCheckingPolicy.hxx" -#include "MEDMEM_ArrayConvert.hxx" - -using namespace MEDMEM; - -int main(void) { - - const int mdim = 2; - const int nbelem1 = 20; - - // TEST n° 1 FullInterlace et NoGauss - std::cout << std::endl; - std::cout << "Test de MEDMEM_Array en FullInterlace et NoGauss : " << std::endl; - std::cout << std::endl; - - bool test1ok = true; - const double * myArray1Ptr = 0; - const double array1Ref[] = { 11 , 12 , 21 , 22 , 31 , 32 , 41 , 42 , 51 , 52 , - 61 , 62 , 71 , 72 , 81 , 82 , 91 , 92 , 101 , 102 , - 111 , 112 , 121 , 122 , 131 , 132 , 141 , 142 , - 151 , 152 , 161 , 162 , 171 , 172 , 181 , 182 , - 191 , 192 , 201 , 202 }; - - const double array2Ref[] = { 11 , 21 , 31 , 41 , 51 , 61 , 71 , 81 , 91 , 101 - , 111 , 121 , 131 , 141 , 151 , 161 , 171 , 181 - , 191 , 201 , - 12 , 22 , 32 , 42 , 52 , 62 , 72 , 82 , 92 , 102 - , 112 , 122 , 132 , 142 , 152 , 162 , 172 , 182 - , 192 , 202 }; - - MEDMEM_Array myArray1(mdim,nbelem1); - - for (int i =1; i <= nbelem1; i++) - for (int j =1; j <= mdim; j++) - myArray1.setIJ(i,j,i*10+j); - - myArray1Ptr = myArray1.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); - - std::cout << "- Egualité de myArray1 et de myArray1Ref : " << test1ok << std::endl ; - - test1ok = true; - MEDMEM_Array myArray1bis(myArray1, false); - myArray1Ptr = myArray1bis.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); - std::cout << "- Constructeur par recopie en FullInterlace et NoGauss : " << test1ok << std::endl; - - test1ok = true; - MEDMEM_Array myArray1ter; - myArray1ter = myArray1; - myArray1Ptr = myArray1ter.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); - std::cout << "- Opérateur d'affectation en FullInterlace et NoGauss : " << test1ok << std::endl; - - - test1ok = true; - MEDMEM_Array myArray1qua(mdim,nbelem1); - myArray1Ptr = myArray1qua.getPtr(); - - for (int i =1; i <= nbelem1; i++) - myArray1qua.setRow(i,&array1Ref[(i-1)*mdim]); - - for (int i =0; i < mdim*nbelem1; i++) - test1ok = test1ok && ( myArray1Ptr[i] == array1Ref[i] ); - std::cout << "- Méthode setRow en FullInterlace et NoGauss : " << test1ok << std::endl; - - std::cout << "- Test de levée d'exception pour getColumn : "; - try { - myArray1qua.getColumn(1); - } - catch (MEDMEM::MEDEXCEPTION &m) { - std::cout << m.what() << endl ; - } - - test1ok = true; - MEDMEM_Array * myArray1cin = ArrayConvert(myArray1); - myArray1Ptr = myArray1cin->getPtr(); - int elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i <= nbelem1 ; i++ ) { - test1ok = test1ok - && ( myArray1cin->getIJ(i,j) == array2Ref[elemno] ) - && ( myArray1Ptr[elemno] == array2Ref[elemno] ); - elemno++; - } - std::cout << "- Convertion du mode FullInterlaceNoGaussPolicy au mode NoInterlaceNoGaussPolicy : " - << test1ok << std::endl; - - - - // TEST n°2 NoInterlace et NoGauss - std::cout << std::endl; - std::cout << "Test de MEDMEM_Array en NoInterlace et NoGauss : " << std::endl; - std::cout << std::endl; - - bool test2ok = true; - const double * myArray2Ptr = 0; - - MEDMEM_Array myArray2(mdim,nbelem1); - - for (int i =1; i <= nbelem1; i++) - for (int j =1; j <= mdim; j++) - myArray2.setIJ(i,j,i*10+j); - - myArray2Ptr = myArray2.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); - - std::cout << "- Egualité de myArray2 et de myArray2Ref : " << test2ok << std::endl ; - - test2ok = true; - MEDMEM_Array myArray2bis(myArray2, false); - myArray2Ptr = myArray2bis.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); - std::cout << "- Constructeur par recopie en NoInterlace et NoGauss : " << test2ok << std::endl; - - test2ok = true; - MEDMEM_Array myArray2ter; - myArray2ter = myArray2; - myArray2Ptr = myArray2ter.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); - std::cout << "- Opérateur d'affectation en NoInterlace et NoGauss : " << test2ok << std::endl; - - test2ok = true; - MEDMEM_Array myArray2qua(mdim,nbelem1); - myArray2Ptr = myArray2qua.getPtr(); - - for (int j =1; j <= mdim; j++) - myArray2qua.setColumn(j,&array2Ref[nbelem1*(j-1)]); - - for (int i =0; i < mdim*nbelem1; i++) - test2ok = test2ok && ( myArray2Ptr[i] == array2Ref[i] ); - std::cout << "- Méthode setColumn en NoInterlace et NoGauss : " << test2ok << std::endl; - - std::cout << "- Test de levée d'exception pour getRow : " ; - try { - myArray2qua.getRow(1); - } - catch (MEDMEM::MEDEXCEPTION &m) { - std::cout << m.what() << endl ; - } - - test2ok = true; - MEDMEM_Array * myArray2cin = ArrayConvert(myArray2); - myArray2Ptr = myArray2cin->getPtr(); - elemno = 0; - for (int i=1; i <= nbelem1 ; i++ ) - for (int j=1; j <= mdim; j++) { - test2ok = test2ok - && ( myArray2cin->getIJ(i,j) == array1Ref[elemno] ) - && ( myArray2Ptr[elemno] == array1Ref[elemno] ); - elemno++; - } - std::cout << "- Convertion du mode NoInterlaceNoGaussPolicy au mode FullInterlaceNoGaussPolicy : " - << test2ok << std::endl; - - - // TEST n°3 FullInterlace et Gauss - const int nbelem2 = 5; - const int nbtypegeo = 2; - const int nbelgeoc[nbtypegeo+1] = {1,3,6}; - const int nbgaussgeo[nbtypegeo+1] = {-1,2,3}; - - std::cout << std::endl; - std::cout << "Test de MEDMEM_Array en FullInterlace et Gauss : " << std::endl; - std::cout << std::endl; - - bool test3ok = true; - const double * myArray3Ptr = 0; - const double array3Ref[] = {1.11 , 1.12 , 1.21 , 1.22 , - 2.11 , 2.12 , 2.21 , 2.22 , - 13.11 , 13.12 , 13.21 , 13.22 , 13.31 , 13.32 , - 14.11 , 14.12 , 14.21 , 14.22 , 14.31 , 14.32 , - 15.11 , 15.12 , 15.21 , 15.22 , 15.31 , 15.32 }; - - const double array4Ref[] = { 1.11 , 1.21 , 2.11 , 2.21, - 13.11 , 13.21 , 13.31 , 14.11 , 14.21 , 14.31 , - 15.11 , 15.21 , 15.31 , - 1.12 , 1.22 , 2.12 , 2.22 , - 13.12 , 13.22 , 13.32 , 14.12 , 14.22 , 14.32 , - 15.12 , 15.22 , 15.32 }; - - MEDMEM_Array myArray3(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); - - elemno = 1; - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { - for (int k=1; k <= nbgaussgeo[ntyp]; k++) - for (int j=1; j <= mdim; j++) { - myArray3.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j); - } - elemno++; - } - } - myArray3Ptr = myArray3.getPtr(); - for (int i =0; i < myArray3.getArraySize(); i++) - test3ok = test3ok && ( myArray3Ptr[i] == array3Ref[i] ); - - std::cout << "- Egualité de myArray3 et de myArray3Ref : " << test3ok << std::endl ; - - test3ok = true; - MEDMEM_Array myArray3bis(myArray3, false); - myArray3Ptr = myArray3bis.getPtr(); - - elemno = 0; - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray3bis.getNbGauss(i); k++) - for (int j=1; j <= mdim; j++) { - test3ok = test3ok - && ( myArray3bis.getIJK(i,j,k) == array3Ref[elemno] ) - && ( myArray3Ptr[elemno] == array3Ref[elemno] ); - elemno++; - } - std::cout << "- Constructeur par recopie en FullInterlace et Gauss : " << test3ok << std::endl; - - test3ok = true; - MEDMEM_Array myArray3ter; - myArray3ter = myArray3; //Opérateur d'affectation - myArray3Ptr = myArray3ter.getPtr(); - - elemno = 0; - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray3ter.getNbGauss(i); k++) - for (int j=1; j <= mdim; j++) { - test3ok = test3ok - && ( myArray3ter.getIJK(i,j,k) == array3Ref[elemno] ) - && ( myArray3Ptr[elemno] == array3Ref[elemno] ); - elemno++; - } - - std::cout << "- Opérateur d'affectation en FullInterlace et Gauss : " << test3ok << std::endl; - - - test3ok = true; - MEDMEM_Array myArray3qua(mdim,nbelem2, - nbtypegeo,nbelgeoc,nbgaussgeo); - myArray3Ptr = myArray3qua.getPtr(); - - int cumul = 0; - for (int i =1; i <= nbelem2; i++){ - myArray3qua.setRow(i,&array3Ref[cumul]); - cumul+=myArray3qua.getNbGauss(i)*mdim; - }; - - for (int i =0; i < myArray3qua.getArraySize(); i++) - test3ok = test3ok && ( myArray3Ptr[i] == array3Ref[i] ); - std::cout << "- Méthode setRow en FullInterlace et Gauss : " << test3ok << std::endl; - - std::cout << "- Test de levée d'exception pour getColumn : " ; - try { - myArray3qua.getColumn(1); - } - catch (MEDMEM::MEDEXCEPTION &m) { - std::cout << m.what() << endl ; - } - - test3ok = true; - MEDMEM_Array * myArray3cin = ArrayConvert(myArray3); - myArray3Ptr = myArray3cin->getPtr(); - elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray3cin->getNbGauss(i); k++) { - test3ok = test3ok - && ( myArray3cin->getIJK(i,j,k) == array4Ref[elemno] ) - && ( myArray3Ptr[elemno] == array4Ref[elemno] ); - elemno++; - } - std::cout << "- Convertion du mode FullInterlaceGaussPolicy au mode NoInterlaceGaussPolicy : " - << test3ok << std::endl; - - - // TEST n°4 NoInterlace et Gauss - std::cout << std::endl; - std::cout << "Test de MEDMEM_Array en NoInterlace et Gauss : " << std::endl; - std::cout << std::endl; - - bool test4ok = true; - const double * myArray4Ptr = 0; - - MEDMEM_Array myArray4(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); - - elemno = 1; - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { - for (int k=1; k <= nbgaussgeo[ntyp]; k++) - for (int j=1; j <= mdim; j++) { - myArray4.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j); - } - elemno++; - } - } - myArray4Ptr = myArray4.getPtr(); - for (int i =0; i < myArray4.getArraySize(); i++) { - test4ok = test4ok && ( myArray4Ptr[i] == array4Ref[i] ); - } - std::cout << "- Egualité de myArray4 et de myArray4Ref : " << test4ok << std::endl ; - - test4ok = true; - MEDMEM_Array myArray4bis(myArray4, false); - myArray4Ptr = myArray4bis.getPtr(); - - elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray4bis.getNbGauss(i); k++) { - test4ok = test4ok - && ( myArray4bis.getIJK(i,j,k) == array4Ref[elemno] ) - && ( myArray4Ptr[elemno] == array4Ref[elemno] ); - elemno++; - } - std::cout << "- Constructeur par recopie en NoInterlace et Gauss : " << test4ok << std::endl; - - test4ok = true; - MEDMEM_Array myArray4ter; - myArray4ter = myArray4; // Opérateur d'affectation - myArray4Ptr = myArray4ter.getPtr(); - - elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray4ter.getNbGauss(i); k++) { - test4ok = test4ok - && ( myArray4ter.getIJK(i,j,k) == array4Ref[elemno] ) - && ( myArray4Ptr[elemno] == array4Ref[elemno] ); - elemno++; - } - - std::cout << "- Opérateur d'affectation en NoInterlace et Gauss : " << test4ok << std::endl; - - - test4ok = true; - MEDMEM_Array myArray4qua(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); - myArray4Ptr = myArray4qua.getPtr(); - - for (int j =1; j <= mdim; j++) - myArray4qua.setColumn(j,&array4Ref[(myArray4qua.getArraySize()/mdim)*(j-1)]); - - for (int i =0; i < myArray4qua.getArraySize(); i++) - test4ok = test4ok && ( myArray4Ptr[i] == array4Ref[i] ); - std::cout << "- Méthode setColumn en NoInterlace et Gauss : " << test4ok << std::endl; - - std::cout << "- Test de levée d'exception pour getRow : " ; - try { - myArray4qua.getRow(1); - } - catch (MEDMEM::MEDEXCEPTION &m) { - std::cout << m.what() << endl ; - } - - - test4ok = true; - MEDMEM_Array * myArray4cin = ArrayConvert(myArray4); - //// MEDMEM_Array * myArray4cin; - ////ArrayConvert(myArray4,myArray4cin); - // typedef MEDMEM_Array MyArray; - // MyArray myArray4cin MyArray(myArray4); - // myArray4cin.convert(myArray4); - // MEDMEM_Array myArray4cin(myArray4); - myArray4Ptr = myArray4cin->getPtr(); - elemno = 0; - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray4cin->getNbGauss(i); k++) - for (int j=1; j <= mdim; j++) { - test4ok = test4ok - && ( myArray4cin->getIJK(i,j,k) == array3Ref[elemno] ) - && ( myArray4cin->getIJK(i,j,k) == myArray3.getIJK(i,j,k) ) - && ( myArray4Ptr[elemno] == array3Ref[elemno] ); - elemno++; - } - - std::cout << "- Convertion du mode NoInterlaceGaussPolicy au mode FullInterlaceGaussPolicy : " - << test4ok << std::endl; - - - //TEST DES METHODES D'INTERROGATION en NoInterlace et Gauss : - // MEDMEM_ArrayInterface::Array & myArray4bis = myField4bis.getArray(); - - std::cout << std::endl; - std::cout << "Test de la méthode getDim : " << myArray4bis.getDim() << std::endl; - std::cout << "Test de la méthode getNbelem : " << myArray4bis.getNbElem() << std::endl; - std::cout << "Test de la méthode getArraySize : " << myArray4bis.getArraySize() << std::endl; - std::cout << "Test de la méthode getInterlacingType : " << myArray4bis.getInterlacingType() << std::endl; - - - // Test de levée d'exception si MED_ARRAY compilée avec une politique de checking - std::cout << std::endl; - std::cout << "Test de levée d'exception pour indice incohérent " << std::endl; - try { - myArray4.getIJ(0,2); //L'exception génère des blocks perdus (A voir) - } - catch (MEDMEM::MEDEXCEPTION &m) { - std::cout << m.what() << endl ; - } - - - - return 0; - -} - diff --git a/src/MEDMEMBinTest/test_MEDMEM_poly3D.cxx b/src/MEDMEMBinTest/test_MEDMEM_poly3D.cxx deleted file mode 100755 index ff7f5c27d..000000000 --- a/src/MEDMEMBinTest/test_MEDMEM_poly3D.cxx +++ /dev/null @@ -1,348 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_ModulusArray.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include - -#define MESHNAME "poly3D" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -#define DIM_OF_FIELD 3 - - -class SupportTester -{ -private: - const int *_tabOfNodes; - vector _eltsActiveYet; - vector _lgthOfEltsActiveYet; -public: - SupportTester(const int *tabOfNodes, int nbOfElts, int nbOfNodesPerElt); - SupportTester(const int *tabOfNodes, int nbOfElts, const int *nbOfNodesPerElt); - bool isIncludedAndNotAlreadyConsumed(const int *tabOfNodesOfTheElementToTest); - bool areAllEltsConsumed(); -private: - static bool areEquivalent(const int *nodes1, const int *nodes2, int nbOfNodes); -}; - -SupportTester::SupportTester(const int *tabOfNodes, int nbOfElts, int nbOfNodesPerElt):_tabOfNodes(tabOfNodes) -{ - for(int i=0;i::iterator iter2=_lgthOfEltsActiveYet.begin(); - for(vector::iterator iter=_eltsActiveYet.begin();iter!=_eltsActiveYet.end();iter++) - if(areEquivalent(_tabOfNodes+(*iter),tabOfNodesOfTheElementToTest,*iter2)) - { - _eltsActiveYet.erase(iter); - _lgthOfEltsActiveYet.erase(iter2); - return true; - } - else - { - iter2++; - } - return false; -} - -bool SupportTester::areAllEltsConsumed() -{ - return _eltsActiveYet.size()==0; -} - -bool SupportTester::areEquivalent(const int *nodes1, const int *nodes2, int nbOfNodes) -{ - MEDMODULUSARRAY arr1(nbOfNodes,nodes1); - MEDMODULUSARRAY arr2(nbOfNodes,nodes2); - return arr1.compare(arr2)!=0; -} - -int main (int argc, char ** argv) -{ - if (argc<2) // after 2, ignored ! - { - cerr << "Usage : " << argv[0] << " poly3D.med typically in ../../share/salome/resources/med" << endl << endl; - exit(-1); - } - int nbOfPtsForTest=0; - int i; - string filename = argv[1]; - MESH * myMesh = new MESH; - myMesh->setName(MESHNAME); - MED_MESH_RDONLY_DRIVER myMeshReadDriver(filename,myMesh); - myMeshReadDriver.setMeshName(MESHNAME); - myMeshReadDriver.open(); - myMeshReadDriver.read(); - myMeshReadDriver.close(); - //Test 1 : test if connectivity of poly3D mesh is OK - if(myMesh->getMeshDimension()==3 && myMesh->getSpaceDimension()==3) - nbOfPtsForTest++; - if(myMesh->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_TETRA4)==1 && myMesh->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA)==2) - nbOfPtsForTest++; - const int REFnodalConnForTetra[4]= - { - 17, 9, 18, 19 - }; - const int *connForTetraToTest=myMesh->getConnectivity(MED_NODAL,MED_CELL,MED_TETRA4); - const int *connIndForTetraToTest=myMesh->getConnectivityIndex(MED_NODAL,MED_CELL); - for(i=connIndForTetraToTest[0]-1;igetConnectivity(MED_NODAL,MED_CELL,MED_POLYHEDRA); - if(globIndex[1]-globIndex[0]==46 && globIndex[2]-globIndex[1]==45)// resp 46 nodes and 45 nodes are in polyh 1 and 2. - nbOfPtsForTest++; - //7 - const int REFnodalConnOfFaces[91]= - { - 1, 2, 3, 4, 5, 6, -1,// Polyhedron 1 - 1, 7, 8, 2, -1, - 2, 8, 9, 3, -1, - 4, 3, 9, 10, -1, - 5, 4, 10, 11, -1, - 6, 5, 11, 12, -1, - 1, 6, 12, 7, -1, - 7, 12, 8, -1, - 10, 9, 8, 12, 11, - - 13, 14, 15, 3, 2, -1,// Polyhedron 2 - 13, 2, 8, 16, -1, - 14, 13, 16, 17, -1, - 15, 14, 17, -1, - 15, 17, 18, -1, - 15, 18, 9, -1, - 3, 15, 9, -1, - 2, 3, 9, 8, -1, - 8, 9, 17, 16, -1, - 9, 18, 17 - }; - for(i=0;i<74;i++) - if(REFnodalConnOfFaces[i]==nodalConnOfFaces[i]) - nbOfPtsForTest++; - if(nbOfPtsForTest!=7+74) - { - cout << "TEST1 K0 ! : Invalid Globaldata in memory..." << endl; - return 1; - } - // TEST 2 : FAMILY - nbOfPtsForTest=0; - vector families=myMesh->getFamilies(MED_FACE); - if(families.size()==3) - nbOfPtsForTest++; - vector::iterator iter=families.begin(); - FAMILY *fam1=*(iter++); - FAMILY *fam2=*(iter++); - FAMILY *fam3=*(iter); - const int *nbs; - // family 1 - if(fam1->getNumberOfTypes()==1 && fam1->getTypes()[0]==MED_POLYGON && fam1->getNumberOfElements(MED_ALL_ELEMENTS)==3) - nbOfPtsForTest++; - nbs=fam1->getNumber(MED_ALL_ELEMENTS); - const int REFTabForPolyg[16]= - { - 1, 2, 3, 4, 5, 6, 10, 9, 8, 12, 11, 13, 14, 15, 3, 2 - }; - const int REFTabForPolygLgth[3]= - { - 6,5,5 - }; - SupportTester test1(REFTabForPolyg,3,REFTabForPolygLgth); - for(i=0;i<3;i++) - { - int lgth; - const int *conn=((CONNECTIVITY *)myMesh->getConnectivityptr())->getConnectivityOfAnElement(MED_NODAL,MED_FACE,nbs[i],lgth); - if(test1.isIncludedAndNotAlreadyConsumed(conn)) - nbOfPtsForTest++; - } - if(test1.areAllEltsConsumed()) - nbOfPtsForTest++; - // family 2 - if(fam2->getNumberOfElements(MED_ALL_ELEMENTS)==8) - nbOfPtsForTest++; - nbs=fam2->getNumber(MED_ALL_ELEMENTS); - const int REFTabForQuad[32]= - { - 1, 7, 8, 2, 2, 8, 9, 3, 4, 3, 9, 10, 5, 4, 10, 11, 6, 5, 11, 12, 1, 6, 12, 7, 14, 13, 16, 17, 8, 9, 17, 16 - }; - SupportTester test2(REFTabForQuad,8,4); - for(i=0;i<8;i++) - { - int lgth; - const int *conn=((CONNECTIVITY *)myMesh->getConnectivityptr())->getConnectivityOfAnElement(MED_NODAL,MED_FACE,nbs[i],lgth); - if(test2.isIncludedAndNotAlreadyConsumed(conn)) - nbOfPtsForTest++; - } - if(test2.areAllEltsConsumed()) - nbOfPtsForTest++; - // family 3 - if(fam3->getNumberOfElements(MED_ALL_ELEMENTS)==6) - nbOfPtsForTest++; - nbs=fam3->getNumber(MED_ALL_ELEMENTS); - const int REFTabForTria[18]= - { - 7, 12, 8, 15, 14, 17, 15, 17, 18, 15, 18, 9, 3, 15, 9, 18, 17, 9 - }; - SupportTester test3(REFTabForTria,6,3); - for(i=0;i<6;i++) - { - int lgth; - const int *conn=((CONNECTIVITY *)myMesh->getConnectivityptr())->getConnectivityOfAnElement(MED_NODAL,MED_FACE,nbs[i],lgth); - if(test3.isIncludedAndNotAlreadyConsumed(conn)) - nbOfPtsForTest++; - } - if(test3.areAllEltsConsumed()) - nbOfPtsForTest++; - if(nbOfPtsForTest!=21) - { - cout << "TEST2 K0 ! : Invalid data in memory for families !!!" << endl; - return 1; - } - // TEST 3 : volumes, areas, barycenter - nbOfPtsForTest=0; - const SUPPORT *supOnCell=myMesh->getSupportOnAll(MED_CELL); - FIELD* vol1=myMesh->getVolume(supOnCell, false); - int lgth=vol1->getValueLength(); - const double *vals=vol1->getValue(); - if(lgth==3) - nbOfPtsForTest++; - const double REFVolOfPolyHedron[3]= - { - 2.333333333333333,-11.66666666666666,-13.83224131414673 - }; - for(i=0;i<3;i++) - if(fabs(REFVolOfPolyHedron[i]-vals[i])<1e-12) - nbOfPtsForTest++; - vol1->removeReference(); - vol1=myMesh->getVolume(supOnCell, true); - lgth=vol1->getValueLength(); - vals=vol1->getValue(); - if(lgth==3) - nbOfPtsForTest++; - for(i=0;i<3;i++) - if(fabs(fabs(REFVolOfPolyHedron[i])-vals[i])<1e-12) - nbOfPtsForTest++; - vol1->removeReference(); - FIELD* bary=myMesh->getBarycenter(supOnCell); - lgth=bary->getValueLength(); - vals=bary->getValue(); - if(lgth==9) - nbOfPtsForTest++; - const double REFBaryOfPolyHedron[9]= - { - 5.5, 1, -1, 2, 1.5, 1.0833333333333333, 5.1, 1.6, 0.9 - }; - for(i=0;i<9;i++) - if(fabs(REFBaryOfPolyHedron[i]-vals[i])<1e-12) - nbOfPtsForTest++; - bary->removeReference(); - //area - vol1=myMesh->getArea(fam1); - lgth=vol1->getValueLength(); - vals=vol1->getValue(); - if(lgth==3) - nbOfPtsForTest++; - const double REFAreaForPolyg[3]= - { - 6,5,6.5 - }; - for(i=0;i<3;i++) - if(fabs(REFAreaForPolyg[i]-vals[i])<1e-12) - nbOfPtsForTest++; - vol1->removeReference(); - - vol1=myMesh->getArea(fam2); - lgth=vol1->getValueLength(); - vals=vol1->getValue(); - if(lgth==8) - nbOfPtsForTest++; - const double REFAreaForQuad[8]= - { - 2.1213203435596424, 2.8284271247461903, 4.4721359549995796, 4.4721359549995796, - 2.8284271247461903, 2.1213203435596428, 3.6798724963767362, 4 - }; - for(i=0;i<8;i++) - if(fabs(REFAreaForQuad[i]-vals[i])<1e-12) - nbOfPtsForTest++; - vol1->removeReference(); - - vol1=myMesh->getArea(fam3); - lgth=vol1->getValueLength(); - vals=vol1->getValue(); - if(lgth==6) - nbOfPtsForTest++; - const double REFAreaForTri[6]= - { - 2.9580398915498081, 1.4142135623730951, 2.2360679774997898, - 3.3541019662496847, 3.3541019662496847, 2.2360679774997898 - }; - for(i=0;i<6;i++) - if(fabs(REFAreaForTri[i]-vals[i])<1e-12) - nbOfPtsForTest++; - vol1->removeReference(); - if(nbOfPtsForTest!=38) - { - cout << "TEST3 K0 ! : Error in calculation of basic properties !!!" << endl; - return 1; - } - // TEST 4 -- CHECK FOR Reverse descending using getBoundaryElements. - nbOfPtsForTest=0; - SUPPORT *bound=myMesh->getBoundaryElements(MED_NODE); - if(bound->getNumberOfElements(MED_ALL_ELEMENTS)==19) - nbOfPtsForTest++; - if(bound->isOnAllElements()) - nbOfPtsForTest++; - if(nbOfPtsForTest!=2) - { - cout << "TEST4 K0 ! : Error in getBoundaryElements probably due to Reverse descending !!!" << endl; - return 1; - } - bound->removeReference(); - /////////// - cout << "ALL TESTS OK !!!" << endl; - myMesh->removeReference(); - return 0; -} diff --git a/src/MEDMEMBinTest/test_affect_medarray.cxx b/src/MEDMEMBinTest/test_affect_medarray.cxx deleted file mode 100644 index c9e01580f..000000000 --- a/src/MEDMEMBinTest/test_affect_medarray.cxx +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM - jroy - 16/12/2002 */ - -#include - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_medarray(MEDARRAY & myMedArray) -{ - int numberof ; - MESSAGE_MED("Show all 1 :"); - numberof = myMedArray.getLeadingValue() ; - for (int i=1; i<=myMedArray.getLengthValue() ; i++) { - const double * node = myMedArray.getRow(i) ; - cout << " - " ; - for (int j=0;j * myMedArray = new MEDARRAY(dimension,nb_noeuds,mode); - for (med_int i=1; i<=myMedArray->getLengthValue(); i++) { - for (med_int j=1; j<=myMedArray->getLeadingValue(); j++) - myMedArray->setIJ(i,j,(double) rand()); - }; - - affiche_medarray(* myMedArray); - MEDARRAY * myMedArray2 = new MEDARRAY(); - * myMedArray2 = * myMedArray; - // delete myMedArray; // si on recopie les tableaux - affiche_medarray(* myMedArray2); - delete myMedArray; // si on ne recopie pas les tableaux - delete myMedArray2; - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_connectivity.cxx b/src/MEDMEMBinTest/test_copie_connectivity.cxx deleted file mode 100644 index 93fe03a66..000000000 --- a/src/MEDMEMBinTest/test_copie_connectivity.cxx +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* Programme de test du constructeur de copies de la classe CONNECTIVITY de MEDMEM - jroy - 19/12/2002 */ - -#include - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_connectivity(const CONNECTIVITY * myConnectivity, MESH * myMesh) -{ - int MeshDimension = myMesh->getMeshDimension() ; - int NumberOfNodes = myMesh->getNumberOfNodes() ; - - int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL) ; - const medGeometryElement * Types = myMesh->getTypes(MED_CELL) ; - - cout << "Show Connectivity (Nodal) :" << endl ; - for (int i=0; igetNumberOfElements(MED_CELL,Types[i]); - const int * connectivity = myMesh->getConnectivity(MED_NODAL,MED_CELL,Types[i]); - int NomberOfNodesPerCell = Types[i]%100 ; - for (int j=0;jgetReverseConnectivity(MED_NODAL) ; - const int * ReverseNodalConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_NODAL) ; - for (int i=0; icalculateConnectivity(MED_DESCENDING,MED_CELL); - try { - NumberOfElements = myMesh->getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); - connectivity = myMesh->getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS); - connectivity_index = myMesh->getConnectivityIndex(MED_DESCENDING,MED_CELL); - } - catch (MEDEXCEPTION& m) { - cout << m.what() << endl ; - exit (-1) ; - } - for (int j=0;jgetReverseConnectivity(MED_DESCENDING) ; - const int * ReverseDescendingConnectivityIndex = myMesh->getReverseConnectivityIndex(MED_DESCENDING) ; - - int NumberOfConstituents = 0; - string constituent ; - medEntityMesh constituentEntity ; - - if (MeshDimension==3) { - constituent = "Face" ; - constituentEntity = MED_FACE ; - } - - if (MeshDimension==2) { - constituent = "Edge" ; - constituentEntity = MED_EDGE ; - } - - if (MeshDimension==1) { - MESSAGE_MED("ERROR : MeshDimension = 1 !"); - MESSAGE_MED("We could not see Reverse Descending Connectivity.") ; - } else { - NumberOfConstituents = myMesh->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS); - for (int i=0; igetConnectivity(MED_NODAL,constituentEntity,MED_ALL_ELEMENTS); - const int * face_connectivity_index = myMesh->getConnectivityIndex(MED_NODAL,constituentEntity); - for (int i=0; isetName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; - myMeshDriver.setMeshName(meshname); - myMeshDriver.open() ; - myMeshDriver.read() ; //A partir d'ici la connectivité est construite - myMeshDriver.close() ; - - const CONNECTIVITY * myConnectivity = myMesh->getConnectivityptr(); - affiche_connectivity(myConnectivity, myMesh); - - CONNECTIVITY * myConnectivity2 = new CONNECTIVITY(* myConnectivity); - affiche_connectivity(myConnectivity2, myMesh); - - CONNECTIVITY * myConnectivity3 = new CONNECTIVITY(* myConnectivity2); - delete myConnectivity2; - affiche_connectivity(myConnectivity3, myMesh); - delete myConnectivity3; - - myMesh->removeReference(); - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_coordinate.cxx b/src/MEDMEMBinTest/test_copie_coordinate.cxx deleted file mode 100644 index 0f4edee00..000000000 --- a/src/MEDMEMBinTest/test_copie_coordinate.cxx +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* Programme de test du constructeur de copies de la classe COORDINATE de MEDMEM - jroy - 17/12/2002 */ - -#include - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_tableau(const double * myArray, int nb_lignes, int nb_colonnes) -{ - cout << "Nombre de lignes : " << nb_lignes << endl; - cout << "Nombre de colonnes : " << nb_colonnes << endl; - cout << "Valeurs :" << endl; - - for (int i=0; igetLeadingValue(); - //int _numberofNodes = (int) myCoordinate.getCoordinatePtr()->getLengthValue(); - cout << "- Nom des coordonnées : " << endl; - for (int i=1; i<=_spaceDimension; i++) - cout << i << " " << myCoordinate.getCoordinateName(i) << endl; - // cout< * myMedArray = new MEDARRAY(spaceDimension,numberofNodes,mode); - for (med_int i=1; i<=myMedArray->getLengthValue(); i++) { - for (med_int j=1; j<=myMedArray->getLeadingValue(); j++) - myMedArray->setIJ(i,j,(double) rand()); - }; - - //construction noms des coordonnées - string * myCoordinatesNames = new string[spaceDimension]; - if (spaceDimension >= 1) myCoordinatesNames[0] = "x"; - if (spaceDimension >= 2) myCoordinatesNames[1] = "y"; - if (spaceDimension >= 3) myCoordinatesNames[2] = "z"; - - //construction unités des coordonnées - string * myCoordinatesUnits = new string[spaceDimension]; - if (spaceDimension >= 1) myCoordinatesUnits[0] = "m"; - if (spaceDimension >= 2) myCoordinatesUnits[1] = "m"; - if (spaceDimension >= 3) myCoordinatesUnits[2] = "m"; - - //construction des indices des noeuds - int * myNodeNumber = new int[numberofNodes]; - for (int i=0; isetCoordinates(myMedArray); - myCoordinate->setCoordinatesNames(myCoordinatesNames); - myCoordinate->setCoordinatesUnits(myCoordinatesUnits); - myCoordinate->setNodesNumbers(myNodeNumber); - - // myCoordinate->setCoordinatesNames((string *)NULL); - // myCoordinate->setNodesNumbers((int *) NULL); - - delete myMedArray ; - delete[] myCoordinatesNames ; - delete[] myCoordinatesUnits ; - delete[] myNodeNumber ; - - affiche_coordinate(* myCoordinate,numberofNodes,spaceDimension); - COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate); - delete myCoordinate ; - - affiche_coordinate(* myCoordinate2,numberofNodes,spaceDimension); - delete myCoordinate2 ; - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_family.cxx b/src/MEDMEMBinTest/test_copie_family.cxx deleted file mode 100644 index 88edb3b19..000000000 --- a/src/MEDMEMBinTest/test_copie_family.cxx +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_support(const SUPPORT * mySupport) -{ - cout << " - Name : "<getName().c_str()<getDescription().c_str()<getEntity()<isOnAllElements())) - { - int NumberOfTypes = mySupport->getNumberOfTypes() ; - cout<<" - NumberOfTypes : "<getTypes() ; - for (int j=0;jgetNumberOfElements(Types[j]) ; - const int * Number = mySupport->getNumber(Types[j]) ; - for (int k=0; kgetIdentifier()<getNumberOfAttributes() ; - cout << " - Attributes ("<getAttributeIdentifier(j)<<" : "<getAttributeValue(j)<<", "<getAttributeDescription(j).c_str()<getNumberOfGroups() ; - cout << " - Groups ("<getGroupName(j).c_str()<setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; - myMeshDriver.setMeshName(meshname); - myMeshDriver.open() ; - myMeshDriver.read() ; - myMeshDriver.close() ; - - if ( myMesh->getNumberOfFamilies(MED_NODE) < 1 ) - { - cerr << "No nodal families in the file" << endl; - return 1; - } - const FAMILY * myFamily = myMesh->getFamily(MED_NODE,1); - - cout << "Show Family :"<removeReference(); - cout << "Show Family3 :"<removeReference(); - - cout << "That's all"<removeReference(); - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_fieldT.cxx b/src/MEDMEMBinTest/test_copie_fieldT.cxx deleted file mode 100644 index a7768c557..000000000 --- a/src/MEDMEMBinTest/test_copie_fieldT.cxx +++ /dev/null @@ -1,160 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM - jroy - 12/12/2002 */ - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_FieldConvert.hxx" -#include "MEDMEM_define.hxx" - -#include - -#include -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - - -static void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport) -{ - cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; - for (int i=1; igetComponentName(i)<< endl; - cout << " - description : "<getComponentDescription(i) << endl; - cout << " - units : "<getMEDComponentUnit(i) << endl; - } - cout << "- iteration :" << endl ; - cout << " - numero : " << myField->getIterationNumber()<< endl ; - cout << " - ordre : " << myField->getOrderNumber()<< endl ; - cout << " - temps : " << myField->getTime()<< endl ; - - cout << "- Type : " << myField->getValueType()<< endl; - - cout << "- Adresse support : " << mySupport << endl; -} - -template -void affiche_fieldT(FIELD * myField, - const SUPPORT * mySupport) -{ - affiche_field_((FIELD_ *) myField, mySupport); - - cout << "- Valeurs :"<getNumberOfElements(MED_ALL_ELEMENTS); - int NumberOfComponents = myField->getNumberOfComponents() ; - - if ( myField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) { - for (int i=1; igetRow(i) ; - for (int j=0; jgetColumn(j) ; - for (int i=0; isetName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; - myMeshDriver.setMeshName(meshname); - int current = myMesh->addDriver(myMeshDriver); - myMesh->read(current); - - // read field : - if (argc != 4) exit(0) ; - // else we have a field ! - string fieldname = argv[3]; - - FIELD * myField ; - const SUPPORT * mySupport = myMesh->getSupportOnAll(MED_CELL); - try - { - myField = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - } - catch (...) - { - mySupport = myMesh->getSupportOnAll(MED_NODE); - try - { - myField = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - } - catch (...) - { - cout << "Field double " << fieldname << " not found !!!" << endl ; - exit (-1) ; - } - } - - affiche_fieldT(myField, mySupport); - FIELD * myField2 = new FIELD(* myField); // Contructeur par recopie, sauf SUPPORT - myField->removeReference(); // Ne détruit pas le Support - affiche_fieldT(myField2, myField2->getSupport()); - FIELD * myField3 = FieldConvert( *myField2 ); - myField2->removeReference(); - - affiche_fieldT(myField3, myField3->getSupport()); - FIELD * myField4 = FieldConvert( *myField3 ); - myField3->removeReference(); - affiche_fieldT(myField4, myField4->getSupport()); - myField4->removeReference(); - - FIELD * myField5 = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - affiche_fieldT(myField5, myField5->getSupport()); - myField5->removeReference(); - - myMesh->removeReference(); - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_field_.cxx b/src/MEDMEMBinTest/test_copie_field_.cxx deleted file mode 100644 index b81289d2f..000000000 --- a/src/MEDMEMBinTest/test_copie_field_.cxx +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* Programme de test du constructeur de copies de la classe FIELD_ de MEDMEM - jroy - 12/12/2002 */ - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -#include - -#include -#include - - -using namespace MEDMEM; -using namespace MED_EN; - - -static void affiche_field(FIELD_ * myField, const SUPPORT * mySupport) -{ - cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; - for (int i=1; igetComponentName(i)<< endl; - cout << " - description : "<getComponentDescription(i) << endl; - cout << " - units : "<getMEDComponentUnit(i) << endl; - } - cout << "- iteration :" << endl ; - cout << " - numero : " << myField->getIterationNumber()<< endl ; - cout << " - ordre : " << myField->getOrderNumber()<< endl ; - cout << " - temps : " << myField->getTime()<< endl ; - - cout << "- Type : " << myField->getValueType()<< endl; - /* - cout << "- Valeurs :"<getNumberOfElements(MED_ALL_ELEMENTS); - - for (int i=1; igetValueI(MED_FULL_INTERLACE,i) ; - for (int j=0; jgetSupportOnAll(MED_EN::MED_CELL); - FIELD * myField = new FIELD() ; - - myField->setName(fieldname); - myField->setSupport(mySupport); - MED_FIELD_RDONLY_DRIVER myFieldDriver(filename,myField) ; - myFieldDriver.setFieldName(fieldname); - myFieldDriver.open() ; - - try - { - myFieldDriver.read() ; - } - catch (...) - { - myField->setSupport(0); - mySupport = myMesh->getSupportOnAll(MED_EN::MED_NODE); - myField->setSupport(mySupport); - try - { - myFieldDriver.read() ; - } - catch (...) - { - cout << "Field " << fieldname << " not found !!!" << endl ; - exit (-1) ; - } - } - - myFieldDriver.close() ; - - FIELD_ * pt_field_ = myField; - affiche_field(pt_field_, mySupport); - FIELD_ * pt_field_2 = new FIELD_(* pt_field_); - myField->removeReference(); - affiche_field(pt_field_2, pt_field_2->getSupport()); - - pt_field_2->removeReference(); - myMesh->removeReference() ; - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_group.cxx b/src/MEDMEMBinTest/test_copie_group.cxx deleted file mode 100644 index 4e17097e5..000000000 --- a/src/MEDMEMBinTest/test_copie_group.cxx +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_support(const SUPPORT * mySupport) -{ - cout << " - Name : "<getName().c_str()<getDescription().c_str()<getEntity()<isOnAllElements())) { - int NumberOfTypes = mySupport->getNumberOfTypes() ; - cout<<" - NumberOfTypes : "<getTypes() ; - for (int j=0;jgetNumberOfElements(Types[j]) ; - const int * Number = mySupport->getNumber(Types[j]) ; - for (int k=0; kgetNumberOfFamilies() ; - cout << " - Families ("<getFamily(j)->getName().c_str()<setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; - myMeshDriver.setMeshName(meshname); - myMeshDriver.open() ; - myMeshDriver.read() ; - myMeshDriver.close() ; - - const GROUP * myGroup = myMesh->getGroup(MED_NODE,1); - cout << "Show Group :"<removeReference(); - affiche_groupe(myGroup3); - myGroup3->removeReference(); - - myMesh->removeReference() ; - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_medarray.cxx b/src/MEDMEMBinTest/test_copie_medarray.cxx deleted file mode 100644 index 83d6d4434..000000000 --- a/src/MEDMEMBinTest/test_copie_medarray.cxx +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -/* Programme de test du constructeur de copies de la classe MEDARRAY de MEDMEM - jroy - 16/12/2002 */ - -#include - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_medarray(MEDARRAY & myMedArray) -{ - int numberof ; - MESSAGE_MED("Show all 1 :"); - numberof = myMedArray.getLeadingValue() ; - for (int i=1; i<=myMedArray.getLengthValue() ; i++) { - const double * node = myMedArray.getRow(i) ; - cout << " - " ; - for (int j=0;j * myMedArray = new MEDARRAY(dimension,nb_noeuds,mode); - for (med_int i=1; i<=myMedArray->getLengthValue(); i++) { - for (med_int j=1; j<=myMedArray->getLeadingValue(); j++) - myMedArray->setIJ(i,j,(double) rand()); - }; - - affiche_medarray(* myMedArray); - MEDARRAY * myMedArray2 = new MEDARRAY(* myMedArray,false); - delete myMedArray; - affiche_medarray(* myMedArray2); - MEDARRAY * myMedArray3 = new MEDARRAY(10,20); - (* myMedArray3) = (* myMedArray2) ; - delete myMedArray2; - affiche_medarray(* myMedArray3); - delete myMedArray3; - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_mesh.cxx b/src/MEDMEMBinTest/test_copie_mesh.cxx deleted file mode 100644 index 620cd1bfe..000000000 --- a/src/MEDMEMBinTest/test_copie_mesh.cxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include - -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char ** argv) { - - if (argc <3) { // after 3, ignored ! - cerr << "Usage : " << argv[0] - << " filename meshname" << endl << endl; - exit(-1); - } - - string filename = argv[1] ; - string meshname = argv[2] ; - - MESH * myMesh= new MESH; - myMesh->setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; - myMeshDriver.setMeshName(meshname); - myMeshDriver.open() ; - myMeshDriver.read() ; - myMeshDriver.close() ; - - cout << * myMesh << endl; - MESH * myMesh2 = new MESH(* myMesh); - myMesh->removeReference(); - cout << * myMesh2 << endl; - myMesh2->removeReference(); - - return 0; -} diff --git a/src/MEDMEMBinTest/test_copie_support.cxx b/src/MEDMEMBinTest/test_copie_support.cxx deleted file mode 100644 index 78064d6fb..000000000 --- a/src/MEDMEMBinTest/test_copie_support.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -#include - -#include -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_support(const SUPPORT * mySupport) -{ - cout << " - Name : "<getName().c_str()<getDescription().c_str()<getEntity()<isOnAllElements())) - { - int NumberOfTypes = mySupport->getNumberOfTypes() ; - cout<<" - NumberOfTypes : "<getTypes() ; - for (int j=0;jgetNumberOfElements(Types[j]) ; - const int * Number = mySupport->getNumber(Types[j]) ; - for (int k=0; ksetName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh) ; - myMeshDriver.setMeshName(meshname); - myMeshDriver.open() ; - myMeshDriver.read() ; - myMeshDriver.close() ; - - //Construction d'un support total - const SUPPORT * mySupportTotal = myMesh->getSupportOnAll(MED_CELL); - - cout << "Show Support on all :"<removeReference(); - - //Construction d'un support partiel - SUPPORT* mySupport = new SUPPORT; - mySupport->setMesh(myMesh); - mySupport->setName("Support on CELLs"); - mySupport->setEntity(MED_CELL); - - int NumberOfGeometricType = 0; - int TotalNumberOfElements = 0; - int * NumberOfElements = new int[myMesh->getNumberOfTypes(MED_CELL)]; - int * NumberValue = new int[myMesh->getGlobalNumberingIndex(MED_CELL)[myMesh->getNumberOfTypes(MED_CELL)]-1]; - int cmp = 0; - medGeometryElement * GeometricTypePartial = new medGeometryElement[myMesh->getNumberOfTypes(MED_CELL)]; - const medGeometryElement * GeometricType = myMesh->getTypes(MED_CELL); - for (int i=0;igetNumberOfTypes(MED_CELL);i=i+2) - { - NumberOfGeometricType=NumberOfGeometricType+1; - TotalNumberOfElements=TotalNumberOfElements+myMesh->getNumberOfElements(MED_CELL,GeometricType[i]); - NumberOfElements[i/2]=myMesh->getNumberOfElements(MED_CELL,GeometricType[i]); - for (int j=0;jgetNumberOfElements(MED_CELL,GeometricType[i]);j++) - { - NumberValue[cmp]=myMesh->getGlobalNumberingIndex(MED_CELL)[i]+j; - cmp=cmp+1; - } - GeometricTypePartial[i/2]=GeometricType[i]; - } - - mySupport->setpartial("Support partiel",NumberOfGeometricType,TotalNumberOfElements,GeometricTypePartial,NumberOfElements,NumberValue); - - delete[] NumberOfElements ; - delete[] NumberValue ; - delete[] GeometricTypePartial ; - - cout << "Show Partial Support :"<removeReference(); - affiche_support(mySupport2); - mySupport2->removeReference(); - - myMesh->removeReference(); - - return 0; -} diff --git a/src/MEDMEMBinTest/test_gibi_driver.cxx b/src/MEDMEMBinTest/test_gibi_driver.cxx deleted file mode 100644 index 10bdcbcd6..000000000 --- a/src/MEDMEMBinTest/test_gibi_driver.cxx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_GibiMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_DriverFactory.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; -using namespace DRIVERFACTORY; - -int main (int argc, char ** argv) -{ - /* process the arguments */ - if (argc != 2) - { - cerr << "Usage : " << argv[0] - << " Gibifilename" << endl << endl - << "-> lit le fichier gibi filename ,crée 2 fichiers : MED et VTK" << endl; - exit(-1); - } - - string gibifilename = argv[1]; - - // Construction des noms de fichier - const string ext=".sauve"; - string::size_type pos=gibifilename.find(ext,0); - string basename (gibifilename, 0, pos); // nom sans extension - string medfile21=basename+"_V21.med"; // nom fichier med 2.1 à creer - string medfile22=basename+"_V22.med"; // nom fichier med 2.2 à creer - string vtkfile=basename+".vtk"; // nom fichier vtk à creer - string::size_type pos1=gibifilename.rfind('/'); - string meshName (gibifilename,pos1+1,pos-pos1-1); // get rid of directory & extension - cout << meshName << endl; - - // lecture du fichier gibi - // MESH * myMesh= new MESH(GIBI_DRIVER,gibifilename); - MESH * myMesh= new MESH; - GIBI_MESH_RDONLY_DRIVER myGibiMeshDriver(gibifilename, myMesh) ; - myGibiMeshDriver.open() ; - myGibiMeshDriver.read() ; - myGibiMeshDriver.close() ; - - cout << "Impression de MESH : " << endl; - cout << *myMesh; - - cout << "creation du fichier med 22 : " << endl; - int idMed22 = myMesh->addDriver(MED_DRIVER, medfile22, meshName); - myMesh->write(idMed22) ; - - // creation d'un fichier vtk - cout << "creation d'un fichier vtk : " << endl; - int idVtk = myMesh->addDriver(VTK_DRIVER, vtkfile, meshName); - myMesh->write(idVtk) ; - myMesh->removeReference(); - - // remontée mémoire du fichier med 22 - myMesh= new MESH(MED_DRIVER,medfile22,meshName); - - myMesh->removeReference(); -} diff --git a/src/MEDMEMBinTest/test_grid.cxx b/src/MEDMEMBinTest/test_grid.cxx deleted file mode 100644 index 52b680ef9..000000000 --- a/src/MEDMEMBinTest/test_grid.cxx +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_Grid.hxx" -#include - -using namespace MEDMEM; -using namespace MED_EN; - -static void usage(const char * test) -{ - cerr << "Usage : " << test - << " SpaceDimension nbMaille" << endl << endl - << "-> Crée une grille cartesienne en dimension SpaceDimension avec nbMaille suivant chaque direction" << endl; - exit(-1); -} - -int main (int argc, char ** argv) { - - /* process the arguments */ - if (argc != 3) - usage(argv[0]); - - const int SpaceDimension=atoi(argv[1]); - const int nbMaille=atoi(argv[2]); - if(SpaceDimension>3 || SpaceDimension<1 || nbMaille<1) - usage(argv[0]); - - // Creation des tableaux necessaires à la construction de GRID - std::vector nMaille(SpaceDimension,nbMaille); - std::vector Origine(SpaceDimension,0.0); - std::vector pas(SpaceDimension,10.0); - std::vector > XYZ_Array(SpaceDimension); - for(int i=0;i!=SpaceDimension;++i) - { - XYZ_Array[i].resize(nMaille[i]+1); // nbre de noeuds = nbre de mailles +1 - XYZ_Array[i][0]=Origine[i]; - for(int j=1;j!=(int)XYZ_Array[i].size();++j) - XYZ_Array[i][j]=XYZ_Array[i][j-1] + pas[i]; - } - - std::vector coord_name(SpaceDimension,"X"); - if(SpaceDimension>=2) - coord_name[1]="Y"; - if(SpaceDimension>=3) - coord_name[2]="Z"; - std::vector coord_unit(SpaceDimension,"cm"); - - // creation du pointeur MESH à partir d'un GRID, test affichage - MEDMEM::GMESH *grid=(new MEDMEM::GRID( XYZ_Array, coord_name, coord_unit, MED_CARTESIAN) ); - const MEDMEM::MESH* Mesh = grid->convertInMESH(); - Mesh->getConnectivityptr(); - std::cout << "Affichage du maillage : " << endl << *Mesh << endl; - Mesh->removeReference(); - grid->removeReference(); -} diff --git a/src/MEDMEMBinTest/test_operation_fielddouble.cxx b/src/MEDMEMBinTest/test_operation_fielddouble.cxx deleted file mode 100644 index e90ac50c6..000000000 --- a/src/MEDMEMBinTest/test_operation_fielddouble.cxx +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -#include -#include -#include -#include - -double myfunction1(double x) -{ - return 0.25*(x-1.0); -} - - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport) -{ - cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; - cout << "- Nombre de valeurs : "<< myField->getNumberOfValues() << endl ; - for (int i=1; igetComponentName(i)<< endl; - cout << " - description : "<getComponentDescription(i) << endl; - cout << " - units : "<getMEDComponentUnit(i) << endl; - } - cout << "- iteration :" << endl ; - cout << " - numero : " << myField->getIterationNumber()<< endl ; - cout << " - ordre : " << myField->getOrderNumber()<< endl ; - cout << " - temps : " << myField->getTime()<< endl ; - - cout << "- Type : " << myField->getValueType()<< endl; - - cout << "- Adresse support : " << mySupport << endl; -} - -static void affiche_fieldT(FIELD * myField, const SUPPORT * mySupport) -{ - affiche_field_((FIELD_ *) myField, mySupport); - - cout << "- Valeurs :"<getNumberOfElements(MED_ALL_ELEMENTS); - int NumberOfComponents = myField->getNumberOfComponents() ; - - for (int i=1; igetRow(i) ; - for (int j=0; jnorm2() << endl; - cout << "Norme max : " << myField->normMax() << endl; - try - { - for (int i=1; i<=myField->getNumberOfComponents(); ++i) - cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl; - cout << "Norme L2 : " << myField->normL2() << endl; - - for (int i=1; i<=myField->getNumberOfComponents(); ++i) - cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl; - cout << "Norme L1 : " << myField->normL1() << endl; - } - catch (MEDEXCEPTION &ex) - { - cout << ex.what() << endl; - } -} - -static void affiche_valeur_field(const FIELD& f) -{ - const int tailleMax=12; - const int taille=f.getNumberOfValues()*f.getNumberOfComponents(); - const double * value=f.getValue(); - if(taille<=tailleMax) - for(int i=0;i& resOp, const FIELD& f1, const FIELD& f2, - char Op, const char* intitule, int verbose) -{ - int res=0; - - // get pointers to inside arrays of values - const double * value=resOp.getValue(); - const double * value1=f1.getValue(); - const double * value2=f2.getValue(); - const int size=f1.getNumberOfValues()*f1.getNumberOfComponents(); // size of field1 - - // check size compatibility - if(f1.getNumberOfValues()*f1.getNumberOfComponents()!=size || - resOp.getNumberOfValues()*resOp.getNumberOfComponents()!=size) - res=1; - - if(!res) - { - switch(Op) - { - case '+': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]+value2[i]) - res+=1; - break; - case '-': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]-value2[i]) - res+=1; - break; - case 'n': - for(int i=0; i!=size; ++i) - if(value[i]!=-value1[i]) - res+=1; - break; - case '*': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]*value2[i]) - res+=1; - break; - case '/': - for(int i=0; i!=size; ++i) - if(value2[i]!=0.0) - if(value[i]!=value1[i]/value2[i]) - res+=1; - break; - case '=': - for(int i=0; i!=size; ++i) - if(value[i]!=value2[i]) - res+=1; - break; - case 'a': - for(int i=0; i!=size; ++i) - if(value[i]!=value1[i]+value2[i]*value2[i]) - res+=1; - break; - } - } - - if (verbose) - cout << endl << intitule << "["; - cout << res; - if (verbose) - { - cout << "] : "; - affiche_valeur_field(resOp); - } - else - cout << endl; -} - -int main (int argc, char ** argv) -{ - /* process the arguments */ - int verbose=0; // verbose=1 if the verbose mode is selected - int res=0; // unit test result - int ntest=0; // numéro du test - - if (argc>=2 && !strcmp(argv[1],"-v")) - verbose=1; - - if (argc != 4+verbose) - { - cerr << "Usage : " << argv[0] - << "[-v] filename meshname fieldname" << endl << endl - << "-> tests field's operations on the FIELD fieldname" << endl - << "Use optional option -v to select verbose mode" << endl; - exit(-1); - } - string filename = argv[verbose+1]; - string meshname = argv[verbose+2];// Maintenant plus très utile - string fieldname = argv[verbose+3]; - - /* read MESH, SUPPORT and FIELDS */ - //MESH * myMesh = new MESH(MED_DRIVER,filename,meshname); - - MESH * myMesh; - const SUPPORT * mySupport; - FIELD * myField1; - - try - { - myField1 = new FIELD(MED_DRIVER,filename,fieldname) ; - mySupport = myField1->getSupport(); - myMesh = new MESH(MED_DRIVER,filename,mySupport->getMeshName()); - mySupport->setMesh(myMesh); - - FIELD * myField2 = new FIELD(* myField1); - FIELD *myFieldPlus = *myField1 + *myField2; - if(verbose) - { - // affichage des nprmes,des champs f1, f2, scalarProduct(f1,f2) et f1+f2 - FIELD* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport()); - cout << "Norme L2 calculee en fournissant le volume : " << myField1->normL2(myField1_vol) << endl; - for (int i=1; i<=myField1->getNumberOfComponents(); ++i) - cout << "Norme L2 - comp=" << i << " : " << myField1->normL2(i,myField1_vol) << endl; - cout << "Norme L1 calculee en fournissant le volume : " << myField1->normL1(myField1_vol) << endl; - for (int i=1; i<=myField1->getNumberOfComponents(); ++i) - cout << "Norme L1 - comp=" << i << " : " << myField1->normL1(i,myField1_vol) << endl; - myField1_vol->removeReference(); - - affiche_fieldT(myField1, myField1->getSupport()); - cout << endl << string(60,'-') << endl; - affiche_fieldT(myField2, myField2->getSupport()); - cout << endl << string(60,'-') << endl; - - FIELD* myFieldDot = FIELD::scalarProduct(*myField1, *myField2); - affiche_fieldT(myFieldDot, myFieldDot->getSupport()); - myFieldDot->removeReference(); - cout << endl << string(60,'-') << endl ; - affiche_fieldT(myFieldPlus, myFieldPlus->getSupport()); - cout << endl << string(60,'-') << endl << endl ; - } - - - // Verifie plusieurs cas de non compatibilité - - // test 1 : Unites non compatibles - const string unite=myField1->getMEDComponentUnit(1); - myField1->setMEDComponentUnit(1,string("UniteBidon")); - ntest++; res=1; - try - { - FIELD *myFieldPlus = *myField1 + *myField2; - if(verbose) - { - cout << endl << string(60,'-') << endl; - cout<< "Test " << ntest << " : incompatibilité d'unité : " << endl << endl; - } - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - res=0; - if(verbose) - cout << ex.what() << endl; - myField1->setMEDComponentUnit(1,unite); - } - cout << res << endl; - - // test 2 : numberOfComponents non compatibles - const int numberOfComponents =myField1->getNumberOfComponents(); - myField1->setNumberOfComponents(13); - ntest++; res=1; - try - { - if(verbose) - { - cout << endl << string(60,'-') << endl; - cout<< "Test " << ntest << " : incompatibilité nombre de composantes : " << endl << endl; - } - FIELD *myFieldPlus = *myField1 + *myField2; - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - res=0; - if(verbose) - cout << endl << ex.what() << endl << endl; - myField1->setNumberOfComponents(numberOfComponents); - } - cout << res << endl; - - // test 3 : supports non compatibles - const SUPPORT *mySupport2=myMesh->getSupportOnAll(MED_NODE); - myField1->setSupport(mySupport2); - ntest++; res=1; - try - { - if(verbose) - cout << endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité des supports" << endl << endl; - FIELD *myFieldPlus = *myField1 + *myField2; - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - res=0; - if(verbose) - cout << ex.what() << endl << endl << endl; - myField1->setSupport(mySupport); - } - cout << res << endl; - - // test 4 : champs de taille nulle - myField1->setNumberOfComponents(0); - myField2->setNumberOfComponents(0); - ntest++; res=2; - try - { - if(verbose) - cout<< endl << string(60,'-') << endl << "Test " << ntest << " : incompatibilité taille nulle" << endl << endl; - FIELD *myFieldPlus = *myField1 + *myField2; - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - --res; - if(verbose) - cout << ex.what() << endl << endl ; - } - try - { - myField1->norm2(); - } - catch (MEDEXCEPTION & ex) - { - --res; - if(verbose) - cout << ex.what() << endl << endl ; - myField1->setNumberOfComponents(numberOfComponents); - myField2->setNumberOfComponents(numberOfComponents); - } - cout << res << endl; - - // Apres toutes ces exceptions, des opérations qui marchent! - - if(verbose) - { - cout<< endl << string(60,'-') << endl << "Test " << ++ntest << " : Operations arithmétiques" << endl; - cout << endl << " f1 : "; affiche_valeur_field(*myField1); - cout << endl << " f2 : "; affiche_valeur_field(*myField2); - cout << endl << string(140,'-'); - } - - // Test du résultats de certaines opérations et affichage si verbose - checkOperation(*myFieldPlus, *myField1, *myField2, '+', " f1+f2 ", verbose); - FIELD* myFieldadd = FIELD::add(*myField1, *myField2); - checkOperation( *myFieldadd, *myField1, *myField2, '+', "add(f1,f2)", verbose); - myFieldadd->removeReference(); - - FIELD *myFieldMoins = *myField1 - *myField2; - checkOperation(*myFieldMoins, *myField1, *myField2, '-', " f1-f2 ", verbose); - myFieldMoins->removeReference(); - FIELD* myFieldsub = FIELD::sub(*myField1, *myField2); - checkOperation( *myFieldsub, *myField1, *myField2, '-', "sub(f1,f2)", verbose); - myFieldsub->removeReference(); - FIELD *myFieldNeg = -(*myField1); - checkOperation(*myFieldNeg, *myField1, *myField1, 'n', " -f1 ", verbose); - myFieldNeg->removeReference(); - FIELD *myFieldFois = *myField1 * *myField2; - checkOperation(*myFieldFois, *myField1, *myField2, '*', " f1*f2 ", verbose); - myFieldFois->removeReference(); - FIELD* myFieldmul = FIELD::mul(*myField1, *myField2); - checkOperation( *myFieldmul, *myField1, *myField2, '*', "mul(f1,f2)", verbose); - - FIELD *myFieldDiv = *myField1 / *myField2; - checkOperation(*myFieldDiv, *myField1, *myField2, '/', " f1/f2 ", verbose); - myFieldDiv->removeReference(); - FIELD* myFielddiv = FIELD::div(*myField1, *myField2); - checkOperation( *myFielddiv, *myField1, *myField2, '/', "div(f1,f2)", verbose); - myFielddiv->removeReference(); - - FIELD *myFieldAsso = (*myField1)+*((*myField2)*(*myField2)); - checkOperation(*myFieldAsso, *myField1, *myField2, 'a', " f1+f2*f2 ", verbose); - myFieldAsso->removeReference(); - myField1->applyLin(4.0,1.0); - checkOperation(*myField1, *myField2, *myField2, 'l', " 4.f1 + 1 ", verbose); - myField1->applyFunc(); - checkOperation( *myField1, *myField2, *myField1, '=', "CB : ->f1)", verbose); - - *myField1 += *myField2; - checkOperation(*myField1, *myField2, *myField2, '+', " f1+=f2 ", verbose); - - *myField1 -= *myField2; - checkOperation(*myField1, *myField2, *myField2, '=', " f1-=f2 ", verbose); - - *myField1 *= *myField2; - checkOperation(*myField1, *myField2, *myField2, '*', " f1*=f2 ", verbose); - *myField1 /= *myField2; - checkOperation(*myField1, *myFieldmul, *myField2, '/', " f1/=f2 ", verbose); - myFieldmul->removeReference(); - - - myFieldPlus->removeReference(); - myField1->removeReference(); - myField2->removeReference(); - //mySupport->removeReference(); ??? - myMesh->removeReference(); - } - catch ( MEDEXCEPTION & ex) - { - cout << ex.what() << endl; - } - - return 0; -} diff --git a/src/MEDMEMBinTest/test_operation_fieldint.cxx b/src/MEDMEMBinTest/test_operation_fieldint.cxx deleted file mode 100644 index 5e63fbc5a..000000000 --- a/src/MEDMEMBinTest/test_operation_fieldint.cxx +++ /dev/null @@ -1,333 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" - -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_define.hxx" - -#include -#include -#include -#include - -using namespace MEDMEM; -using namespace MED_EN; - -int myfunction1(int x); -int myfunction1(int x) -{ - return 2*x; -} - -int myfunction2(int x); -int myfunction2(int x) -{ - return x/2; -} - -using namespace std; -static void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport) -{ - cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; - cout << "- Nombre de valeurs : "<< myField->getNumberOfValues() << endl ; - for (int i=1; igetComponentName(i)<< endl; - cout << " - description : "<getComponentDescription(i) << endl; - cout << " - units : "<getMEDComponentUnit(i) << endl; - } - cout << "- iteration :" << endl ; - cout << " - numero : " << myField->getIterationNumber()<< endl ; - cout << " - ordre : " << myField->getOrderNumber()<< endl ; - cout << " - temps : " << myField->getTime()<< endl ; - - cout << "- Type : " << myField->getValueType()<< endl; - - cout << "- Adresse support : " << mySupport << endl; -} - -static void affiche_fieldT(FIELD * myField, const SUPPORT * mySupport) -{ - affiche_field_((FIELD_ *) myField, mySupport); - - cout << "- Valeurs :"<getNumberOfElements(MED_ALL_ELEMENTS); - int NumberOfComponents = myField->getNumberOfComponents() ; - - for (int i=1; igetRow(i) ; - for (int j=0; jnorm2() << endl; - std::cout << "Norme max : " << myField->normMax() << endl; - try - { - for (int i=1; i<=myField->getNumberOfComponents(); ++i) - std::cout << "Norme L2 - comp=" << i << " : " << myField->normL2(i) << endl; - std::cout << "Norme L2 : " << myField->normL2() << endl; - - for (int i=1; i<=myField->getNumberOfComponents(); ++i) - std::cout << "Norme L1 - comp=" << i << " : " << myField->normL1(i) << endl; - std::cout << "Norme L1 : " << myField->normL1() << endl; - } - catch (MEDEXCEPTION &ex) - { - std::cout << ex.what() << std::endl; - } -} - -static void affiche_valeur_field(const char * intitule, const int taille, const FIELD& f) -{ - const int * value=f.getValue(); - std::cout << endl << intitule; - for(int i=0;i * myField1; - try - { - /* read MESH, SUPPORT and FIELD */ - mySupport = myMesh->getSupportOnAll(MED_CELL); - myField1 = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - } - catch (MEDEXCEPTION &ex) - { - mySupport = myMesh->getSupportOnAll(MED_NODE); - try - { - myField1 = new FIELD(mySupport,MED_DRIVER,filename,fieldname) ; - myField1->setValueIJ(10,1,-9); // pour tester les normes max avec une valeur negative - } - catch (...) - { - cout << "Field int " << fieldname << " not found !!!" << endl ; - exit (-1) ; - } - } - - FIELD * myField2 = new FIELD(* myField1); - //myField1->setNumberOfValues(16); // PROVISOIRE !! BUG - //myField2->setNumberOfValues(16); // PROVISOIRE !! BUG -// FIELD* myField1_vol=myField1->getSupport()->getMesh()->getVolume(myField1->getSupport()); -// affiche_fieldT(myField1_vol, myField1->getSupport()); - - affiche_fieldT(myField1, myField1->getSupport()); - std::cout << endl << string(60,'-') << endl; - affiche_fieldT(myField2, myField2->getSupport()); - - // Verifie plusieurs cas de non compatibilité - - // Unites non compatibles - const string unite=myField1->getMEDComponentUnit(1); - myField1->setMEDComponentUnit(1,string("UniteBidon")); - try - { - std::cout << endl << string(60,'-') << endl; - std::cout<< "Test incompatibilité d'unité :" << endl; - FIELD *myFieldPlus = *myField1 + *myField2; - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - std::cout << "MEDEXCEPTION : " << ex.what() << endl; - myField1->setMEDComponentUnit(1,unite); - } - - // numberOfComponents non compatibles - const int numberOfComponents =myField1->getNumberOfComponents(); - myField1->setNumberOfComponents(4); - try - { - std::cout << endl << string(60,'-') << endl; - std::cout<< "Test incompatibilité nombre de composantes :" << endl; - FIELD *myFieldPlus = *myField1 + *myField2; - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - std::cout << ex.what() << endl; - myField1->setNumberOfComponents(numberOfComponents); - } - - // supports non compatibles - const SUPPORT *mySupport2=myMesh->getSupportOnAll(MED_NODE); - myField1->setSupport(mySupport2); - try - { - std::cout << endl << string(60,'-') << endl; - std::cout<< "Test incompatibilité des supports :" << endl; - FIELD *myFieldPlus = *myField1 + *myField2; - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - std::cout << ex.what() << endl; - myField1->setSupport( myField2->getSupport() ); - } - - // champs de taille nulle - myField1->setNumberOfComponents(0); - myField2->setNumberOfComponents(0); - try - { - std::cout << endl << string(60,'-') << endl; - std::cout<< "Test incompatibilité taille nulle :" << endl; - FIELD *myFieldPlus = *myField1 + *myField2; - myFieldPlus->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - std::cout << ex.what() << endl; - } - try - { - myField1->norm2(); - } - catch (MEDEXCEPTION & ex) - { - std::cout << ex.what() << endl; - myField1->setNumberOfComponents(numberOfComponents); - myField2->setNumberOfComponents(numberOfComponents); - } - - // Apres toutes ces exceptions, des opérations qui marchent! - - FIELD *myFieldPlus = *myField1 + *myField2; - FIELD *myFieldMoins = *myField1 - *myField2; - FIELD *myFieldNeg = -(*myField1); - FIELD *myFieldFois = *myField1 * *myField2; - FIELD *myFieldDiv = *myField1 / *myField2; - FIELD *myFieldAsso = (*myField1)+*((*myField2)*(*myField2)); - FIELD* myFieldadd = FIELD::add(*myField1, *myField2); - FIELD* myFieldsub = FIELD::sub(*myField1, *myField2); - FIELD* myFieldmul = FIELD::mul(*myField1, *myField2); - FIELD* myFielddiv = FIELD::div(*myField1, *myField2); - FIELD* myFieldDot = FIELD::scalarProduct(*myField1, *myField2); - - std::cout << endl << string(60,'-') << endl << "f1+f2 :" << endl << endl; - affiche_fieldT(myFieldPlus, myFieldPlus->getSupport()); - std::cout << endl << string(60,'-') << endl << "add(f1,f2) :" << endl << endl; - affiche_fieldT(myFieldadd, myFieldadd->getSupport()); - std::cout << endl << string(60,'-') << endl << "scalarProduct(f1,f2) :" << endl << endl; - affiche_fieldT(myFieldDot, myFieldDot->getSupport()); - std::cout << endl << string(60,'-') << endl << " - f1 :" << endl << endl; - affiche_fieldT(myFieldNeg, myFieldNeg->getSupport()); - int size=myFieldPlus->getNumberOfValues()*myFieldPlus->getNumberOfComponents(); - - std::cout << endl << string(60,'-') << endl << "Tests opérations :" << endl << endl; - affiche_valeur_field(" f1 :", size, *myField1); - affiche_valeur_field(" f2 :", size, *myField2); - std::cout << endl << " " << string(4*size,'-'); - - affiche_valeur_field(" + :", size, *myFieldPlus); - affiche_valeur_field(" add :", size, *myFieldadd); - affiche_valeur_field(" - :", size, *myFieldMoins); - affiche_valeur_field(" sub :", size, *myFieldsub); - affiche_valeur_field(" * :", size, *myFieldFois); - affiche_valeur_field(" mul :", size, *myFieldmul); - affiche_valeur_field(" / :", size, *myFieldDiv); - affiche_valeur_field(" div :", size, *myFielddiv); - affiche_valeur_field("f1+f2*f1:", size, *myFieldAsso); - affiche_valeur_field(" - f1 :", size, *myFieldNeg); - - myFieldPlus->removeReference(); - myFieldMoins->removeReference(); - myFieldFois->removeReference(); - myFieldDiv->removeReference(); - myFieldAsso->removeReference(); - myFieldNeg->removeReference(); - - // Test applyLin - std::cout << endl; - myField1->applyLin(1,1); - affiche_valeur_field(" f1+1 :", size, *myField1); - myField1->applyLin(1,-1); - affiche_valeur_field(" -> f1 :", size, *myField1); - - // Test applyFunc - std::cout << endl; - myField1->applyFunc(); - affiche_valeur_field(" CB 2f1 :", size, *myField1); - myField1->applyFunc(); - affiche_valeur_field(" -> f1 :", size, *myField1); - - // Test operateur += - std::cout << endl; - *myField1 += *myField2; - affiche_valeur_field(" f1+=f2 :", size, *myField1); - - // Test operateur *= - *myField1 *= *myField2; - affiche_valeur_field(" f1*=f2 :", size, *myField1); - - // Test operateur /= - *myField1 /= *myField2; - affiche_valeur_field(" f1/=f2 :", size, *myField1); - - // Test operateur -= - *myField1 -= *myField2; - affiche_valeur_field(" f1-=f2 :", size, *myField1); - - std::cout << endl << endl; - - - myFieldadd->removeReference(); - myFieldsub->removeReference(); - myFieldmul->removeReference(); - myFielddiv->removeReference(); - myFieldDot->removeReference(); -// myField1_vol->removeReference(); - - myField1->removeReference(); - myField2->removeReference(); - mySupport->removeReference(); - myMesh->removeReference(); - return 0; -} diff --git a/src/MEDMEMBinTest/test_porflow_driver.cxx b/src/MEDMEMBinTest/test_porflow_driver.cxx deleted file mode 100644 index da8060ef7..000000000 --- a/src/MEDMEMBinTest/test_porflow_driver.cxx +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_PorflowMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -int main (int argc, char ** argv) -{ - /* process the arguments */ - if (argc != 2) - { - cerr << "Usage : " << argv[0] - << " Porflowfilename" << endl << endl - << "-> lit le fichier Porflowfilename ,crée 2 fichiers : MED et VTK" << endl; - exit(-1); - } - - string porflowfilename = argv[1]; - - // Construction des noms de fichier - const string ext=".inp"; - string::size_type pos=porflowfilename.find(ext,0); - string basename (porflowfilename, 0, pos); // nom sans extension - string medfile=basename+".med"; // nom fichier med à creer - string vtkfile=basename+".vtk"; // nom fichier vtk à creer - string::size_type pos1=porflowfilename.rfind('/'); - string meshName (porflowfilename,pos1+1,pos-pos1-1); //get rid of directory & extension - cout << meshName << endl; - - // lecture du fichier porflow - MESH * myMesh= new MESH; - PORFLOW_MESH_RDONLY_DRIVER myPorflowMeshDriver(porflowfilename, myMesh) ; - myPorflowMeshDriver.open() ; - myPorflowMeshDriver.read() ; - myPorflowMeshDriver.close() ; - - cout << "Impression de MESH : " << endl; - cout << *myMesh; - - // creation d'un fichier med - cout << "creation d'un fichier med : " << endl; - int idMed = myMesh->addDriver(MED_DRIVER, medfile, meshName); - myMesh->write(idMed) ; - - // creation d'un fichier vtk - cout << "creation d'un fichier vtk : " << endl; - int idVtk = myMesh->addDriver(VTK_DRIVER, vtkfile, meshName); - myMesh->write(idVtk) ; - - - int SpaceDimension = myMesh->getSpaceDimension() ; - int MeshDimension = myMesh->getMeshDimension() ; - int NumberOfNodes = myMesh->getNumberOfNodes() ; - - cout << "Space Dimension : " << SpaceDimension << endl << endl ; - - cout << "Mesh Dimension : " << MeshDimension << endl << endl ; - - const double * Coordinates = myMesh->getCoordinates(MED_FULL_INTERLACE) ; - - cout << "Show Nodes Coordinates : " << endl ; - - cout << "Name :" << endl ; - const string * CoordinatesNames = myMesh->getCoordinatesNames() ; - for(int i=0; igetCoordinatesUnits() ; - for(int i=0; iremoveReference(); - - // remontée du fichier med en mémoire - myMesh= new MESH(MED_DRIVER,medfile,meshName); - myMesh->removeReference(); - -} diff --git a/src/MEDMEMBinTest/test_profil_MedFieldDriver.cxx b/src/MEDMEMBinTest/test_profil_MedFieldDriver.cxx deleted file mode 100644 index 5132ef70f..000000000 --- a/src/MEDMEMBinTest/test_profil_MedFieldDriver.cxx +++ /dev/null @@ -1,254 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_define.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void affiche_field_(FIELD_ * myField, const SUPPORT * mySupport) -{ - cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; - for (int i=1; igetComponentName(i)<< endl; - cout << " - description : "<getComponentDescription(i) << endl; - cout << " - units : "<getMEDComponentUnit(i) << endl; - } - cout << "- iteration :" << endl ; - cout << " - numero : " << myField->getIterationNumber()<< endl ; - cout << " - ordre : " << myField->getOrderNumber()<< endl ; - cout << " - temps : " << myField->getTime()<< endl ; - - cout << "- Type : " << myField->getValueType()<< endl; - - cout << "- Adresse support : " << mySupport << endl; -} - -template -void affiche_fieldT(FIELD * myField, - const SUPPORT * mySupport) -{ - const double * value = 0; - const int * number = 0; - - affiche_field_((FIELD_ *) myField, mySupport); - - cout.setf(ios::fixed); - cout << "- Valeurs :"<isOnAllElements(); - int NumberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS); - cout << "mySupport->getNumberOfElements(MED_ALL_ELEMENTS)" << NumberOf << endl; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "myField->getNumberOfComponents()" << NumberOfComponents << endl; - if (!onAll) number = mySupport->getNumber(MED_ALL_ELEMENTS); - - if ( myField->getInterlacingType() == MED_EN::MED_FULL_INTERLACE ) { - for (int i=1; igetRow(i) ; - else - value = myField->getRow(number[i-1]); - for (int j=0; jgetColumn(j) ; - for (int i=0; i * myField1 = new FIELD(MED_DRIVER,fileName,fieldName, - iterationNumber, orderNumber); - affiche_fieldT(myField1, myField1->getSupport()); - - // Pour éviter de modifier le fichier d'origine, - // on en crée une copie avec uniquement le maillage. - // Rem : Pour le test, le chargement du maillage n'est pas nécessaire - // On pourrait réécrire le Champ dans le fichier d'origine - // sous un autre nom. - // Attention si le driver MED_MESH modifie le nombre d'éléments d'un type géométrique : - // le calcul de renumérotation à l'écriture du champ risque d'être faux ! - meshName = myField1->getSupport()->getMeshName(); - MESH * myMesh = new MESH(MED_DRIVER,fileName,meshName); - MED_MESH_WRONLY_DRIVER myMeshDriver1("Copy_withmesh_"+fileName,myMesh); - int current=myMesh->addDriver(myMeshDriver1); - myMesh->write(current); - myMesh->removeReference(); - - // On ajoute un driver en écriture, comme la relation SUPPORT-MESH n'est pas - // initialisée, le driver doit trouver le maillage dans le fichier cible - // pour réaliser la transcription des profils MEDMEMOIRE à MEDFICHIER. - MED_FIELD_WRONLY_DRIVER myFieldDriver2("Copy_withmesh_"+fileName,myField1) ; - current = myField1->addDriver(myFieldDriver2); - myField1->write(current); - myField1->removeReference(); - } - -// mode2: -// ///////////////////////////////////////////////////////////////////////////// -// // TEST DEUXIEME MODE : -// // Lecture idem 1er mode -// // A l'écriture, le fichier cible ne contient pas le maillage mais la -// // relation SUPPORT-MESH étant établie le driver utilise les informations -// // dans le maillage en mémoire pour transcrire les profils. -// // Selon le modèle MED FICHIER, ce mode est interdit : le fichier doit au moins -// // contenir un lien sur le maillage (information pas encore exploitée dans MEDMEMOIRE -// // : pas de gestion de montage/démontage des fichiers ) -// // Attention si le driver MED_MESH modifie le nombre d'éléments d'un type géométrique : -// // le calcul de renumérotation à l'écriture du champ risque d'être faux car les -// // profils crées à la lecture son basés sur le nombre d'éléments par type géoémtrique -// // du maillage contenu dans le fichier à la lecture. -// // Une solution consisterait à prendre en compte le montage de fichiers distants -// // et de prendre en compte la différence de nombre d'éléments par type géométrique -// // entre le maillage MEDMEM et le maillage MEDFICHIER -// // (Hum ! : Il serait plus simple que MEDMEMOIRE ne recalcule pas systématiquement -// // ce que l'on ne lui demande pas, ce qui permettrait aussi de réécrire à l'identique -// // un fichier que l'on vient de lire) -// { -// FIELD * myField2 = new FIELD(MED_DRIVER,fileName,fieldName, -// iterationNumber, orderNumber); - -// meshName = myField2->getSupport()->getMeshName(); -// MESH * myMesh2 = new MESH(MED_DRIVER,fileName,meshName); - -// const SUPPORT * mySupport2=myField2->getSupport(); -// mySupport2->setMesh(myMesh2); - -// // On ajoute un driver en écriture, comme la relation SUPPORT-MESH est -// // initialisée, le driver utilise le maillage en mémoire -// // pour réaliser la transcription des profils MEDMEMOIRE à MEDFICHIER. -// MED_FIELD_WRONLY_DRIVER myFieldDriver3("Copy_nomesh_"+fileName,myField2) ; -// int current = myField2->addDriver(myFieldDriver3); -// myField2->write(current); - -// //Pour regarder le fichier produit avec MDUMP decommenter ces trois lignes -// //car le fichier qui est produit n'est pas à la norme MED -// //Il doit contenir soit le maillage associé soit un lien vers le maillage associé. -// //MED_MESH_WRONLY_DRIVER myMeshDriver2("Copy_nomesh_"+fileName,myMesh2); -// //current=myMesh2->addDriver(myMeshDriver2); -// //myMesh2->write(current); - -// delete myField2; -// delete myMesh2; - - -// } -// mode3: -// // TEST TROISIEME MODE : -// // A la lecture, le fichier MED lu ne contient pas le maillage associé au champ demandé -// // (mais un lien MEDFICHIER qui n'est pas exploité à ce jour). -// // Cependant avant sa lecture le FIELD a été associé à un SUPPORT -// // avec le lien au MESH préalablement chargé. -// // Le driver du FIELD (automatiquement crée) est capable de lire les profils MEDFICHIER -// // et utilise la relation SUPPORT-MESH initialisée pour transcrire les profils -// // de la numérotation locale MEDFICHIER à la numérotation globale MEDMEMOIRE). -// // REM: Une fois le champ chargé, il possède un nouveau support, le premier peut être libéré. -// // En effet le driver du FIELD se fit uniquement au type géométriques définis dans le champ MEDFICHIER -// // pour créer son SUPPORT car un SUPPORT crée "onAll" à partir d'un MESH repose sur tous -// // les types géométriques du MESH ce qui n'est pas forcément le cas d'un champ MEDFICHIER -// // (même sans profil) lu à posteriori. -// { -// med_2_3::med_err err=-1; -// med_2_3::med_idt id = med_2_3::MEDfileOpen(const_cast ( ("Copy_nomesh_"+fileName).c_str()), -// med_2_3::MED_ACC_RDWR); -// if (id <=0) cout << "Erreur dans MEDouvrir pour le fichier " << "Copy_nomesh_"+fileName < ( ("Copy_withmesh_"+fileName).c_str()), -// const_cast (meshName.c_str()) ); -// if (err !=0) cout << "Erreur dans MEDlienEcr pour le maillage distant " << meshName -// <<" contenu dans le fichier " << "Copy_withmesh_"+fileName < * myField3 = new FIELD(mySupport3,MED_DRIVER,"Copy_nomesh_"+fileName,fieldName, -// iterationNumber, orderNumber); -// delete mySupport3; // Il est déjà possible de libérer ce SUPPORT - -// //TEST à la réecriture : -// string cpy("__Copy"); -// vector < string > pflNames = myField3->getSupport()->getProfilNames(); -// for (int i=0; i< pflNames.size(); ++i) { -// pflNames[i].resize(pflNames[i].size()-cpy.size()); -// pflNames[i]+=cpy; -// } -// const_cast(myField3->getSupport())->setProfilNames(pflNames); -// MED_FIELD_WRONLY_DRIVER myFieldDriver4("Copy_nomesh_"+fileName,myField3) ; -// myFieldDriver4.setFieldName(myField3->getName()+"__Copy"); -// int current = myField3->addDriver(myFieldDriver4); -// myField3->write(current); - -// delete myMesh3; -// delete myField3; - - -// //ESSAYER AVEC MAILLAGE DS FICHIER ET LIEN SUPORT-MESH PRESENTS SIMULTANEMENT -// //EN VERSION COHERENTE ET NON COHERENTE -// } -} diff --git a/src/MEDMEMBinTest/test_profil_gauss_MedFieldDriver.cxx b/src/MEDMEMBinTest/test_profil_gauss_MedFieldDriver.cxx deleted file mode 100644 index 72f6fb45e..000000000 --- a/src/MEDMEMBinTest/test_profil_gauss_MedFieldDriver.cxx +++ /dev/null @@ -1,463 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_GaussLocalization.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -#define INTERLACING_MODE FullInterlace -static int fct2(int i,const int * number) { return i;} -static int fct1(int i,const int * number) { return number[i]; } - -static void affiche_field_(FIELD_ * myField) -{ - cout << "Field "<< myField->getName() << " : " <getDescription() << endl ; - int NumberOfComponents = myField->getNumberOfComponents() ; - cout << "- Nombre de composantes : "<< NumberOfComponents << endl ; - for (int i=1; igetComponentName(i)<< endl; - cout << " - description : "<getComponentDescription(i) << endl; - cout << " - units : "<getMEDComponentUnit(i) << endl; - } - cout << "- iteration :" << endl ; - cout << " - numero : " << myField->getIterationNumber()<< endl ; - cout << " - ordre : " << myField->getOrderNumber()<< endl ; - cout << " - temps : " << myField->getTime()<< endl ; - - cout << "- Type : " << myField->getValueType()<< endl; - //PRESENCE DE POINTS DE GAUSS -} - -// Cas de traitement des valeurs sans spécificité concernant -// les points de Gauss ou les profils -// Pas de spécificité concernant le type géométrique -template -void affiche_fieldT(FIELD * myField) -{ - const double * value = 0; - affiche_field_((FIELD_ *) myField); - - cout.setf(ios::fixed); - - int numberOf = myField->getNumberOfValues(); - int numberOfComponents = myField->getNumberOfComponents() ; - int valueLength = myField->getValueLength(); - int numberOfGeometricType = myField->getNumberOfGeometricTypes(); - const int * nbOfElements = myField->getNumberOfElements(); - const MED_EN::medGeometryElement * typeList = myField->getGeometricTypes(); - // Suivant le traitement, on peut faire sortir si il y a des points de Gauss - // ou des profils - - cout << "myField->getValueLength (MED_ALL_ELEMENTS) : " << valueLength << endl; - cout << "myField->getNumberOfElements (MED_ALL_ELEMENTS) : " << numberOf << endl; - cout << "myField->getNumberOfComponents () : " << numberOfComponents << endl; - cout << "myField->getNumberOfGeometricType () : " << numberOfGeometricType << endl; - for (int i=0; i < numberOfGeometricType; i++) { - cout << "Number Of Elements on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< nbOfElements[i] << endl; - cout << "Number Of Gauss Points on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< myField->getNumberOfGaussPoints(typeList[i]) << endl; - cout << "Localization description : " << endl << myField->getGaussLocalization(typeList[i]) << endl; - } - - cout << "- Valeurs :"<getValueLength (MED_ALL_ELEMENTS) : " << valueLength << endl; - cout << "mySupport->getNumberOfElements (MED_ALL_ELEMENTS) : " << numberOf << endl; - cout << "mySupport->getNumberOfComponents () : " << numberOfComponents << endl; - cout << "mySupport->getNumberOfGeometricType () : " << numberOfGeometricType << endl; - assert(numberOf == myField->getNumberOfValues() ); - - // S'il existe des profils, je récupère la liste des numéros d'éléments - // pour tous les types géométriques - for (int i=0; i < numberOfGeometricType; i++) { - cout << "Number Of Elements on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< nbOfElements[i] << endl; - cout << "Number Of Gauss Points on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< nbGaussPoints[i] << endl; - cout << "Localization description : " << endl << myField->getGaussLocalization(typeList[i]) << endl; - } - - // On récupère la liste complète - if (!onAll) number = mySupport->getNumber(MED_ALL_ELEMENTS); - - int elNo = -1; - cout << "- Valeurs :" << endl; - for (int i=1; i<=numberOf; i++) { - if (onAll) elNo = i; else elNo = number[i-1]; - //cout << endl << "myField->getRow("<getRow(elNo) << endl; - value = myField->getRow(elNo) ; - //UP: getRow prend un numéro d'élément qui existe, getRow(1) n'existe pas forcément si il y a un profil - //qui ne défini pas cet indice - //cout << endl << " Valeur de getNbGaussI("<getNbGaussI(elNo) << endl; - for (int j=0; jgetNbGaussI(elNo); j++) - //UP : Prend en compte le nombre de points de Gauss de l'élément elNo - cout << "value["<< elNo << "] = " << value[j] << " "; - cout< -void affiche_fieldT(FIELD * myField) -{ - const double * value = 0; - const int * number = 0; - - affiche_field_((FIELD_ *) myField); - const SUPPORT * mySupport=myField->getSupport(); - - cout.setf(ios::fixed); - - - int numberOfComponents = myField->getNumberOfComponents() ; - int valueLength = myField->getValueLength(); - const int * nbGaussPoints = myField->getNumberOfGaussPoints(); - - int numberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS); - int numberOfGeometricType = mySupport->getNumberOfTypes(); - const int * nbOfElements = mySupport->getNumberOfElements(); - const MED_EN::medGeometryElement * typeList = mySupport->getTypes(); - bool onAll = mySupport->isOnAllElements(); - - cout << "mySupport->getValueLength (MED_ALL_ELEMENTS) : " << valueLength << endl; - cout << "mySupport->getNumberOfElements (MED_ALL_ELEMENTS) : " << numberOf << endl; - cout << "mySupport->getNumberOfComponents () : " << numberOfComponents << endl; - cout << "mySupport->getNumberOfGeometricType () : " << numberOfGeometricType << endl; - cout << "mySupport->getNumberOfElements(MED_ALL_ELEMENTS) : " << numberOf << endl; - assert(numberOf == myField->getNumberOfValues() ); - - // S'il existe des profils, je récupère la liste des numéros d'éléments - // pour tous les types géométriques - for (int i=0; i < numberOfGeometricType; i++) { - cout << "Number Of Elements on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< nbOfElements[i] << endl; - cout << "Number Of Gauss Points on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< nbGaussPoints[i] << endl; - cout << "Localization description : " << endl << myField->getGaussLocalization(typeList[i]) << endl; - } - - - int (* fct)(int,const int *); - - if (!onAll) { - number = mySupport->getNumber(MED_ALL_ELEMENTS); - fct=fct1; - } else - fct=fct2; - - int oneDimlength = valueLength/numberOfComponents; - for (int j=1; j<=numberOfComponents; j++) { - value = myField->getColumn(j) ; - for (int i=0; i -void affiche_fieldT2(FIELD< T, INTERLACING_TAG> * myField) -{} - - -// Spécialisation du traitement pour le mode FullInterlace -// Spécifité de traitement par rapport aux profils (utilisation du SUPPORT) -// Spécificité concernant le type géométrique -// Spécificité concernant les points de Gauss -template <> -void affiche_fieldT2(FIELD * myField) -{ - const int * number = 0; - - affiche_field_((FIELD_ *) myField); - const SUPPORT * mySupport=myField->getSupport(); - - cout.setf(ios::fixed); - - - int numberOfComponents = myField->getNumberOfComponents() ; - int valueLength = myField->getValueLength(); - const int * nbGaussPoints = myField->getNumberOfGaussPoints(); - - int numberOf = mySupport->getNumberOfElements(MED_ALL_ELEMENTS); - int numberOfGeometricType = mySupport->getNumberOfTypes(); - const int * nbOfElements = mySupport->getNumberOfElements(); - const MED_EN::medGeometryElement * typeList = mySupport->getTypes(); - bool onAll = mySupport->isOnAllElements(); - - cout << "mySupport->getValueLength (MED_ALL_ELEMENTS) : " << valueLength << endl; - cout << "mySupport->getNumberOfElements (MED_ALL_ELEMENTS) : " << numberOf << endl; - cout << "mySupport->getNumberOfComponents () : " << numberOfComponents << endl; - cout << "mySupport->getNumberOfGeometricType () : " << numberOfGeometricType << endl; - cout << "mySupport->getNumberOfElements(MED_ALL_ELEMENTS) : " << numberOf << endl; - assert(numberOf == myField->getNumberOfValues() ); - - // S'il existe des profils, je récupère la liste des numéros d'éléments - // pour tous les types géométriques - for (int i=0; i < numberOfGeometricType; i++) { - cout << "Number Of Elements on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< nbOfElements[i] << endl; - cout << "Number Of Gauss Points on type "<< MED_EN::geoNames[typeList[i]] - <<" : "<< nbGaussPoints[i] << endl; - } - - - int (* fct)(int,const int *); - - if (!onAll) { - number = mySupport->getNumber(MED_ALL_ELEMENTS); - fct=fct1; - } else - fct=fct2; - - cout << "- Valeurs :"< * myField1 = new FIELD(MED_DRIVER,fileName,fieldName, - iterationNumber, orderNumber); - affiche_fieldT(myField1); - cout << endl; - affiche_fieldT2(myField1); - - // Pour éviter de modifier le fichier d'origine, - // on en crée une copie avec uniquement le maillage. - // Rem : Pour le test, le chargement du maillage n'est pas nécessaire - // On pourrait réécrire le Champ dans le fichier d'origine - // sous un autre nom. - // Attention si le driver MED_MESH modifie le nombre d'éléments d'un type géométrique : - // le calcul de renumérotation à l'écriture du champ risque d'être faux ! - meshName = myField1->getSupport()->getMeshName(); - MESH * myMesh = new MESH(MED_DRIVER,fileName,meshName); - MED_MESH_WRONLY_DRIVER myMeshDriver1("Copy_withmesh_"+fileName,myMesh); - int current=myMesh->addDriver(myMeshDriver1); - myMesh->write(current); - myMesh->removeReference(); - - // On ajoute un driver en écriture, comme la relation SUPPORT-MESH n'est pas - // initialisée, le driver doit trouver le maillage dans le fichier cible - // pour réaliser la transcription des profils MEDMEMOIRE à MEDFICHIER. - MED_FIELD_WRONLY_DRIVER myFieldDriver2("Copy_withmesh_"+fileName,myField1) ; - current = myField1->addDriver(myFieldDriver2); - myField1->write(current); - myField1->removeReference(); - } - -// mode2: -// ///////////////////////////////////////////////////////////////////////////// -// // TEST DEUXIEME MODE : -// // Lecture idem 1er mode -// // A l'écriture, le fichier cible ne contient pas le maillage mais la -// // relation SUPPORT-MESH est établie, le driver peut donc utiliser les informations -// // dans le maillage pour transcrire les profils. -// // Selon le modèle MED FICHIER, ce mode est interdit : le fichier doit au moins -// // contenir un lien sur le maillage (information pas encore exploitée dans MEDMEMOIRE -// // : pas de gestion de montage/démontage des fichiers ) -// // Attention si le driver MED_MESH modifie le nombre d'éléments d'un type géométrique : -// // le calcul de renumérotation à l'écriture du champ risque d'être faux car les -// // profils crées à la lecture sont basés sur le nombre d'éléments par type géoémtrique -// // du maillage contenu dans le fichier à la lecture. -// // Une solution consisterait à prendre en compte le montage de fichiers distants -// // et de prendre en compte la différence de nombre d'éléments par type géométrique -// // entre le maillage MEDMEM et le maillage MEDFICHIER -// // (Hum ! : Il serait plus simple que MEDMEMOIRE ne recalcule pas systématiquement -// // ce que l'on ne lui demande pas, ce qui permettrait aussi de réécrire à l'identique -// // un fichier que l'on vient de lire) -// { -// FIELD * myField2 = new FIELD(MED_DRIVER,fileName,fieldName, -// iterationNumber, orderNumber); - -// meshName = myField2->getSupport()->getMeshName(); -// MESH * myMesh2 = new MESH(MED_DRIVER,fileName,meshName); - -// const SUPPORT * mySupport2=myField2->getSupport(); -// mySupport2->setMesh(myMesh2); - -// // On ajoute un driver en écriture, comme la relation SUPPORT-MESH est -// // initialisée, le driver utilise le maillage en mémoire -// // pour réaliser la transcription des profils MEDMEMOIRE à MEDFICHIER. -// MED_FIELD_WRONLY_DRIVER myFieldDriver3("Copy_nomesh_"+fileName,myField2) ; -// int current = myField2->addDriver(myFieldDriver3); -// myField2->write(current); - -// //Pour regarder le fichier produit avec MDUMP decommenter ces trois lignes -// //car le fichier qui est produit n'est pas à la norme MED -// //Il doit contenir soit le maillage associé soit un lien vers le maillage associé. -// //MED_MESH_WRONLY_DRIVER myMeshDriver2("Copy_nomesh_"+fileName,myMesh2); -// //current=myMesh2->addDriver(myMeshDriver2); -// //myMesh2->write(current); - -// delete myField2; -// delete myMesh2; - - -// } -// mode3: -// // TEST TROISIEME MODE : -// // A la lecture, le fichier MED lu ne contient pas le maillage associé au champ demandé -// // (mais un lien MEDFICHIER qui n'est pas exploité à ce jour). -// // Cependant avant sa lecture le FIELD a été associé à un SUPPORT -// // avec le lien au MESH préalablement chargé. -// // Le driver du FIELD (automatiquement crée) est capable de lire les profils MEDFICHIER -// // et utilise la relation SUPPORT-MESH initialisée pour transcrire les profils -// // de la numérotation locale MEDFICHIER à la numérotation globale MEDMEMOIRE). -// // REM: Une fois le champ chargé, il possède un nouveau support, le premier peut être libéré. -// // En effet le driver du FIELD se fit uniquement au type géométriques définis dans le champ MEDFICHIER -// // pour créer son SUPPORT car un SUPPORT crée "onAll" à partir d'un MESH repose sur tous -// // les types géométriques du MESH ce qui n'est pas forcément le cas d'un champ MEDFICHIER -// // (même sans profil) lu à posteriori. -// { -// med_2_3::med_err err=-1; -// med_2_3::med_idt id = med_2_3::MEDfileOpen(const_cast ( ("Copy_nomesh_"+fileName).c_str()), -// med_2_3::MED_ACC_RDWR); -// if (id <=0) cout << "Erreur dans MEDouvrir pour le fichier " << "Copy_nomesh_"+fileName < ( ("Copy_withmesh_"+fileName).c_str()), -// const_cast (meshName.c_str()) ); -// if (err !=0) cout << "Erreur dans MEDlienEcr pour le maillage distant " << meshName -// <<" contenu dans le fichier " << "Copy_withmesh_"+fileName < * myField3 = new FIELD(mySupport3,MED_DRIVER,"Copy_nomesh_"+fileName,fieldName, iterationNumber, orderNumber); -// delete mySupport3; // Il est déjà possible de libérer ce SUPPORT - -// //TEST à la réecriture (renommage des profils -// // à cause de MEDprofilEcr qui ne prend pas en compte le mode -// // MED_LECTURE_AJOUT) ): -// string cpy("__Copy"); -// vector < string > pflNames = myField3->getSupport()->getProfilNames(); -// for (int i=0; i< pflNames.size(); ++i) { -// pflNames[i].resize(pflNames[i].size()-cpy.size()); -// pflNames[i]+=cpy; -// } -// const_cast(myField3->getSupport())->setProfilNames(pflNames); - -// MED_FIELD_WRONLY_DRIVER myFieldDriver4("Copy_nomesh_"+fileName,myField3) ; -// myFieldDriver4.setFieldName(myField3->getName()+"__Copy"); -// int current = myField3->addDriver(myFieldDriver4); -// myField3->write(current); - -// delete myMesh3; -// delete myField3; - - -// //ESSAYER AVEC MAILLAGE DS FICHIER ET LIEN SUPORT-MESH PRESENTS SIMULTANEMENT -// //EN VERSION COHERENTE ET NON COHERENTE -// } -} diff --git a/src/MEDMEMBinTest/test_write_groups_poly.cxx b/src/MEDMEMBinTest/test_write_groups_poly.cxx deleted file mode 100644 index a6be65346..000000000 --- a/src/MEDMEMBinTest/test_write_groups_poly.cxx +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Group.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void addMedFacesGroup (MESHING& meshing, int nFaces, int *groupValue, string groupName) -{ - GROUP *faces=new GROUP; - int myNumberOfElements[1]; - medGeometryElement mytypes[1]; - int index[2]; - faces->setName(groupName); - faces->setMesh(&meshing); - faces->setEntity(MED_EN::MED_FACE); - faces->setNumberOfGeometricType(1); - mytypes[0] = MED_EN::MED_POLYGON; - faces->setGeometricType(mytypes); - myNumberOfElements[0] = nFaces; - faces->setNumberOfElements(myNumberOfElements); - index[0] = 1; - index[1] = nFaces; - faces->setNumber(index, groupValue); - meshing.addGroup(*faces); - faces->removeReference(); -} - -int main() -{ - MESHING *pmesh = new MESHING; - pmesh->setName( "C2MESH" ); - pmesh->setNumberOfTypes(0, MED_EN::MED_CELL); - const int nb_hexagone = 7; - const int nbmailles_axiales = 2; - const int nb_polyH = nb_hexagone*(nbmailles_axiales-1); - const int nb_polyG = nb_hexagone*nbmailles_axiales; - const int nNodes = 6 * nb_hexagone * nbmailles_axiales; - - double coord[] = { - 44.401823743922364, 0 , 0, 55.698259110886582, 6.5220000000000002, 0, - 55.698259110886582, 19.566000000000003, 0, 44.401823743922364, 26.088000000000001, 0, - 33.105388376958146, 19.566000000000003, 0, 33.105388376958146, 6.5220000000000002, 0, - 66.9946944778508 , 0 , 0, 78.291129844815018, 6.5220000000000002, 0, - 78.291129844815018, 19.566000000000003, 0, 66.9946944778508 , 26.088000000000001, 0, - 55.698259110886582, 19.566000000000003, 0, 55.698259110886582, 6.5220000000000002, 0, - 33.105388376958146, 19.565999999999999, 0, 44.401823743922364, 26.088000000000001, 0, - 44.401823743922364, 39.131999999999998, 0, 33.105388376958146, 45.653999999999996, 0, - 21.808953009993928, 39.131999999999998, 0, 21.808953009993928, 26.088000000000001, 0, - 55.698259110886582, 19.565999999999999, 0, 66.9946944778508 , 26.088000000000001, 0, - 66.9946944778508 , 39.131999999999998, 0, 55.698259110886582, 45.653999999999996, 0, - 44.401823743922364, 39.131999999999998, 0, 44.401823743922364, 26.088000000000001, 0, - 78.291129844815018, 19.565999999999999, 0, 89.587565211779236, 26.088000000000001, 0, - 89.587565211779236, 39.131999999999998, 0, 78.291129844815018, 45.653999999999996, 0, - 66.9946944778508 , 39.131999999999998, 0, 66.9946944778508 , 26.088000000000001, 0, - 44.401823743922364, 39.132000000000005, 0, 55.698259110886582, 45.654000000000003, 0, - 55.698259110886582, 58.698 , 0, 44.401823743922364, 65.219999999999999, 0, - 33.105388376958146, 58.698 , 0, 33.105388376958146, 45.654000000000003, 0, - 66.9946944778508 , 39.132000000000005, 0, 78.291129844815018, 45.654000000000003, 0, - 78.291129844815018, 58.698 , 0, 66.9946944778508 , 65.219999999999999, 0, - 55.698259110886582, 58.698 , 0, 55.698259110886582, 45.654000000000003, 0, - 44.401823743922364, 0 , 1, 55.698259110886582, 6.5220000000000002, 1, - 55.698259110886582, 19.566000000000003, 1, 44.401823743922364, 26.088000000000001, 1, - 33.105388376958146, 19.566000000000003, 1, 33.105388376958146, 6.5220000000000002, 1, - 66.9946944778508 , 0 , 1, 78.291129844815018, 6.5220000000000002, 1, - 78.291129844815018, 19.566000000000003, 1, 66.9946944778508 , 26.088000000000001, 1, - 55.698259110886582, 19.566000000000003, 1, 55.698259110886582, 6.5220000000000002, 1, - 33.105388376958146, 19.565999999999999, 1, 44.401823743922364, 26.088000000000001, 1, - 44.401823743922364, 39.131999999999998, 1, 33.105388376958146, 45.653999999999996, 1, - 21.808953009993928, 39.131999999999998, 1, 21.808953009993928, 26.088000000000001, 1, - 55.698259110886582, 19.565999999999999, 1, 66.9946944778508 , 26.088000000000001, 1, - 66.9946944778508 , 39.131999999999998, 1, 55.698259110886582, 45.653999999999996, 1, - 44.401823743922364, 39.131999999999998, 1, 44.401823743922364, 26.088000000000001, 1, - 78.291129844815018, 19.565999999999999, 1, 89.587565211779236, 26.088000000000001, 1, - 89.587565211779236, 39.131999999999998, 1, 78.291129844815018, 45.653999999999996, 1, - 66.9946944778508 , 39.131999999999998, 1, 66.9946944778508 , 26.088000000000001, 1, - 44.401823743922364, 39.132000000000005, 1, 55.698259110886582, 45.654000000000003, 1, - 55.698259110886582, 58.698 , 1, 44.401823743922364, 65.219999999999999, 1, - 33.105388376958146, 58.698 , 1, 33.105388376958146, 45.654000000000003, 1, - 66.9946944778508 , 39.132000000000005, 1, 78.291129844815018, 45.654000000000003, 1, - 78.291129844815018, 58.698 , 1, 66.9946944778508 , 65.219999999999999, 1, - 55.698259110886582, 58.698 , 1, 55.698259110886582, 45.654000000000003, 1}; - - pmesh->setCoordinates(3, nNodes, coord, "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - - string coordname[3] = { "x", "y", "z" }; - pmesh->setCoordinatesNames(coordname); - - // Set coordinates units - string coordunit[3] = { "cm", "cm", "cm" }; - pmesh->setCoordinatesUnits(coordunit); - - const medGeometryElement types[] = { MED_EN::MED_POLYGON, MED_EN::MED_POLYHEDRA }; - - pmesh->setNumberOfTypes(1, MED_EN::MED_CELL); - pmesh->setTypes( & types[1], MED_EN::MED_CELL ); - pmesh->setNumberOfElements( & nb_polyH, MED_CELL ); - - pmesh->setNumberOfTypes(1, MED_EN::MED_FACE); - pmesh->setTypes( & types[0], MED_EN::MED_FACE ); - pmesh->setNumberOfElements( & nb_polyG, MED_FACE ); - - int polyHInd[nb_polyH+1] = {1, 44, 87, 130, 173, 216, 259, 302 }; - int polyHConn[301] = { - 1,2,3,4,5,6, -1, 43,44,45,46,47,48,-1, 1,2,44,43, -1, 2,3,45,44, -1, - 3,4,46,45, -1, 4,5,47,46, -1, 5,6,48,47, -1, 6,1,43,48, // #1 - 7,8,9,10,3,2, -1, 49,50,51,52,45,44,-1, 7,8,50,49, -1, 8,9,51,50, -1, - 9,10,52,51, -1, 10,3,45,52, -1, 3,2,44,45, -1, 2,7,49,44, // #2 - 5,4,15,16,17,18, -1, 47,46,57,58,59,60,-1, 5,4,46,47, -1, 4,15,57,46, -1, - 15,16,58,57, -1, 16,17,59,58, -1, 17,18,60,59,-1, 18,5,47,60, // #3 - 3,10,21,22,15,4, -1, 45,52,63,64,57,46,-1, 3,10,52,45, -1, 10,21,63,52,-1, - 21,22,64,63, -1, 22,15,57,64, -1, 15,4,46,57, -1, 4,3,45,46, // #4 - 9,26,27,28,21,10, -1, 51,68,69,70,63,52,-1, 9,26,68,51, -1, 26,27,69,68,-1, - 27,28,70,69, -1, 28,21,63,70, -1, 21,10,52,63,-1, 10,9,51,52, // #5 - 15,22,33,34,35,16,-1, 57,64,75,76,77,58,-1, 15,22,64,57,-1, 22,33,75,64,-1, - 33,34,76,75, -1, 34,35,77,76, -1, 35,16,58,77,-1, 16,15,57,58, // #6 - 21,28,39,40,33,22,-1, 63,70,81,82,75,64,-1, 21,28,70,63,-1, 28,39,81,70,-1, - 39,40,82,81, -1, 40,33,75,82, -1, 33,22,64,75,-1, 22,21,63,64}; // #7 - - pmesh->setConnectivity(MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA, polyHConn, polyHInd); - - int cpolygonsindex[nb_polyG+1] = {1, 7, 13, 19, 25, 31, 37, 43, 49, 55, 61, 67, 73, 79, 85}; - int connec[] = { - 1 , 2 , 3 , 4 , 5 , 6 , - 7 , 8 , 9 , 10, 3 , 2 , - 5 , 4 , 15, 16, 17, 18, - 3 , 10, 21, 22, 15, 4 , - 9 , 26, 27, 28, 21, 10, - 15, 22, 33, 34, 35, 16, - 21, 28, 39, 40, 33, 22, - 43, 44, 45, 46, 47, 48, - 49, 50, 51, 52, 45, 44, - 47, 46, 57, 58, 59, 60, - 45, 52, 63, 64, 57, 46, - 51, 68, 69, 70, 63, 52, - 57, 64, 75, 76, 77, 58, - 63, 70, 81, 82, 75, 64}; - - pmesh->setConnectivity(MED_EN::MED_FACE, MED_EN::MED_POLYGON,connec, cpolygonsindex); - - int bottom[] = {1, 2, 3, 4, 5, 6, 7}; - addMedFacesGroup(*pmesh, nb_hexagone, bottom, "BottomFaces"); - - int id = pmesh->addDriver(MED_DRIVER, "cronoshexa.med", pmesh->getName()); - pmesh->write(id); - pmesh->removeReference(); - - if ( getenv("srcdir") ) - /* we are in 'make check' */ - remove( "cronoshexa.med" ); - - return 0; -} diff --git a/src/MEDMEMBinTest/tests/readCoordinate.cxx b/src/MEDMEMBinTest/tests/readCoordinate.cxx deleted file mode 100755 index 4ba1067f1..000000000 --- a/src/MEDMEMBinTest/tests/readCoordinate.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : readCoordinate.cxx -// Module : MED -// -#include -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -using namespace std; -using namespace MEDMEM; - -#define MED_TAILLE_PNOM 16 - -static void usage(char * name) -{ - cout << " " << name <<" "<< " " << " " << endl; - cout << " " << "displays all Nodes Coordinates in mdump mode" << endl; - cout << endl; - cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl; - cout << " " << "values for interlace mode are : " << endl; - cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl; - exit(-1); -} - -int main (int argc, char ** argv) { - - if (argc < 3) usage(argv[0]); - if (argc > 4) usage(argv[0]); - - string fileName = argv[1]; - string meshName = argv[2]; - - MED_EN::medModeSwitch Mode = MED_EN::MED_FULL_INTERLACE; - if (argc==4) - { - string comp=argv[3]; - if ( comp == "MED_NO_INTERLACE" ) Mode = MED_EN::MED_NO_INTERLACE; - else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]); - } - - - MESH * myMesh= new MESH; - myMesh->setName(meshName); - MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh); - try - { - myMeshDriver.setMeshName(meshName); - myMeshDriver.open(); - } - catch (const exception & ex) - { - MESSAGE_MED("Catch Exception : "); - SCRUTE_MED(ex.what()); - }; - MESSAGE_MED("Open done"); - - try - { - myMeshDriver.read(); - } - catch (const exception & ex) - { - MESSAGE_MED("Catch Exception : "); - SCRUTE_MED(ex.what()); - }; - MESSAGE_MED("Read done"); - - int SpaceDimension = myMesh->getSpaceDimension() ; - int NumberOfNodes = myMesh->getNumberOfNodes() ; - - cout << "(************************)"<getCoordinatesSystem(); - if ( typeRepere.size() == 0 ) typeRepere ="0"; - cout << "- Type de repere des coordonnees : " << typeRepere << endl; - - string chainevide(MED_TAILLE_PNOM+2,' '); - cout << "- Nom des coordonnees : " << endl ; - const string * CoordinatesNames = myMesh->getCoordinatesNames() ; - for (int i=0; i < SpaceDimension ; i++) - { - string bonnelongueur=chainevide; - bonnelongueur.replace(1,CoordinatesNames[i].size(),CoordinatesNames[i]); - cout << bonnelongueur; - } - cout <getCoordinatesUnits() ; - for ( int i=0; i < SpaceDimension ; i++) - { - string bonnelongueur=chainevide; - bonnelongueur.replace(1,CoordinatesUnits[i].size(),CoordinatesUnits[i]); - cout << bonnelongueur; - } - cout <getCoordinates(Mode) ; - cout << "- Coordonnees des noeuds : " << endl; - for (int i=0; i < SpaceDimension*NumberOfNodes; i++) - { - fprintf(stdout," %f ",Coordinates[i]); - } - cout <removeReference(); - -} diff --git a/src/MEDMEMBinTest/tests/readEntete.cxx b/src/MEDMEMBinTest/tests/readEntete.cxx deleted file mode 100755 index 6e3cf07c1..000000000 --- a/src/MEDMEMBinTest/tests/readEntete.cxx +++ /dev/null @@ -1,183 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : readEntete.cxx -// Module : MED -// -#include -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_DriversDef.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void usage(char * name) -{ - cout << " " << name <<" "<< " " << " " << endl; - cout << " " << "displays all Nodes Coordinates in mdump mode" << endl; - cout << endl; - cout << " " << "mesh name is mandatory. Try mdump if necessary" << endl; - cout << " " << "values for interlace mode are : " << endl; - cout << " " << "MED_FULL_INTERLACE (default value) or MED_NO_INTERLACE" << endl; - exit(-1); -} - -int main (int argc, char ** argv) { - - if (argc < 3) usage(argv[0]); - if (argc > 4) usage(argv[0]); - - string fileName = argv[1]; - string meshName = argv[2]; - - medModeSwitch Mode = MED_FULL_INTERLACE; - if (argc==4) - { - string comp=argv[3]; - if ( comp == "MED_NO_INTERLACE" ) Mode = MED_NO_INTERLACE; - else if ( comp != "MED_FULL_INTERLACE") usage(argv[0]); - } - - - MESH * myMesh= new MESH; - myMesh->setName(meshName); - MED_MESH_RDONLY_DRIVER myMeshDriver(fileName,myMesh); - try - { - myMeshDriver.setMeshName(meshName); - myMeshDriver.open(); - } - catch (const exception & ex) - { - MESSAGE_MED("Catch Exception : "); - SCRUTE_MED(ex.what()); - }; - MESSAGE_MED("Open done"); - - try - { - myMeshDriver.read(); - } - catch (const exception & ex) - { - MESSAGE_MED("Catch Exception : "); - SCRUTE_MED(ex.what()); - }; - MESSAGE_MED("Read done"); - - int SpaceDimension = myMesh->getSpaceDimension(); - int MeshDimension = myMesh->getMeshDimension(); - int NumberOfNodes = myMesh->getNumberOfNodes(); - - cout << "(****************************)" << endl; - cout << "(* INFORMATIONS GENERALES : *)" << endl; - cout << "(****************************)" << endl; - - // string chainevide(MED_TAILLE_PNOM+2,' '); - cout << "- Nom du maillage : <<" << meshName << ">>" << endl; - cout << "- Dimension d'espace : "<< SpaceDimension << endl; - cout << "- Dimension du maillage : "<< MeshDimension << endl; - cout << "- Pas de nom universel " << endl ; - cout << "- Nombre de noeuds : " << NumberOfNodes << " " << endl; - - int NumberOfTypes = myMesh->getNumberOfTypes(MED_CELL); - const medGeometryElement * Types; - - cout << "- Nombre de Type de mailles : " << NumberOfTypes << endl; - - if (NumberOfTypes > 0) - { - Types = myMesh->getTypes(MED_CELL); - - cout << " Types : "; - for (int itype=0; itype currentEntity = meshEntities[MED_CELL]; - list::const_iterator currentGeometry; - - for (currentGeometry = currentEntity.begin(); - currentGeometry != currentEntity.end(); - currentGeometry++) - { - cout << "- Nombre de mailles de type "; - cout << geoNames[(*currentGeometry)] << " : "; - cout << myMesh->getNumberOfElements(MED_CELL,(MED_EN::medGeometryElement)(*currentGeometry)); - cout << " " << endl; - } - } - - NumberOfTypes = myMesh->getNumberOfTypes(MED_FACE); - - cout << "- Nombre de Type de faces : " << NumberOfTypes << endl; - - if (NumberOfTypes > 0) - { - Types = myMesh->getTypes(MED_FACE); - - cout << " Types : "; - for (int itype=0; itype currentEntity2 = meshEntities[MED_FACE]; - list::const_iterator currentGeometry; - - for (currentGeometry = currentEntity2.begin(); - currentGeometry != currentEntity2.end(); - currentGeometry++) - { - cout << "- Nombre de faces de type "; - cout << geoNames[(*currentGeometry)] << " : "; - cout << myMesh->getNumberOfElements(MED_FACE,(*currentGeometry)); - cout << " " << endl; - } - } - - NumberOfTypes = myMesh->getNumberOfTypes(MED_EDGE); - - cout << "- Nombre de Type de aretes : " << NumberOfTypes << endl; - - if (NumberOfTypes > 0) - { - Types = myMesh->getTypes(MED_EDGE); - - cout << " Types : "; - for (int itype=0; itype currentEntity3 = meshEntities[MED_EDGE]; - list::const_iterator currentGeometry; - - for (currentGeometry = currentEntity3.begin(); - currentGeometry != currentEntity3.end(); - currentGeometry++) - { - cout << "- Nombre d'aretes de type "; - cout << geoNames[(*currentGeometry)] << " : "; - cout << myMesh->getNumberOfElements(MED_EDGE,(*currentGeometry)); - cout << " " << endl; - } - } - - myMesh->removeReference(); -} diff --git a/src/MEDMEMBinTest/tests/testUArray.cxx b/src/MEDMEMBinTest/tests/testUArray.cxx deleted file mode 100755 index 048457df1..000000000 --- a/src/MEDMEMBinTest/tests/testUArray.cxx +++ /dev/null @@ -1,347 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : testUArray.cxx -// Module : MED -// -#include // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_Array.hxx" - -using namespace std; -using namespace MEDMEM; - -static void imprime(string titre,const int * myValues,const int * myOthers, int lignes, int colonnes) -{ - cout << " " <(int,int,mode) */ - /* - get sur le pointeur MED_FULL_INTERLACE */ - /* - initialisation des valeurs (coordonnées ieme elt = I+1) */ - /* - get sur le pointeur MED_NO_INTERLACE */ - /* ---------------------------------------------------------- */ - - int SpaceDimension = 3; - int NumberOfNodes = 4; - - - - MEDARRAY * myArrayfull= new MEDARRAY(SpaceDimension,NumberOfNodes,MED_EN::MED_FULL_INTERLACE); - ASSERT_MED(myArrayfull != NULL); - - const int * myValues = myArrayfull->get(MED_EN::MED_FULL_INTERLACE); - ASSERT_MED(myValues!= NULL); - - for (int i=0; isetIJ(i+1,k+1,i+1) ; - } - } - - const int * myOthers = myArrayfull->get(MED_EN::MED_NO_INTERLACE) ; - ASSERT_MED(myOthers != NULL); - - imprime("Initialisation full interlace (xi=yi=zi=i+1)",myValues,myOthers,NumberOfNodes,SpaceDimension); - - MEDARRAY * myArrayno= new MEDARRAY(SpaceDimension,NumberOfNodes,MED_EN::MED_NO_INTERLACE); - ASSERT_MED(myArrayno != NULL); - const int * myValuesno = myArrayno->get(MED_EN::MED_NO_INTERLACE); - ASSERT_MED(myValuesno!= NULL); - - for (int k=0; ksetIJ(i+1,k+1,k+1) ; - } - } - - const int * myOthersno = myArrayno->get(MED_EN::MED_FULL_INTERLACE) ; - ASSERT_MED(myOthersno != NULL); - - imprime("Initialisation no interlace (xi=yi=zi=i+1)",myOthersno,myValuesno,NumberOfNodes,SpaceDimension); - - - /* ---------------------------------------------------------- */ - /* */ - /* Tests des Fonctions Set */ - /* */ - /* - setI sur l'element 1 avec des coordonnees a 100 */ - /* - setJ sur l'element 1 avec des coordonnees a 100 */ - /* - setIJ sur (1,2) avec une coordonnee = 1992 */ - /* - set avec l ensemble des coordonnes remises à i */ - /* ---------------------------------------------------------- */ - - - int * myNewLine = new int[SpaceDimension]; - for (int i = 0; i < SpaceDimension; i++) - myNewLine[i] = myValues[i] * 100; - try - { - myArrayfull->setI(1, myNewLine); - } - catch ( const std::exception &e ) - { - cout << "--------------" << endl; - cout << " Pb au setI " << endl; - cout << "--------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------" << endl; - cout << " Pb au setI " << endl; - cout << "---------------" << endl; - } - - delete [] myNewLine; - imprime("1er element : coordonnees à 100",myValues,myOthers,NumberOfNodes,SpaceDimension); - - int * myNewCol = new int[NumberOfNodes]; - for (int i = 0; i < NumberOfNodes; i++) - myNewCol[i] = 100; - try - { - myArrayno->setJ(1, myNewCol); - } - catch ( const std::exception &e ) - { - cout << "--------------" << endl; - cout << " Pb au setJ " << endl; - cout << "--------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------" << endl; - cout << " Pb au setJ " << endl; - cout << "---------------" << endl; - } - - delete [] myNewCol; - imprime("1eres coordonnees à 100",myOthersno,myValuesno,NumberOfNodes,SpaceDimension); - - try - { - myArrayfull->setIJ(1,2,1992); - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " Pb au setIJ() de 1 , 2 " << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-----------------------------" << endl; - cout << " Pb au setIJ() de 1 , 2 " << endl; - cout << "-----------------------------" << endl; - } - - imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension); - - - try - { - myArrayno->setIJ(1,2,1992); - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " Pb au setIJ() de 1 , 2 " << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-----------------------------" << endl; - cout << " Pb au setIJ() de 1 , 2 " << endl; - cout << "-----------------------------" << endl; - } - - imprime("1er element : 2ieme coordonnee = 1992",myValues,myOthers,NumberOfNodes,SpaceDimension); - - int * mynewvalues= new int [ NumberOfNodes*SpaceDimension ]; - for (int i=0; iset(MED_EN::MED_FULL_INTERLACE,mynewvalues); - myValues = myArrayfull->get(MED_EN::MED_FULL_INTERLACE); - myOthers = myArrayfull->get(MED_EN::MED_NO_INTERLACE); - } - catch ( const std::exception &e ) - { - cout << "-------------" << endl; - cout << " Pb au set " << endl; - cout << "-------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "--------------" << endl; - cout << " Pb au set " << endl; - cout << "--------------" << endl; - } - imprime("remise valeur a i sur myArrayfull med full interlace",myValues,myOthers,NumberOfNodes,SpaceDimension); - - try - { - myArrayno->set(MED_EN::MED_FULL_INTERLACE,mynewvalues); - myValuesno = myArrayfull->get(MED_EN::MED_FULL_INTERLACE); - myOthersno = NULL; - } - catch ( const std::exception &e ) - { - cout << "-------------" << endl; - cout << " Pb au set " << endl; - cout << "-------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "--------------" << endl; - cout << " Pb au setI " << endl; - cout << "--------------" << endl; - } - imprime("set full interlace de myArrayno",myValuesno,myOthersno,NumberOfNodes,SpaceDimension); - - /* ---------------------------------------------------------- */ - /* */ - /* Tests des constructeurs */ - /* Tests des Fonctions Get */ - /* */ - /* */ - /* ---------------------------------------------------------- */ - - MEDARRAY * myArrayShare = new MEDARRAY( *myArrayfull); - const int * sharevalues = myArrayShare->get(MED_EN::MED_FULL_INTERLACE ); - const int * shareno = myArrayShare->get(MED_EN::MED_NO_INTERLACE); - imprime("test contructeur par recopie non profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension); - - myArrayfull->setIJ(1,2,1992); - ASSERT_MED(myArrayShare->getIJ(1,2) == 1992); - imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension); - - myArrayShare->setIJ(1,2,1995); - ASSERT_MED(myArrayfull->getIJ(1,2) == 1995); - imprime("change valeur tableau cible, impression tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension); - - delete myArrayShare; - imprime("tableau cible apres destruction tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension); - - MEDARRAY * myArrayShare2 = new MEDARRAY( *myArrayfull,true); - sharevalues = myArrayShare2->get(MED_EN::MED_FULL_INTERLACE ); - shareno = myArrayShare2->get(MED_EN::MED_NO_INTERLACE ); - imprime("test contructeur par recopie profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension); - - myArrayfull->setIJ(1,2,18); - imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension); - - myArrayShare2->setIJ(1,2,19); - imprime("change valeur tableau cible, impression tableau source",myValues,myOthers,NumberOfNodes,SpaceDimension); - - myArrayno->set(MED_EN::MED_NO_INTERLACE,mynewvalues); - myArrayno->setIJ(2,1,1); - myValuesno = myArrayno->get(MED_EN::MED_NO_INTERLACE); - myOthersno = myArrayno->get(MED_EN::MED_FULL_INTERLACE); - imprime("Initialisation no interlace (0...11)",myOthersno,myValuesno,NumberOfNodes,SpaceDimension); - - MEDARRAY * myArrayShare3 = new MEDARRAY( *myArrayno); - sharevalues = myArrayShare3->get(MED_EN::MED_FULL_INTERLACE); - shareno = myArrayShare3->get(MED_EN::MED_NO_INTERLACE); - imprime("test contructeur par recopie non profonde",sharevalues,shareno,NumberOfNodes,SpaceDimension); - - myArrayno->setIJ(1,2,1992); - ASSERT_MED(myArrayShare3->getIJ(1,2) == 1992); - imprime("change valeur tableau source, impression tableau cible",sharevalues,shareno,NumberOfNodes,SpaceDimension); - - myArrayShare3->setIJ(1,2,1995); - ASSERT_MED(myArrayno->getIJ(1,2) == 1995); - imprime("change valeur tableau cible, impression tableau source",myValuesno,myOthersno,NumberOfNodes,SpaceDimension); - - delete myArrayno; - delete [] mynewvalues; - delete myArrayfull; - delete myArrayShare2; - delete myArrayShare3; - MESSAGE_MED("FIN NORMALE DU TRAITEMENT"); - return EXIT_SUCCESS ; -} -/* - inline medModeSwitch getMode() const ; -*/ diff --git a/src/MEDMEMBinTest/tests/testUArray.cxx.ok b/src/MEDMEMBinTest/tests/testUArray.cxx.ok deleted file mode 100755 index 626bf285f..000000000 --- a/src/MEDMEMBinTest/tests/testUArray.cxx.ok +++ /dev/null @@ -1,332 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include // pour l'acces à EXIT_SUCCESS et EXIT_FAILURE -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_Array.hxx" -using namespace MEDMEM; - -int main (int argc, char ** argv) -{ - - int SpaceDimension = 3; - int NumberOfNodes = 4; - MEDARRAY * myArray = new MEDARRAY(SpaceDimension,NumberOfNodes,MED_FULL_INTERLACE) ; - ASSERT(myArray != NULL); - - int * value = myArray->get(MED_FULL_INTERLACE) ; - ASSERT(value!= NULL); - - for (int i=0; igetLeadingValue() ; - ASSERT (leadingValue == SpaceDimension); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au getLeadingValue() " << endl; - cout << "-------------------------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << " Pb au getLeadingValue() " << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - } - - int lengthValue; - try - { - lengthValue = myArray->getLengthValue() ; - ASSERT(lengthValue == NumberOfNodes) - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au getLengthValue() " << endl; - cout << "-------------------------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << " Pb au getLengthValue() " << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - } - - cout << "Show all using getI and full interlace :" << endl; - for (int i=1; i<=lengthValue; i++) - { - try - { - int * node = myArray->getI(MED_FULL_INTERLACE,i) ; - cout << " - " ; - for (int j=0;jgetI(MED_NO_INTERLACE,i) ; - cout << " - " ; - for (int j=0;jgetIJ(i,j) << " " ; - cout << endl ; - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au getIJ() i " << i << " j " << j << endl; - cout << "-------------------------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << " Pb au getIJ() i " << i << " j " << j << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - } - } - - cout << "Show all using get and MED_NO_INTERLACE :" << endl; - try - { - int * NoInterlaceArray = myArray->get(MED_NO_INTERLACE) ; - for (int i=0; iset(MED_FULL_INTERLACE, myNewInt); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au set " << endl; - cout << "-------------------------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------" << endl; - cout << " Pb au set " << endl; - cout << "---------------" << endl; - return EXIT_FAILURE ; - } - delete [] myNewInt; - - cout << "Nouvelles valeurs (x10) : get avec Full interlace : " << endl; - int * myNewValue; - try - { - myNewValue = myArray->get(MED_FULL_INTERLACE) ; - ASSERT(myNewValue!= NULL); - } - catch ( const std::exception &e ) - { - cout << "-----------------" << endl; - cout << " Pb au get " << endl; - cout << "-----------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------" << endl; - cout << " Pb au get " << endl; - cout << "---------------" << endl; - } - - cout << " - "; - for (int i=0; isetI(MED_FULL_INTERLACE, 1, myNewLine); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au getLengthValue() " << endl; - cout << "-------------------------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------" << endl; - cout << " Pb au setI " << endl; - cout << "---------------" << endl; - } - delete [] myNewLine; - - try - { - myNewValue = myArray->getI(MED_FULL_INTERLACE,1) ; - ASSERT(myNewValue!= NULL); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au getLengthValue() " << endl; - cout << "-------------------------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------" << endl; - cout << " Pb au getI " << endl; - cout << "---------------" << endl; - } - - cout << endl << " Nouvelles valeurs (x100) sur la 1ere ligne: get avec Full interlace : "; - cout << endl << " - "; - for (int i=0; isetIJ(1,1,1992); - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " Pb au setIJ() de 1 , 1 " << endl; - cout << "---------------------------" << endl; - MESSAGE( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-----------------------------" << endl; - cout << " Pb au setIJ() de 1 , 1 " << endl; - cout << "-----------------------------" << endl; - } - - cout << "Nouvelle valeur avec setIJ et getIJ" << endl; - cout << " - " << myArray->getIJ(1,1) << endl; - - delete myArray; - return EXIT_SUCCESS ; -} - -/* - inline medModeSwitch getMode() const ; - -*/ diff --git a/src/MEDMEMBinTest/tests/testUCellModel.cxx b/src/MEDMEMBinTest/tests/testUCellModel.cxx deleted file mode 100755 index 47f237b6a..000000000 --- a/src/MEDMEMBinTest/tests/testUCellModel.cxx +++ /dev/null @@ -1,369 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : testUCellModel.cxx -// Module : MED -// -#include -#include -#include "MEDMEM_Utilities.hxx" - -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_DriversDef.hxx" - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -#define MED_NBR_GEOMETRIE_MAILLE 15 - -static void usage(char * name) -{ - cout << " " << name << endl; -} - -int main (int argc, char ** argv) -{ - - if (argc < 1) usage(argv[0]); - - - cout << "CELLMODEL Test" << endl ; - cout << "--------------" << endl; - - /* ----------------------------------------------------- - Construction de tous les types de cellmodel possibles - ----------------------------------------------------- - */ - - CELLMODEL * tous =new CELLMODEL[MED_NBR_GEOMETRIE_MAILLE ]; - const medGeometryElement allCellType[MED_NBR_GEOMETRIE_MAILLE ]= - {MED_POINT1, MED_SEG2, MED_SEG3, MED_TRIA3, - MED_QUAD4, MED_TRIA6, MED_QUAD8, MED_TETRA4, - MED_PYRA5, MED_PENTA6, MED_HEXA8, MED_TETRA10, - MED_PYRA13, MED_PENTA15, MED_HEXA20 }; - - for (int i=0; i setGeomElt; - medGeometryElement * vt; - int taille; - try - { - vt=tous[i].getConstituentsType(dim2); - taille=tous[i].getNumberOfConstituents(dim2); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au getConstituentsType() " << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "--------------------------------" << endl; - cout << " Pb au getConstituentsType() " << endl; - cout << "--------------------------------" << endl; - return EXIT_FAILURE ; - }; - for (int k=0; k::iterator iter_s; - for (iter_s=setGeomElt.begin() ;iter_s!=setGeomElt.end();iter_s++) - { - cout << geoNames[(*iter_s)] << endl; - } - - cout << "Impression des coordonnées du 1er Element de ce type" << endl; - try - { - vector v2=tous[i].getNodesConstituent(dim2,1); - for (int k=0; k 1 ) - { - try - { - cout << "Informations particulieres - dimension " << dimension - 1 << endl; - set ::iterator iter_s; - for (iter_s=tous[i].getAllConstituentsType().begin() ; - iter_s!=tous[i].getAllConstituentsType().end();iter_s++) - { - cout << geoNames[*iter_s] << endl; - } - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << " Pb au getAllConstituentsType() " << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "------------------------------------" << endl; - cout << " Pb au getAllConstituentsType() " << endl; - cout << "------------------------------------" << endl; - return EXIT_FAILURE ; - } - } -*/ - - } - - delete[] tous ; - - return EXIT_SUCCESS ; -/* - Reste a Tester - // Return number of constituents foreach type (which dimension is _dimension-1). - map getNumberOfConstituentsForeachType() const; -*/ -} diff --git a/src/MEDMEMBinTest/tests/testUCoordinate.cxx b/src/MEDMEMBinTest/tests/testUCoordinate.cxx deleted file mode 100755 index 11b8e45c7..000000000 --- a/src/MEDMEMBinTest/tests/testUCoordinate.cxx +++ /dev/null @@ -1,396 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : testUCoordinate.cxx -// Module : MED -// -#include -#include -#include "MEDMEM_Utilities.hxx" - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Array.hxx" -#include "MEDMEM_Coordinate.hxx" -#include - -#define pouieme 0.009 - -using namespace std; -using namespace MEDMEM; - -static void usage(char * name) -{ - cout << " " << name << endl; -} - -int main (int argc, char ** argv) -{ - - - if (argc < 1) usage(argv[0]); - - cout << "COORDINATE Test" << endl; - cout << "---------------" << endl; - - int SpaceDim = 3; - int NbOfNodes = 5; - - string * noms = new string[3]; - noms[0]=" X "; - noms[1]=" Y "; - noms[2]=" Z "; - - string units[3]; - units[0]=" m "; - units[1]=" m "; - units[2]=" m "; - - int * numbers=new int[5]; - for (int i=0; i< 5; i++) numbers[i] =10+i; - - MED_EN::medModeSwitch ModeFull=MED_EN::MED_FULL_INTERLACE; - double coor[15] = {0,0,0,0,0,1,0,1,0,1,0,0,0.5,0.5,0.5} ; - ASSERT_MED(SpaceDim*NbOfNodes == 15); - - - cout << " - mode : MED_FULL_INTERLACE" << endl; - cout << " - dimension de l espace : " << SpaceDim << endl; - cout << " - nombre de noeuds : " << NbOfNodes << endl; - - double * coor1 = new double[SpaceDim*NbOfNodes]; - for( int k=0 ; k* CoordinateArray = new MEDARRAY(coor1,SpaceDim,NbOfNodes,ModeFull); - COORDINATE mycoo; - try - { - mycoo.setCoordinates(CoordinateArray); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinates" << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinates" << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - }; - - //--------------------------------------------------------------------// - // Tests des methodes // - // // - // - setCoordinatesNames // - // - setCoordinatesUnits // - // - setCoordinatesSystem // - // - setNodesNumbers // - // // - //--------------------------------------------------------------------// - try - { - mycoo.setCoordinatesNames(noms); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinatesNames" << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinatesNames" << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - }; - - try - { - mycoo.setCoordinatesUnits(units); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinatesUnits" << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinatesUnits" << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - }; - - try - { - mycoo.setCoordinatesSystem("cartesien"); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinatesSystem" << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << "pb avec setCoordinatesSystem" << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - }; - - try - { - mycoo.setNodesNumbers(numbers); - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << "pb avec setNodesNumbers" << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << "pb avec setNodesNumbers" << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - }; - - //--------------------------------------------------------------------// - // Tests des methodes // - // // - // - getCoordinatesNames // - // - getCoordinatesUnits // - // - getCoordinatesUnit // - // - getCoordinatesSystem // - // - getNodesNumbers // - // // - //--------------------------------------------------------------------// - - cout << endl << " Relecture des Coordonnees" << endl << endl; - - try - { - cout << " Le systeme est : " << mycoo.getCoordinatesSystem() << endl; - } - catch ( const std::exception &e ) - { - cout << "-------------------------------" << endl; - cout << "pb avec getCoordinatesSystem" << endl; - cout << "-------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------------" << endl; - cout << "pb avec getCoordinatesSystem" << endl; - cout << "-------------------------------" << endl; - return EXIT_FAILURE ; - }; - - const string * units2; - try - { - units2=mycoo.getCoordinatesUnits(); - for (int axe = 0; axe < SpaceDim; axe++) - { - try - { - string verif = mycoo.getCoordinateUnit(axe+1); - if (verif != units2[axe]) - cout << "Pb avec les noms des axes" << endl; - } - catch ( const std::exception &e ) - { - cout << "-------------------------" << endl; - cout << "pb avec getCoordinateUnit" << endl; - cout << "-------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------" << endl; - cout << "pb avec getCoordinateUnit" << endl; - cout << "-------------------------" << endl; - return EXIT_FAILURE ; - }; - } - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << "pb avec getCoordinatesUnits" << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------------------" << endl; - cout << "pb avec getCoordinatesUnits" << endl; - cout << "---------------------------" << endl; - return EXIT_FAILURE ; - }; - - const string * noms2; - try - { - noms2=mycoo.getCoordinatesNames(); - for (int axe = 0; axe < SpaceDim; axe++) - { - try - { - string verif = mycoo.getCoordinateName(axe+1); - if (verif != noms2[axe]) - cout << "Pb avec les noms des axes" << endl; - } - catch ( const std::exception &e ) - { - cout << "-------------------------" << endl; - cout << "pb avec getCoordinateName" << endl; - cout << "-------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------" << endl; - cout << "pb avec getCoordinateName" << endl; - cout << "-------------------------" << endl; - return EXIT_FAILURE ; - }; - } - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << "pb avec getCoordinatesNames" << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------------------" << endl; - cout << "pb avec getCoordinatesNames" << endl; - cout << "---------------------------" << endl; - return EXIT_FAILURE ; - }; - - - try - { - for (int axe = 0; axe < SpaceDim; axe++) - { - - cout << "Coordonnees sur l'Axe : " << noms2[axe] ; - cout << " dont l unite est " << units2[axe] << endl; - - try - { - for (int num=0; num < NbOfNodes; num++) - { - try - { - const double d = mycoo.getCoordinate(num + 1,axe+1); - cout << d <<" , "; - ASSERT_MED(fabs(d - mycoo.getCoordinateAxis(axe+1)[num]) < pouieme); - ASSERT_MED(fabs(d - mycoo.getCoordinates(ModeFull)[(num * SpaceDim)+axe]) < pouieme); - ASSERT_MED(fabs(d - coor [(num * SpaceDim)+axe]) < pouieme); - } - catch ( const std::exception &e ) - { - cout << "----------------------" << endl; - cout << "pb avec getCoordinates" << endl; - cout << "----------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "----------------------" << endl; - cout << "pb avec getCoordinates" << endl; - cout << "----------------------" << endl; - return EXIT_FAILURE ; - }; - } - cout << endl; - } - catch ( const std::exception &e ) - { - cout << "-------------------------" << endl; - cout << "pb avec getCoordinateAxis" << endl; - cout << "-------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------------" << endl; - cout << "pb avec getCoordinateAxis" << endl; - cout << "-------------------------" << endl; - return EXIT_FAILURE ; - } - } - } - catch ( const std::exception &e ) - { - cout << "----------------------" << endl; - cout << "pb avec getCoordinates" << endl; - cout << "----------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "----------------------" << endl; - cout << "pb avec getCoordinates" << endl; - cout << "----------------------" << endl; - return EXIT_FAILURE ; - }; - - - delete [] noms ; - delete [] numbers; - delete [] coor1; - - delete CoordinateArray ; - - MESSAGE_MED("FIN normale du traitement"); - return EXIT_SUCCESS ; -} - diff --git a/src/MEDMEMBinTest/tests/testUGeoNameMeshEntities.cxx b/src/MEDMEMBinTest/tests/testUGeoNameMeshEntities.cxx deleted file mode 100755 index 45f3f59cb..000000000 --- a/src/MEDMEMBinTest/tests/testUGeoNameMeshEntities.cxx +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : testUGeoNameMeshEntities.cxx -// Module : MED -// -#include "MEDMEM_DriversDef.hxx" - -using namespace std; -static void usage(char * name) -{ - cout << " " << name << endl; - cout << " " << "displays all avalaible geometry elements" << endl; - cout << " " << "display then all avalaible entities, and for each" << endl; - cout << " " << "all possible geomety element" << endl; - cout << endl; - exit(-1); -} - -int main (int argc, char ** argv) -{ - - if (argc < 1) usage(argv[0]); - - - cout << "GEO_NAME Test" << endl ; - cout << "-------------" << endl << endl; - MED_EN::GEO_NAME::const_iterator currentGeom; - for (currentGeom = MED_EN::geoNames.begin(); - currentGeom != MED_EN::geoNames.end(); - currentGeom++) - { - cout << (*currentGeom).second << endl; - }; - - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - list::const_iterator currentGeometry; - - cout << endl; - cout << "MESH_ENTITIES Test" << endl ; - cout << "------------------" << endl << endl; - for (currentEntity = MED_EN::meshEntities.begin(); - currentEntity != MED_EN::meshEntities.end(); - currentEntity++) - { - cout << (*((MED_EN::entNames).find((*currentEntity).first))).second < -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char ** argv) -{ - MEDEXCEPTION a = MEDEXCEPTION("test med exception"); - cout << a << endl;; - cout << a.what() << endl;; - - MEDEXCEPTION b(a); - cout << b << endl; - cout << b.what() << endl;; - - MEDEXCEPTION c("test med exception",argv[0],14); - cout << c << endl; - cout << c.what() << endl;; - - STRING msgErr; - msgErr << "ESSAI::ESSAI()! "<< 4 << "ieme essai "; - cout << MEDEXCEPTION (LOCALIZED(msgErr)).what() << endl ; - - const char * LOC = "toto" ; - cout << MEDEXCEPTION (LOCALIZED(STRING(LOC)<<" et titi")).what() << endl ; - - return EXIT_SUCCESS; - -} diff --git a/src/MEDMEMBinTest/tests/testUModulusArray.cxx b/src/MEDMEMBinTest/tests/testUModulusArray.cxx deleted file mode 100644 index 2a3ad23b5..000000000 --- a/src/MEDMEMBinTest/tests/testUModulusArray.cxx +++ /dev/null @@ -1,424 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : testUModulusArray.cxx -// Module : MED -// -#include -#include -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_ModulusArray.hxx" -using namespace std; -using namespace MEDMEM; - -int main (int argc, char ** argv) -{ - - using namespace std ; - - int array[5]={0,1,2,1,4} ; - MEDMODULUSARRAY modulusArray(5,array); - - cout << " ModulusArray : " << endl; - cout << " _______________" << endl; - for(int i=-10;i<15;i++) - { - cout <<" - A[" << i <<"]="< P; - - // Creation d'un PointerOf de int - // et vérification de la methode set en essayant avec - // une taille nulle, négative puis positive - try - { - P.set(0); - ASSERT_MED((int *)P == NULL); - } - catch ( const std::exception &e ) - { - cout << "-------------------------" << endl; - cout << " pb avec set(taille = 0) " << endl; - cout << "-------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - - try - { - P.set(-1 * size); - ASSERT_MED((int *)P == NULL); - } - catch ( const std::exception &e ) - { - cout << "---------------------" << endl; - cout << " pb avec set(taille) " << endl; - cout << "---------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - - try - { - P.set(size); - ASSERT_MED((int *)P != NULL); - } - catch ( const std::exception &e ) - { - cout << "---------------------" << endl; - cout << " pb avec set(taille) " << endl; - cout << "---------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - for (int i=0; i < size; i++) - { - P[i]=i; - } - - PointerOf P2(10); - - P2=P; - for (int i=0; i < size; i++) - { - SCRUTE_MED(P2[i]); - } - - int * p=new int [size]; - for (int i=0; i < size; i++) - { - p[i]=i*10; - } - - P2.set(p); - PointerOf P3(p); - - for (int i=0; i < size; i++) - { - SCRUTE_MED(P2[i]); - SCRUTE_MED(P3[i]); - } - - const PointerOf P4(p); - const PointerOf P5(P4); - delete [] p; - -} diff --git a/src/MEDMEMBinTest/tests/testUSkyLineArray.cxx b/src/MEDMEMBinTest/tests/testUSkyLineArray.cxx deleted file mode 100644 index 265474fc7..000000000 --- a/src/MEDMEMBinTest/tests/testUSkyLineArray.cxx +++ /dev/null @@ -1,237 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : testUSkyLineArray.cxx -// Module : MED -// -#include -#include "MEDMEM_Utilities.hxx" -#include "MEDMEM_SkyLineArray.hxx" - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char ** argv) -{ - - int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle - int Size = 10 ; // 10 nodes - - int * index = new int[NumberOfCell+1]; - index[0]=1; - index[1]=4; - index[2]=8; - index[3]=11; - - int * value = new int[Size]; - value[0]=1; // first - value[1]=2; - value[2]=5; - value[3]=2; // second - value[4]=3; - value[5]=5; - value[6]=6; - value[7]=3; // thirst - value[8]=4; - value[9]=6; - - MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ; - - const int * ArrayIndex ; - try - { - ArrayIndex = myArray->getIndex() ; - } - catch ( const std::exception &e ) - { - cout << "----------------" << endl; - cout << "pb avec getIndex" << endl; - cout << "----------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "----------------" << endl; - cout << "pb avec getIndex" << endl; - cout << "----------------" << endl; - return EXIT_FAILURE ; - } - - const int * ArrayValue ; - try - { - ArrayValue = myArray->getValue() ; - } - catch ( const std::exception &e ) - { - cout << "----------------" << endl; - cout << "pb avec getValue" << endl; - cout << "----------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "----------------" << endl; - cout << "pb avec getValue" << endl; - cout << "----------------" << endl; - return EXIT_FAILURE ; - } - - - try - { - ASSERT_MED(myArray->getNumberOf()==NumberOfCell); - cout << myArray->getNumberOf() << endl; - } - catch ( const std::exception &e ) - { - cout << "-------------------" << endl; - cout << "pb avec getNumberOf" << endl; - cout << "-------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------" << endl; - cout << "pb avec getNumberOf" << endl; - cout << "-------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - ASSERT_MED(myArray->getLength()==Size); - cout << myArray->getLength() << endl; - } - catch ( const std::exception &e ) - { - cout << "-------------------" << endl; - cout << "pb avec getLength" << endl; - cout << "-------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------" << endl; - cout << "pb avec getLength" << endl; - cout << "-------------------" << endl; - return EXIT_FAILURE ; - } - - cout << "Show all :" << endl ; - for (int i=1; i< NumberOfCell+1 ; i++) - { - const int * cell; - try - { - cell = myArray->getI(i) ; - } - catch ( const std::exception &e ) - { - cout << "-----------------------------" << endl; - cout << "pb avec getI, valeur de i : " << i << endl; - cout << "-----------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------" << endl; - cout << "pb avec getI, valeur de i : " << i << endl; - cout << "-------------------" << endl; - return EXIT_FAILURE ; - } - - int numberof; - try - { - numberof= myArray->getNumberOfI(i) ; - ASSERT_MED(numberof==index[i]-index[i-1]); - } - catch ( const std::exception &e ) - { - cout << "----------------------------------" << endl; - cout << "pb avec getNumberOfI, valeur de i : " << i << endl; - cout << "----------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "----------------------------------" << endl; - cout << "pb avec getNumberOfI, valeur de i : " << i << endl; - cout << "----------------------------------" << endl; - return EXIT_FAILURE ; - } - - cout << " - " ; - for (int j=0;jgetIJ(i,j+1); - if (verif != cell[j]) - { - cout << "----------------------------------" << endl; - cout << " incoherence dans les valeurs : " << endl; - cout << " cell[" << j << "] : " << cell[j] << endl; - cout << " getIJ(" << i <<"," << j << ") : " << verif << endl; - cout << "----------------------------------" << endl; - return EXIT_FAILURE ; - } - } - catch ( const std::exception &e ) - { - cout << "----------------------------------" << endl; - cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl; - cout << "----------------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "----------------------------------" << endl; - cout << "pb avec getIJ, valeurs de i / j : " << i << " " << j<< endl; - cout << "----------------------------------" << endl; - return EXIT_FAILURE ; - } - } - cout << endl ; - } - - delete[] index ; - delete[] value ; - - delete myArray; - MESSAGE_MED("FIN normale du traitement"); - return EXIT_SUCCESS ; - - -/* - MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray ); - void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ; - - -*/ -} diff --git a/src/MEDMEMBinTest/tests/testUUnit.cxx b/src/MEDMEMBinTest/tests/testUUnit.cxx deleted file mode 100755 index 9e1088672..000000000 --- a/src/MEDMEMBinTest/tests/testUUnit.cxx +++ /dev/null @@ -1,400 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : testUUnit.cxx -// Module : MED -// -#include -#include - -#include "MEDMEM_Unit.hxx" -using namespace std; -using namespace MEDMEM; - -int main (int argc, char ** argv) -{ - - cout << "UNIT Test" << endl ; - cout << "---------" << endl; - - UNIT testu; - try - { - testu.setName("ForTesting") ; - } - catch ( const std::exception &e ) - { - cout << "-----------------" << endl; - cout << " pb avec setName " << endl; - cout << "-----------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-----------------" << endl; - cout << " pb avec setName " << endl; - cout << "-----------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setDescription("all values are setted 10") ; - } - catch ( const std::exception &e ) - { - cout << "------------------------" << endl; - cout << " pb avec setDescription " << endl; - cout << "------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "------------------------" << endl; - cout << " pb avec setDescription " << endl; - cout << "------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setMasse(10); - } - catch ( const std::exception &e ) - { - cout << "------------------" << endl; - cout << " pb avec setMasse " << endl; - cout << "------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "------------------" << endl; - cout << " pb avec setMasse " << endl; - cout << "------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setLength(10); - } - catch ( const std::exception &e ) - { - cout << "-------------------" << endl; - cout << " pb avec setLength " << endl; - cout << "-------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------" << endl; - cout << " pb avec setLength " << endl; - cout << "-------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setTime(10); - } - catch ( const std::exception &e ) - { - cout << "-----------------" << endl; - cout << " pb avec setTime " << endl; - cout << "-----------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-----------------" << endl; - cout << " pb avec setTime " << endl; - cout << "-----------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setTemperature(10); - } - catch ( const std::exception &e ) - { - cout << "------------------------" << endl; - cout << " pb avec setTemperature " << endl; - cout << "------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "------------------------" << endl; - cout << " pb avec setTemperature " << endl; - cout << "------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setMatterQuantity(10); - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " pb avec setMatterQuantity " << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------------------" << endl; - cout << " pb avec setMatterQuantity " << endl; - cout << "---------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setCurrentStrength(10) ; - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " pb avec setCurrentStrengt " << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------------------" << endl; - cout << " pb avec setCurrentStrengt " << endl; - cout << "---------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - testu.setLightIntensity(10) ; - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " pb avec setLightIntensity " << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------------------" << endl; - cout << " pb avec setLightIntensity " << endl; - cout << "---------------------------" << endl; - return EXIT_FAILURE ; - } - - - try - { - cout << testu.getName() << endl ; - } - catch ( const std::exception &e ) - { - cout << "-----------------" << endl; - cout << " pb avec getName " << endl; - cout << "-----------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-----------------" << endl; - cout << " pb avec getName " << endl; - cout << "-----------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getDescription() << endl ; - } - catch ( const std::exception &e ) - { - cout << "------------------------" << endl; - cout << " pb avec getDescription " << endl; - cout << "------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "------------------------" << endl; - cout << " pb avec getDescription " << endl; - cout << "------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getMasse() << endl ; - } - catch ( const std::exception &e ) - { - cout << "------------------" << endl; - cout << " pb avec getMasse " << endl; - cout << "------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "------------------" << endl; - cout << " pb avec getMasse " << endl; - cout << "------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getLength() << endl ; - } - catch ( const std::exception &e ) - { - cout << "-------------------" << endl; - cout << " pb avec getLength " << endl; - cout << "-------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-------------------" << endl; - cout << " pb avec getLength " << endl; - cout << "-------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getTime() << endl ; - } - catch ( const std::exception &e ) - { - cout << "-----------------" << endl; - cout << " pb avec getTime " << endl; - cout << "-----------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "-----------------" << endl; - cout << " pb avec getTime " << endl; - cout << "-----------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getTemperature() << endl ; - } - catch ( const std::exception &e ) - { - cout << "------------------------" << endl; - cout << " pb avec getTemperature " << endl; - cout << "------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "------------------------" << endl; - cout << " pb avec getTemperature " << endl; - cout << "------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getMatterQuantity() << endl ; - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " pb avec getMatterQuantity " << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------------------" << endl; - cout << " pb avec getMatterQuantity " << endl; - cout << "---------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getCurrentStrength() << endl ; - } - catch ( const std::exception &e ) - { - cout << "----------------------------" << endl; - cout << " pb avec getCurrentStrength " << endl; - cout << "----------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "----------------------------" << endl; - cout << " pb avec getCurrentStrength " << endl; - cout << "----------------------------" << endl; - return EXIT_FAILURE ; - } - - try - { - cout << testu.getLightIntensity() << endl ; - } - catch ( const std::exception &e ) - { - cout << "---------------------------" << endl; - cout << " pb avec getLightIntensity " << endl; - cout << "---------------------------" << endl; - MESSAGE_MED( "catched exception : " << e.what() ) ; - return EXIT_FAILURE ; - } - catch (...) - { - cout << "---------------------------" << endl; - cout << " pb avec getLightIntensity " << endl; - cout << "---------------------------" << endl; - return EXIT_FAILURE ; - } - - return EXIT_SUCCESS ; - -} diff --git a/src/MEDMEMCppTest/BasicMainTest.hxx b/src/MEDMEMCppTest/BasicMainTest.hxx deleted file mode 100644 index a0c92af70..000000000 --- a/src/MEDMEMCppTest/BasicMainTest.hxx +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _BASICMAINTEST_HXX_ -#define _BASICMAINTEST_HXX_ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// ============================================================================ -/*! - * Main program source for Unit Tests with cppunit package does not depend - * on actual tests, so we use the same for all partial unit tests. - */ -// ============================================================================ - -int main(int argc, char* argv[]) -{ - // --- Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // --- Add a listener that colllects test result - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // --- Add a listener that print dots as test run. -#ifdef WIN32 - CPPUNIT_NS::TextTestProgressListener progress; -#else - CPPUNIT_NS::BriefTestProgressListener progress; -#endif - controller.addListener( &progress ); - - // --- Get the top level suite from the registry - - CPPUNIT_NS::Test *suite = - CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest(); - - // --- Adds the test to the list of test to run - - CPPUNIT_NS::TestRunner runner; - runner.addTest( suite ); - runner.run( controller); - - // --- Print test in a compiler compatible format. - - std::ofstream testFile; - testFile.open("UnitTestsResult", std::ios::out | std::ios::trunc); - //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); - CPPUNIT_NS::CompilerOutputter outputter( &result, testFile ); - outputter.write(); - - // --- Run the tests. - - bool wasSucessful = result.wasSuccessful(); - testFile.close(); - - // --- Return error code 1 if the one of test failed. - - return wasSucessful ? 0 : 1; -} - -#endif diff --git a/src/MEDMEMCppTest/CMakeLists.txt b/src/MEDMEMCppTest/CMakeLists.txt deleted file mode 100644 index 56e3fb4c9..000000000 --- a/src/MEDMEMCppTest/CMakeLists.txt +++ /dev/null @@ -1,131 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INCLUDE_DIRECTORIES( - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${XDR_INCLUDE_DIRS} - ${CPPUNIT_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Geometric2D - ) - -SET(MEDMEMCppTest_SOURCES - MEDMEMTest.cxx - MEDMEMTest_Array.cxx - MEDMEMTest_AsciiFieldDriver.cxx - MEDMEMTest_Connectivity.cxx - MEDMEMTest_Coordinate.cxx - MEDMEMTest_DesactivateFacesComputation.cxx - MEDMEMTest_GetVolumeAbs.cxx - MEDMEMTest_DriverFactory.cxx - MEDMEMTest_Exception.cxx - MEDMEMTest_Extractor.cxx - MEDMEMTest_Family.cxx - MEDMEMTest_Field.cxx - MEDMEMTest_Formulae.cxx - MEDMEMTest_GaussLocalization.cxx - MEDMEMTest_GibiMeshDriver.cxx - MEDMEMTest_Grid.cxx - MEDMEMTest_Group.cxx - MEDMEMTest_MedFileBrowser.cxx - MEDMEMTest_MedFieldDriver.cxx - MEDMEMTest_MedMeshDriver.cxx - MEDMEMTest_MedVersion.cxx - MEDMEMTest_MeshAndMeshing.cxx - MEDMEMTest_ModulusArray.cxx - MEDMEMTest_PartialDescendingConnectivity.cxx - MEDMEMTest_PointerOf.cxx - MEDMEMTest_PorflowMeshDriver.cxx - MEDMEMTest_Remapper.cxx - MEDMEMTest_SkyLineArray.cxx - MEDMEMTest_Support.cxx - MEDMEMTest_TopLevel.cxx - MEDMEMTest_Unit.cxx - MEDMEMTest_VtkFieldDriver.cxx - MEDMEMTest_VtkMedDriver.cxx - MEDMEMTest_VtkMeshDriver.cxx - MEDMEMTest_nArray.cxx - MEDMEMTest_Utils.hxx - MEDMEMTest_Utils.cxx - MEDMEMTest_MeshFuse.cxx - ) - -SET(TestMEDMEM_SOURCES - TestMEDMEM.cxx - ) - -SET(MEDMEMTest_Array_fault_SOURCES - MEDMEMTest_Array_fault.cxx - ) - -SET(MEDMEMTest_Connectivity_fault_SOURCES - MEDMEMTest_Connectivity_fault.cxx - ) - -SET(MEDMEMTest_Coordinate_fault_SOURCES - MEDMEMTest_Coordinate_fault.cxx - ) - -SET(MEDMEMTest_Family_fault_SOURCES - MEDMEMTest_Family_fault.cxx - ) - -SET(MEDMEMTest_Field_fault_SOURCES - MEDMEMTest_Field_fault.cxx - ) - -SET(MEDMEMTest_Grid_fault_SOURCES - MEDMEMTest_Grid_fault.cxx - ) - -SET(MEDMEMTest_MeshAndMeshing_fault_SOURCES - MEDMEMTest_MeshAndMeshing_fault.cxx - ) - -SET(MEDMEMTest_Support_fault_SOURCES - MEDMEMTest_Support_fault.cxx - ) - -SET(MEDMEMTest_VtkFieldDriver_fault_SOURCES - MEDMEMTest_VtkFieldDriver_fault.cxx - ) - -SET(MEDMEMTest_VtkMeshDriver_fault_SOURCES - MEDMEMTest_VtkMeshDriver_fault.cxx - ) - -ADD_LIBRARY(MEDMEMCppTest SHARED ${MEDMEMCppTest_SOURCES}) -SET_TARGET_PROPERTIES(MEDMEMCppTest PROPERTIES COMPILE_FLAGS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${CPPUNIT_DEFINITIONS} ${PLATFORM_DEFINITIONS}") -TARGET_LINK_LIBRARIES(MEDMEMCppTest medmem ${CPPUNIT_LIBS}) - -SET(ALLMEDMEMCPP_TESTS TestMEDMEM MEDMEMTest_Array_fault MEDMEMTest_Connectivity_fault MEDMEMTest_Coordinate_fault MEDMEMTest_Family_fault MEDMEMTest_Field_fault MEDMEMTest_Grid_fault MEDMEMTest_MeshAndMeshing_fault MEDMEMTest_Support_fault MEDMEMTest_VtkFieldDriver_fault MEDMEMTest_VtkMeshDriver_fault) -FOREACH(MEDMEMCPP_TEST ${ALLMEDMEMCPP_TESTS}) - ADD_EXECUTABLE(${MEDMEMCPP_TEST} ${${MEDMEMCPP_TEST}_SOURCES}) - SET_TARGET_PROPERTIES(${MEDMEMCPP_TEST} PROPERTIES COMPILE_FLAGS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") - TARGET_LINK_LIBRARIES(${MEDMEMCPP_TEST} MEDMEMCppTest ${PLATFORM_LIBS}) -ENDFOREACH(MEDMEMCPP_TEST ${ALLMEDMEMCPP_TESTS}) - -INSTALL(TARGETS MEDMEMCppTest DESTINATION ${MED_salomelib_LIBS}) -INSTALL(TARGETS ${ALLMEDMEMCPP_TESTS} DESTINATION ${MED_salomebin_BINS}) -INSTALL(FILES testMEDMEM.py DESTINATION ${MED_salomebin_BINS}) -INSTALL(FILES MEDMEMTest.hxx MEDMEMCppTestExport.hxx DESTINATION ${MED_salomeinclude_HEADERS}) diff --git a/src/MEDMEMCppTest/MEDMEMCppTestExport.hxx b/src/MEDMEMCppTest/MEDMEMCppTestExport.hxx deleted file mode 100644 index 940092fcb..000000000 --- a/src/MEDMEMCppTest/MEDMEMCppTestExport.hxx +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _MEDMEMCPPTESTEXPORT_HXX_ -#define _MEDMEMCPPTESTEXPORT_HXX_ - -#ifdef WIN32 -# if defined MEDMEMCppTest_EXPORTS -# define MEDMEMCPPTEST_EXPORT __declspec( dllexport ) -# else -# define MEDMEMCPPTEST_EXPORT __declspec( dllimport ) -# endif -#else -# define MEDMEMCPPTEST_EXPORT -#endif - -#endif diff --git a/src/MEDMEMCppTest/MEDMEMTest.cxx b/src/MEDMEMCppTest/MEDMEMTest.cxx deleted file mode 100644 index cbfda1049..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest.cxx +++ /dev/null @@ -1,672 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_IndexCheckingPolicy.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Remapper.hxx" - -#include -#include -#include - -#ifdef WIN32 -#include -#endif - -using namespace std; - -// ============================================================================ -/*! - * Set up the environment - */ -// ============================================================================ -void MEDMEMTest::setUp() -{ -} - -// ============================================================================ -/*! - * - delete - */ -// ============================================================================ -void MEDMEMTest::tearDown() -{ -} - -/* -// #1: MEDMEM_Array.hxx \ -// #2: MEDMEM_ArrayConvert.hxx } MEDMEMTest_Array.cxx -// #3: MEDMEM_ArrayInterface.hxx (-) / -// #4: MEDMEM_AsciiFieldDriver.hxx } MEDMEMTest_AsciiFieldDriver.cxx -// #5: MEDMEM_CellModel.hxx } MEDMEMTest.cxx (-) -// #7: MEDMEM_Connectivity.hxx } MEDMEMTest_Connectivity.cxx -// #8: MEDMEM_Coordinate.hxx } MEDMEMTest_Coordinate.cxx -// #9: MEDMEM_DriverFactory.hxx } MEDMEMTest_DriverFactory.cxx -// #10: MEDMEM_DriversDef.hxx } MEDMEMTest.cxx (-) -// #11: MEDMEM_DriverTools.hxx } MEDMEMTest.cxx (-) -// #12: MEDMEM_Exception.hxx } MEDMEMTest_Exception.cxx -// #13: MEDMEM_Family.hxx } MEDMEMTest.cxx -// #14: MEDMEM_Field.hxx \ -// #15: MEDMEM_FieldConvert.hxx / MEDMEMTest_Field.cxx -// #16: MEDMEM_FieldForward.hxx } no methods to test -// #17: MEDMEM_Formulae.hxx } MEDMEMTest_Formulae.cxx -// #18: MEDMEM_GaussLocalization.hxx } MEDMEMTest_GaussLocalization.cxx -// #19: MEDMEM_GenDriver.hxx } abstract class; implemented methods are tested during its successors testing -// #20: MEDMEM_GibiMeshDriver.hxx } MEDMEMTest_GibiMeshDriver.cxx -// #21: MEDMEM_Grid.cxx } MEDMEMTest_Grid.cxx -// #22: MEDMEM_Group.cxx } MEDMEMTest_Group.cxx -// #23: MEDMEM_IndexCheckingPolicy.cxx } MEDMEMTest.cxx -// #24: MEDMEM_Init.cxx } MEDMEMTest.cxx -// #25: MEDMEM_InterlacingPolicy.hxx } MEDMEMTest.cxx (-) -// #26: MEDMEM_InterlacingTraits.hxx } MEDMEMTest.cxx (-) -// #28: MEDMEM_MedFieldDriver.hxx } MEDMEMTest_MedFieldDriver.cxx -// #34: MEDMEM_MEDMEMchampLire.hxx } MEDMEMTest.cxx (-) -// #35: MEDMEM_MEDMEMgaussEcr.hxx } MEDMEMTest.cxx (-) -// #36: MEDMEM_MEDMEMprofilEcr.hxx } MEDMEMTest.cxx (-) -// #37: MEDMEM_MedMeshDriver.hxx } MEDMEMTest_MedMeshDriver.cxx -// #40: MEDMEM_MedVersion.hxx } MEDMEMTest_MedVersion.cxx -// #41: MEDMEM_Mesh.hxx \ -// #42: MEDMEM_Meshing.hxx / MEDMEMTest_MeshAndMeshing.cxx -// #43: MEDMEM_ModulusArray.hxx } MEDMEMTest_ModulusArray.cxx -// #44: MEDMEM_nArray.hxx } MEDMEMTest_nArray.cxx -// #45: MEDMEM_PointerOf.hxx } MEDMEMTest_PointerOf.cxx -// #47: MEDMEM_PorflowMeshDriver.hxx } MEDMEMTest_PorflowMeshDriver.cxx -// #48: MEDMEM_RCBase.hxx } MEDMEMTest.cxx (-) -// #49: MEDMEM_SetInterlacingType.hxx } MEDMEMTest.cxx (-) -// #50: MEDMEM_SkyLineArray.hxx } MEDMEMTest_SkyLineArray.cxx -// #51: MEDMEM_STRING.hxx } MEDMEMTest.cxx -// #52: MEDMEM_Support.hxx } MEDMEMTest_Support.cxx -// #53: MEDMEM_Tags.hxx } MEDMEMTest.cxx (-) -// #54: MEDMEM_TopLevel.hxx } MEDMEMTest_TopLevel.cxx -// #55: MEDMEM_TypeMeshDriver.hxx } MEDMEMTest.cxx -// #56: MEDMEM_Unit.hxx } MEDMEMTest_Unit.cxx -// #57: MEDMEM_VtkFieldDriver.hxx } MEDMEMTest_VtkFieldDriver.cxx -// #58: MEDMEM_VtkMedDriver.hxx } MEDMEMTest_VtkMedDriver.cxx -// #59: MEDMEM_VtkMeshDriver.hxx } MEDMEMTest_VtkMeshDriver.cxx -// #60: MEDMEM_medimport_src.hxx } MEDMEMTest.cxx (-) -*/ - -/*! - * Check methods (4), defined in MEDMEM_IndexCheckingPolicy.hxx: - * class IndexCheckPolicy { - * (+) void checkMoreThanZero(const std::string & classname, int index) const; - * (+) void checkLessOrEqualThan(const std::string & classname, int max, int index) const; - * (+) void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const; - * (+) void checkEquality(const std::string & classname, int a, int b) const; - * } - * class NoIndexCheckPolicy { - * (+) void checkMoreThanZero(const string &classname, int index) const; - * (+) void checkLessOrEqualThan(const std::string & classname, int max, int index) const; - * (+) void checkInInclusiveRange(const std::string & classname, int min, int max, int index) const; - * (+) void checkEquality(const std::string & classname, int a, int b) const; - * } - */ -void MEDMEMTest::testIndexCheckingPolicy() -{ - MEDMEM::IndexCheckPolicy do_check; - MEDMEM::NoIndexCheckPolicy no_check; - - int min = 3; - int max = 10; - - string aClassName ("MEDMEMTest::testIndexCheckingPolicy"); - - // IndexCheckPolicy: throw, if index does not satisfy criteria - CPPUNIT_ASSERT_THROW(do_check.checkMoreThanZero(aClassName, -1), MEDMEM::MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(do_check.checkLessOrEqualThan(aClassName, max, 13), MEDMEM::MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(do_check.checkInInclusiveRange(aClassName, min, max, 1), MEDMEM::MEDEXCEPTION); - // checkEquality() check that values are not equal - CPPUNIT_ASSERT_THROW(do_check.checkEquality(aClassName, 21, 21), MEDMEM::MEDEXCEPTION); - - // NoIndexCheckPolicy: do not throw, if index does not satisfy criteria - CPPUNIT_ASSERT_NO_THROW(no_check.checkMoreThanZero(aClassName, -1)); - CPPUNIT_ASSERT_NO_THROW(no_check.checkLessOrEqualThan(aClassName, max, 13)); - CPPUNIT_ASSERT_NO_THROW(no_check.checkInInclusiveRange(aClassName, min, max, 1)); - CPPUNIT_ASSERT_NO_THROW(no_check.checkEquality(aClassName, 21, 21)); - - // IndexCheckPolicy: do not throw, if index satisfy criteria - CPPUNIT_ASSERT_NO_THROW(do_check.checkMoreThanZero(aClassName, 5)); - CPPUNIT_ASSERT_NO_THROW(do_check.checkLessOrEqualThan(aClassName, max, 7)); - CPPUNIT_ASSERT_NO_THROW(do_check.checkInInclusiveRange(aClassName, min, max, 6)); - CPPUNIT_ASSERT_NO_THROW(do_check.checkEquality(aClassName, 21, 28)); - - // NoIndexCheckPolicy: do not throw, if index satisfy criteria - CPPUNIT_ASSERT_NO_THROW(no_check.checkMoreThanZero(aClassName, 5)); - CPPUNIT_ASSERT_NO_THROW(no_check.checkLessOrEqualThan(aClassName, max, 7)); - CPPUNIT_ASSERT_NO_THROW(no_check.checkInInclusiveRange(aClassName, min, max, 6)); - CPPUNIT_ASSERT_NO_THROW(no_check.checkEquality(aClassName, 21, 28)); -} - -/*! - * Check initialization, done in MEDMEM_Init.cxx: - * (-) MEDMEM::INIT init; - */ -void MEDMEMTest::testInit() -{ - // We cannot check here effect of initialization, done in MEDMEM_Init.cxx, - // because environment variable, set there, is visible only in libmedmem.la - // and its child processes (if any). - - // Check effect of MEDMEM_Init.cxx - //char* traceKind = getenv("SALOME_trace"); - //CPPUNIT_ASSERT(traceKind); -} - -/*! - * Check methods (not in spec), defined in MEDMEM_InterlacingPolicy.hxx: - */ -//void MEDMEMTest::testInterlacingPolicy() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_InterlacingTraits.hxx: - */ -//void MEDMEMTest::testInterlacingTraits() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_MedFieldDriver.hxx: - */ -//void MEDMEMTest::testMedFieldDriver() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_MEDMEMchampLire.hxx: - */ -//void MEDMEMTest::testMEDMEMchampLire() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_MEDMEMgaussEcr.hxx: - */ -//void MEDMEMTest::testMEDMEMgaussEcr() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_MEDMEMprofilEcr.hxx: - */ -//void MEDMEMTest::testMEDMEMprofilEcr() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_MedMeshDriver.hxx: - */ -//void MEDMEMTest::testMedMeshDriver() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_RCBase.hxx: - * class RCBASE { - * (reference counter presently disconnected in C++) virtual void addReference() const = 0; - * (reference counter presently disconnected in C++) virtual void removeReference() const = 0; - * } - */ -//void MEDMEMTest::testRCBase() -//{ -// // nothing to test -//} - -/*! - * Check methods (not in spec), defined in MEDMEM_SetInterlacingType.hxx: - */ -//void MEDMEMTest::testSetInterlacingType() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (2), defined in MEDMEM_STRING.hxx: - * class STRING : public string { - * (+) STRING() - * (+) ~STRING() - * (+) operator const char * () const - * (+) template STRING(const T &valeur) - * (+) template STRING & operator<<(const T &valeur) - * } - */ -void MEDMEMTest::testSTRING() -{ - { - // empty constructor - MEDMEM::STRING medstr; - CPPUNIT_ASSERT(strcmp(medstr.c_str(), "") == 0); - - // template STRING & operator<<(const T &valeur) with T == char* - //medstr << "filling 1"; - medstr << "filling " << 1 << " !!!"; - CPPUNIT_ASSERT(strcmp(medstr.c_str(), "filling 1 !!!") == 0); - - // operator const char * () - CPPUNIT_ASSERT(strcmp((const char *)medstr, "filling 1 !!!") == 0); - CPPUNIT_ASSERT(strcmp( medstr, "filling 1 !!!") == 0); - } - - MEDMEM::MESH * aMesh1 = MEDMEMTest_createTestMesh(); - ostringstream ostr; - ostr << *aMesh1; - - { - // template STRING & operator<<(const T &valeur) with T == MEDMEM::MESH - MEDMEM::STRING medstr; - //medstr << "filling 1"; - medstr << *aMesh1; - CPPUNIT_ASSERT(strcmp(medstr, ostr.str().c_str()) == 0); - } - - { - // Constructor STRING(const T &valeur) with T == char* - //MEDMEM::STRING medstr("filling 2"); - MEDMEM::STRING medstr ("filling 2"); - CPPUNIT_ASSERT(strcmp(medstr.c_str(), "filling 2") == 0); - CPPUNIT_ASSERT(strcmp(medstr, "filling 2") == 0); - } - - { - // Constructor STRING(const T &valeur) with T == MEDMEM::MESH - MEDMEM::STRING medstr (*aMesh1); - CPPUNIT_ASSERT(strcmp(medstr, ostr.str().c_str()) == 0); - } - if(aMesh1) - aMesh1->removeReference(); -} - -/*! - * Check methods (not in spec), defined in MEDMEM_Tags.hxx: - */ -//void MEDMEMTest::testTags() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -/*! - * Check methods (15), defined in MEDMEM_TypeMeshDriver.hxx: - * class TYPE_MESH_DRIVER : public GENDRIVER { - * (-) TYPE_MESH_DRIVER(); - * (-) TYPE_MESH_DRIVER(const string & fileName, MESH * ptrMesh, med_mode_acces accessMode); - * (-) TYPE_MESH_DRIVER(const TYPE_MESH_DRIVER & driver); - * (-) virtual ~TYPE_MESH_DRIVER(); - * (-) void open() throw (MEDEXCEPTION); - * (-) void close() throw (MEDEXCEPTION); - * (-) virtual void write(void) const = 0; - * (-) virtual void read (void) = 0; - * (-) void setMeshName(const string & meshName); - * (-) string getMeshName() const; - * } - * class TYPE_MESH_RDONLY_DRIVER : public virtual TYPE_MESH_DRIVER { - * (-) TYPE_MESH_RDONLY_DRIVER(); - * (-) TYPE_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (-) TYPE_MESH_RDONLY_DRIVER(const TYPE_MESH_RDONLY_DRIVER & driver); - * (-) virtual ~TYPE_MESH_RDONLY_DRIVER(); - * (-) void write(void) const throw (MEDEXCEPTION); - * (-) void read (void) throw (MEDEXCEPTION); - * } - * class TYPE_MESH_WRONLY_DRIVER : public virtual TYPE_MESH_DRIVER { - * (-) TYPE_MESH_WRONLY_DRIVER(); - * (-) TYPE_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (-) TYPE_MESH_WRONLY_DRIVER(const TYPE_MESH_WRONLY_DRIVER & driver); - * (-) virtual ~TYPE_MESH_WRONLY_DRIVER(); - * (-) void write(void) const throw (MEDEXCEPTION); - * (-) void read (void) throw (MEDEXCEPTION); - * } - * class TYPE_MESH_RDWR_DRIVER : public TYPE_MESH_RDONLY_DRIVER, public TYPE_MESH_WRONLY_DRIVER { - * (-) TYPE_MESH_RDWR_DRIVER(); - * (-) TYPE_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh); - * (-) TYPE_MESH_RDWR_DRIVER(const TYPE_MESH_RDWR_DRIVER & driver); - * (-) ~TYPE_MESH_RDWR_DRIVER(); - * (-) void write(void) const throw (MEDEXCEPTION); - * (-) void read (void) throw (MEDEXCEPTION); - * } - */ -void MEDMEMTest::testTypeMeshDriver() -{ - CPPUNIT_FAIL("TYPE_MESH_DRIVER: not implemented"); -} - -/*! - * Check methods (not in spec), defined in MEDMEM_medimport_src.hxx: - */ -//void MEDMEMTest::testmedimport_src() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} - -//60 -//21 not in spec - -////////////////////////////////////// -// HELP METHODS, used in many tests // -////////////////////////////////////// - -/*! - * Create a mesh with certain filling - * .n4 - * | - * | - * n16,n12,n8.---------.n7,n11,n15 - * | | | - * | | | - * n5.----|----.----|----.n3 - * | | | - * | | | - * n17,n13,n9.---------.n10,n14,n18 - * | - * | - * .n6 - * - * .n19 (0,0,5) - * | - * | - * | - * | - * n16.--|-.----.n15 - * / |/ / - * . . . - * / /| / - * n17.----.----.n18 - * | - * | - * n12.--|-.----.n11 - * / |/ / - * . . . - * / /| / - * n13.----.----.n14 - * | - * | - * n8.--|-.----.n7 - * / |/ / - * . . . - * / /| / - * n9.----.----.n10 - * | .n4 (0,2,1) - * | / - * | . - * |/ - * n5.----.----.----.----.n3 (2,0,1) - * (-2,0,1) /n2 (0,0,1) - * . | - * / | - * .n6 | - * | - * | - * .n1 (0,0,0) - */ -MEDMEM::MESH * MEDMEMTest_createTestMesh () -{ - // MESH DATA - int SpaceDimension = 3; - - // coordinates - int NumberOfNodes = 19; - - string Names[3] = { "X","Y","Z" }; - string Units[3] = { "cm","cm","cm" }; - - double Coordinates[57] = { - 0.0, 0.0, 0.0, // n1 - 0.0, 0.0, 1.0, // n2 - 2.0, 0.0, 1.0, // n3 - 0.0, 2.0, 1.0, // n4 - -2.0, 0.0, 1.0, // n5 - 0.0, -2.0, 1.0, // n6 - 1.0, 1.0, 2.0, // n7 - -1.0, 1.0, 2.0, // n8 - -1.0, -1.0, 2.0, // n9 - 1.0, -1.0, 2.0, // n10 - 1.0, 1.0, 3.0, // n11 - -1.0, 1.0, 3.0, // n12 - -1.0, -1.0, 3.0, // n13 - 1.0, -1.0, 3.0, // n14 - 1.0, 1.0, 4.0, // n15 - -1.0, 1.0, 4.0, // n16 - -1.0, -1.0, 4.0, // n17 - 1.0, -1.0, 4.0, // n18 - 0.0, 0.0, 5.0 // n19 - }; - - // cells connectivities - const int NumberOfCellTypes = 3; - MED_EN::medGeometryElement CellTypes[NumberOfCellTypes] = - {MED_EN::MED_TETRA4, MED_EN::MED_PYRA5, MED_EN::MED_HEXA8}; - const int NumberOfCells[NumberOfCellTypes] = {12, 2, 2}; - - int ConnectivityTetra[12 * 4] = { - 1,2,3,6, - 1,2,4,3, - 1,2,5,4, - 1,2,6,5, - 2,7,4,3, - 2,8,5,4, - 2,9,6,5, - 2,10,3,6, - 2,7,3,10, - 2,8,4,7, - 2,9,5,8, - 2,10,6,9 - }; - - int ConnectivityPyra[2 * 5] = { - 7,8,9,10,2, - 15,18,17,16,19 - }; - - int ConnectivityHexa[2 * 8] = { - 11,12,13,14,7,8,9,10, - 15,16,17,18,11,12,13,14 - }; - - // faces connectivities - const int NumberOfFaceTypes = 2; - MED_EN::medGeometryElement FaceTypes[NumberOfFaceTypes] = {MED_EN::MED_TRIA3, MED_EN::MED_QUAD4}; - const int NumberOfFaces[NumberOfFaceTypes] = {4, 4}; - - int ConnectivityTria[4 * 3] = { - 1,4,3, - 1,5,4, - 1,6,5, - 1,3,6 - }; - - int ConnectivityQua[4 * 4] = { - 7,8,9,10, - 11,12,13,14, - 11,7,8,12, - 12,8,9,13 - }; - - - // CREATE THE MESH - MEDMEM::MESHING* myMeshing = new MEDMEM::MESHING; - - myMeshing->setName("meshing"); - - myMeshing->setCoordinates(SpaceDimension, NumberOfNodes, Coordinates, - "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - myMeshing->setCoordinatesNames(Names); - myMeshing->setCoordinatesUnits(Units); - - // define connectivities - myMeshing->setNumberOfTypes(NumberOfCellTypes, MED_EN::MED_CELL); - myMeshing->setTypes(CellTypes, MED_EN::MED_CELL); - myMeshing->setNumberOfElements(NumberOfCells, MED_EN::MED_CELL); - - myMeshing->setConnectivity(MED_EN::MED_CELL, MED_EN::MED_TETRA4, ConnectivityTetra ); - myMeshing->setConnectivity(MED_EN::MED_CELL, MED_EN::MED_PYRA5 , ConnectivityPyra ); - myMeshing->setConnectivity(MED_EN::MED_CELL, MED_EN::MED_HEXA8 , ConnectivityHexa ); - - myMeshing->setNumberOfTypes(NumberOfFaceTypes, MED_EN::MED_FACE); - myMeshing->setTypes(FaceTypes, MED_EN::MED_FACE); - myMeshing->setNumberOfElements(NumberOfFaces, MED_EN::MED_FACE); - - myMeshing->setConnectivity(MED_EN::MED_FACE, MED_EN::MED_TRIA3,ConnectivityTria); - myMeshing->setConnectivity(MED_EN::MED_FACE, MED_EN::MED_QUAD4,ConnectivityQua); - - // edges connectivities - // not yet implemented : if set, results are unpredictable. - - // groups of nodes - { - MEDMEM::GROUP *myGroup=new MEDMEM::GROUP; - myGroup->setName("SomeNodes"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_EN::MED_NODE); - myGroup->setNumberOfGeometricType(1); - MED_EN::medGeometryElement myTypes[1] = {MED_EN::MED_NONE}; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = {4}; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = {1,5}; - const int value[4] = {1,4,5,7}; - myGroup->setNumber(index,value); - myMeshing->addGroup(*myGroup); - myGroup->removeReference(); - } - { - MEDMEM::GROUP *myGroup=new MEDMEM::GROUP; - myGroup->setName("OtherNodes"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_EN::MED_NODE); - myGroup->setNumberOfGeometricType(1); - MED_EN::medGeometryElement myTypes[1] = {MED_EN::MED_NONE}; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = {3}; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = {1,4}; - const int value[3] = {2,3,6}; - myGroup->setNumber(index,value); - myMeshing->addGroup(*myGroup); - myGroup->removeReference(); - } - - // groups of cells - { - MEDMEM::GROUP *myGroup=new MEDMEM::GROUP; - myGroup->setName("SomeCells"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_EN::MED_CELL); - myGroup->setNumberOfGeometricType(3); - MED_EN::medGeometryElement myTypes[3] = {MED_EN::MED_TETRA4,MED_EN::MED_PYRA5,MED_EN::MED_HEXA8}; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[3] = {4,1,2}; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[3+1] = {1,5,6,8}; - const int value[4+1+2] = {2,7,8,12, 13, 15,16}; - myGroup->setNumber(index,value); - myMeshing->addGroup(*myGroup); - myGroup->removeReference(); - } - { - MEDMEM::GROUP *myGroup=new MEDMEM::GROUP; - myGroup->setName("OtherCells"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_EN::MED_CELL); - myGroup->setNumberOfGeometricType(2); - MED_EN::medGeometryElement myTypes[] = {MED_EN::MED_TETRA4,MED_EN::MED_PYRA5}; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[] = {4,1}; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[2+1] = {1,5,6}; - const int value[4+1] = {3,4,5,9, 14}; - myGroup->setNumber(index,value); - myMeshing->addGroup(*myGroup); - myGroup->removeReference(); - } - - // groups of faces - { - MEDMEM::GROUP *myGroup=new MEDMEM::GROUP; - myGroup->setName("SomeFaces"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_EN::MED_FACE); - myGroup->setNumberOfGeometricType(2); - MED_EN::medGeometryElement myTypes[2] = {MED_EN::MED_TRIA3,MED_EN::MED_QUAD4}; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[2] = {2,3}; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[2+1] = {1,3,6}; - const int value[2+3] = {2,4, 5,6,8}; - myGroup->setNumber(index,value); - myMeshing->addGroup(*myGroup); - myGroup->removeReference(); - } - { - MEDMEM::GROUP *myGroup=new MEDMEM::GROUP; - myGroup->setName("OtherFaces"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_EN::MED_FACE); - myGroup->setNumberOfGeometricType(1); - MED_EN::medGeometryElement myTypes[1] = {MED_EN::MED_TRIA3}; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = {2}; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = {1,3}; - const int value[2] = {1,3}; - myGroup->setNumber(index,value); - myMeshing->addGroup(*myGroup); - myGroup->removeReference(); - } - - return myMeshing; -} - -/*! - * Tool to remove temporary files. - * Allows automatique removal of temporary files in case of test failure. - */ -MEDMEMTest_TmpFilesRemover::~MEDMEMTest_TmpFilesRemover() -{ - set::iterator it = myTmpFiles.begin(); - for (; it != myTmpFiles.end(); it++) { -#ifdef WIN32 - //if (GetFileAttributes((*it).data()) & FILE_ATTRIBUTE_NORMAL) - if (GetFileAttributes((*it).data()) != INVALID_FILE_ATTRIBUTES) -#else - if (access((*it).data(), F_OK) == 0) -#endif - remove((*it).data()); - } - myTmpFiles.clear(); - //cout << "~MEDMEMTest_TmpFilesRemover()" << endl; -} - -bool MEDMEMTest_TmpFilesRemover::Register(const string theTmpFile) -{ - return (myTmpFiles.insert(theTmpFile)).second; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest.hxx b/src/MEDMEMCppTest/MEDMEMTest.hxx deleted file mode 100644 index 9d9bf4859..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest.hxx +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _MEDMEMTEST_HXX_ -#define _MEDMEMTEST_HXX_ - -#include "MEDMEMCppTestExport.hxx" -#include "MEDMEMTest_Utils.hxx" - -#include -#include "MEDMEM_Field.hxx" - -#include -#include -//#include -#include - -namespace MEDMEM { - class MESH; -} - -class MEDMEMCPPTEST_EXPORT MEDMEMTest : public CppUnit::TestFixture -{ - CPPUNIT_TEST_SUITE( MEDMEMTest ); - //0 - CPPUNIT_TEST( testArray ); - CPPUNIT_TEST( testArrayConvert ); - //CPPUNIT_TEST( testArrayInterface /* not in spec */ ); - CPPUNIT_TEST( testAsciiFieldDriver ); - //CPPUNIT_TEST( testCellModel /* not in spec */ ); - CPPUNIT_TEST( testConnectivity ); - CPPUNIT_TEST( testCoordinate ); - CPPUNIT_TEST( testDriverFactory ); - //CPPUNIT_TEST( testDriversDef /* not in spec */ ); - //10 - //CPPUNIT_TEST( testDriverTools /* not in spec */ ); - //CPPUNIT_TEST( testException /* not in spec */ ); - CPPUNIT_TEST( testFamily ); - CPPUNIT_TEST( testField ); - CPPUNIT_TEST( testFieldConvert ); - CPPUNIT_TEST( testFormulae ); - CPPUNIT_TEST( testGaussLocalization ); - CPPUNIT_TEST( testGibiMeshDriver ); - //20 - //CPPUNIT_TEST( testGrid ); - CPPUNIT_TEST( testGroup ); - CPPUNIT_TEST( testIndexCheckingPolicy ); - CPPUNIT_TEST( testInit /* cxx */ ); - //CPPUNIT_TEST( testInterlacingPolicy /* not in spec */ ); - //CPPUNIT_TEST( testInterlacingTraits /* not in spec */ ); - CPPUNIT_TEST( testMedFieldDriver ); - CPPUNIT_TEST( testReadFieldOnNodesAndCells ); - //CPPUNIT_TEST( testMedFieldDriver /* not in spec */ ); - CPPUNIT_TEST( testMedFileBrowser ); - //30 - //CPPUNIT_TEST( testMEDMEMchampLire /* not in spec */ ); - //CPPUNIT_TEST( testMEDMEMgaussEcr /* not in spec */ ); - //CPPUNIT_TEST( testMEDMEMprofilEcr /* not in spec */ ); - CPPUNIT_TEST( testMedMeshDriver ); - //CPPUNIT_TEST( testMedMeshDriver /* not in spec */ ); - CPPUNIT_TEST( testMedVersion ); - //40 - CPPUNIT_TEST( testMeshAndMeshing ); - CPPUNIT_TEST( testModulusArray ); - CPPUNIT_TEST( testnArray ); - CPPUNIT_TEST( testPartialDescendingConnectivity ); - CPPUNIT_TEST( testPointerOf ); - CPPUNIT_TEST( testPorflowMeshDriver ); - //CPPUNIT_TEST( testRCBase /* not in spec */ ); - //CPPUNIT_TEST( testSetInterlacingType /* not in spec */ ); - CPPUNIT_TEST( testSkyLineArray ); - //50 - CPPUNIT_TEST( testSTRING ); - CPPUNIT_TEST( testSupport ); - //CPPUNIT_TEST( testTags /* not in spec */ ); - //CPPUNIT_TEST( testTopLevel ); - // CPPUNIT_TEST( testTypeMeshDriver ); - CPPUNIT_TEST( testUnit ); - CPPUNIT_TEST( testVtkFieldDriver ); - CPPUNIT_TEST( testVtkMedDriver ); - CPPUNIT_TEST( testVtkMeshDriver ); - //CPPUNIT_TEST( testmedimport_src /* not in spec */ ); - //60 - CPPUNIT_TEST( testExtractor ); - CPPUNIT_TEST( testMeshFuse ); - CPPUNIT_TEST( testDesactivateFacesComputation ); // issue 0020411 - CPPUNIT_TEST( testGetVolumeAbs ); - CPPUNIT_TEST( test_remapper4 ); - CPPUNIT_TEST( test_remapper5 ); - CPPUNIT_TEST( test_remapper6 ); - CPPUNIT_TEST( test_remapper7 ); - CPPUNIT_TEST( test_remapper3DTo1D ); - CPPUNIT_TEST( test_RemapperP0P0 ); - CPPUNIT_TEST( test_RemapperP1P1 ); - CPPUNIT_TEST( test_RemapperP1P0 ); - CPPUNIT_TEST( test_RemapperP0P1 ); - CPPUNIT_TEST( testGetGaussPointsCoordinates ); - CPPUNIT_TEST_SUITE_END(); - -public: - void setUp(); - void tearDown(); - - void testArray(); - void testArrayConvert(); - //void testArrayInterface() /* not in spec */; - void testAsciiFieldDriver(); - //void testCellModel() /* not in spec */; - void testConnectivity(); - void testCoordinate(); - void testDriverFactory(); - //void testDriversDef() /* not in spec */; - //10 - //void testDriverTools() /* not in spec */; - void testException() /* not in spec */; - void testFamily(); - void testField(); - void testFieldConvert(); - void testFormulae(); - void testGaussLocalization(); - void testGibiMeshDriver(); - //20 - void testGrid(); - void testGroup(); - void testIndexCheckingPolicy(); - void testInit() /* cxx */; - //void testInterlacingPolicy() /* not in spec */; - //void testInterlacingTraits() /* not in spec */; - void testMedFieldDriver(); - void testReadFieldOnNodesAndCells(); - //void testMedFieldDriver /* not in spec */(); - void testMedFileBrowser(); - //30 - //void testMEDMEMchampLire() /* not in spec */; - //void testMEDMEMgaussEcr() /* not in spec */; - //void testMEDMEMprofilEcr() /* not in spec */; - void testMedMeshDriver(); - //void testMedMeshDriver() /* not in spec */; - void testMedVersion(); - //40 - void testMeshAndMeshing(); - void testModulusArray(); - void testnArray(); - void testPartialDescendingConnectivity(); - void testPointerOf(); - void testPorflowMeshDriver(); - //void testRCBase() /* not in spec */; - //void testSetInterlacingType /* IMED_MESH_RDWR_DRIVER(driver), not in spec */(); - void testSkyLineArray(); - //50 - void testSTRING(); - void testSupport(); - //void testTags() /* not in spec */; - void testTopLevel(); - void testTypeMeshDriver(); - void testUnit(); - void testVtkFieldDriver(); - void testVtkMedDriver(); - void testVtkMeshDriver(); - //void testmedimport_src() /* not in spec */; - //60 - void testExtractor(); - void testMeshFuse(); - void testDesactivateFacesComputation(); // issue 0020411 - void testGetVolumeAbs(); - void test_RemapperP0P0(); - void test_RemapperP1P1(); - void test_RemapperP1P0(); - void test_RemapperP0P1(); - void test_remapper4(); - void test_remapper5(); - void test_remapper6(); - void test_remapper7(); - void test_remapper3DTo1D(); - void testGetGaussPointsCoordinates(); - - //private: - void absField(MEDMEM::FIELD&); - private: - double sumAll(const std::vector< std::map >& matrix); -}; - -// to create a mesh with certain filling -MEDMEMCPPTEST_EXPORT MEDMEM::MESH * MEDMEMTest_createTestMesh(); - -// to automatically remove temporary files from disk -class MEDMEMCPPTEST_EXPORT MEDMEMTest_TmpFilesRemover -{ -public: - MEDMEMTest_TmpFilesRemover() {} - ~MEDMEMTest_TmpFilesRemover(); - bool Register(const std::string theTmpFile); - -private: - std::set myTmpFiles; -}; - -/*! - * Tool to print array to stream. - */ -template -void MEDMEMTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text) -{ - stream << text << ": {"; - if (length > 0) { - stream << array[0]; - for (int i = 1; i < length; i++) { - stream << ", " << array[i]; - } - } - stream << "}" << std::endl; -} - -#endif diff --git a/src/MEDMEMCppTest/MEDMEMTest_Array.cxx b/src/MEDMEMCppTest/MEDMEMTest_Array.cxx deleted file mode 100644 index 68c2b9121..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Array.cxx +++ /dev/null @@ -1,675 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_nArray.hxx" -#include "MEDMEM_ArrayConvert.hxx" -#include "MEDMEM_Array.hxx" -//#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_STRING.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #1,2,3: MEDMEMTest_Array.cxx -// Check methods from MEDMEM_Array.hxx, MEDMEM_ArrayConvert.hxx, MEDMEM_ArrayInterface.hxx - -/*! - * Check methods (20), defined in MEDMEM_Array.hxx: - * template class MEDARRAY { - * (+) inline MEDARRAY(); - * (+) inline ~MEDARRAY(); - * (+) MEDARRAY (const int ld_values, const int length_values, - * const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE); - * (+) MEDARRAY (T* values, const int ld_values, - * const int length_values, const MED_EN::medModeSwitch mode=MED_EN::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 int getLeadingValue() const; - * (+) inline int getLengthValue() const; - * (+) const T * get (const MED_EN::medModeSwitch mode); - * (+) const T * getRow (const int i); - * (+) const T * getColumn (const int j); - * (+) const T getIJ (const int i, const int j) const; - * (+) inline MED_EN::medModeSwitch getMode() const; - * (+) void set (const MED_EN::medModeSwitch mode,const T* value); - * (+) void setI (const int i, const T* value); - * (+) void setJ (const int j, const T* value); - * (+) void setIJ (const int i, const int j, const T value); - * (+) void calculateOther(); - * (+) bool isOtherCalculated() const {return (const T*)_valuesOther != NULL;} - * (+) void clearOtherMode(); - * } - * - * Use code of MEDMEM/tests/testUArray.cxx, - * MEDMEM/test_MEDMEM_Array.cxx - */ -void MEDMEMTest::testArray() -{ - int SpaceDimension = 3; - int NumberOfNodes = 4; - - //////////// - // TEST 1 // - //////////// - - /* ---------------------------------------------------------- */ - /* */ - /* INITIALISATION */ - /* */ - /* - constructeur new MEDARRAY(int,int,mode) */ - /* - get sur le pointeur MED_FULL_INTERLACE */ - /* - initialisation des valeurs (coordonnées ieme elt = I+1) */ - /* - get sur le pointeur MED_NO_INTERLACE */ - /* ---------------------------------------------------------- */ - - MEDARRAY * myArrayfull = - new MEDARRAY (SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE); - CPPUNIT_ASSERT(myArrayfull != NULL); - - const int * myValues = myArrayfull->get(MED_EN::MED_FULL_INTERLACE); - CPPUNIT_ASSERT(myValues != NULL); - - for (int i = 0; i < NumberOfNodes; i++) { - for (int k = 0; k < SpaceDimension; k++) { - myArrayfull->setIJ(i+1, k+1, i+1); - } - } - - const int * myOthers = myArrayfull->get(MED_EN::MED_NO_INTERLACE); - CPPUNIT_ASSERT(myOthers != NULL); - - MEDARRAY * myArrayno = new MEDARRAY(SpaceDimension, NumberOfNodes, MED_EN::MED_NO_INTERLACE); - CPPUNIT_ASSERT(myArrayno != NULL); - const int * myValuesno = myArrayno->get(MED_EN::MED_NO_INTERLACE); - CPPUNIT_ASSERT(myValuesno != NULL); - - for (int k = 0; k < SpaceDimension; k++) { - for (int i = 0; i < NumberOfNodes; i++) { - myArrayno->setIJ(i+1, k+1, k+1); - } - } - - const int * myOthersno = myArrayno->get(MED_EN::MED_FULL_INTERLACE); - CPPUNIT_ASSERT(myOthersno != NULL); - - /* ---------------------------------------------------------- */ - /* */ - /* Tests des Fonctions Set */ - /* */ - /* - setI sur l'element 1 avec des coordonnees a 100 */ - /* - setJ sur l'element 1 avec des coordonnees a 100 */ - /* - setIJ sur (1,2) avec une coordonnee = 1992 */ - /* - set avec l ensemble des coordonnes remises à i */ - /* ---------------------------------------------------------- */ - - int * myNewLine = new int[SpaceDimension]; - for (int i = 0; i < SpaceDimension; i++) - myNewLine[i] = myValues[i] * 100; - try - { - myArrayfull->setI(1, myNewLine); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception in myArrayfull->setI()"); - } - - delete [] myNewLine; - - int * myNewCol = new int[NumberOfNodes]; - for (int i = 0; i < NumberOfNodes; i++) - myNewCol[i] = 100; - try - { - myArrayno->setJ(1, myNewCol); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception in myArrayno->setJ()"); - } - - delete [] myNewCol; - - try - { - myArrayfull->setIJ(1, 2, 1992); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception in myArrayfull->setIJ()"); - } - - try - { - myArrayno->setIJ(1, 2, 1992); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception in myArrayno->setIJ()"); - } - - int * mynewvalues = new int [ NumberOfNodes*SpaceDimension ]; - for (int i = 0; i < NumberOfNodes*SpaceDimension; i++) { - mynewvalues[i] = i; - } - try - { - myArrayfull->set(MED_EN::MED_FULL_INTERLACE, mynewvalues); - myValues = myArrayfull->get(MED_EN::MED_FULL_INTERLACE); - myOthers = myArrayfull->get(MED_EN::MED_NO_INTERLACE); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myArrayno->set(MED_EN::MED_FULL_INTERLACE, mynewvalues); - myValuesno = myArrayfull->get(MED_EN::MED_FULL_INTERLACE); - myOthersno = NULL; - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - /* ---------------------------------------------------------- */ - /* */ - /* Tests des constructeurs */ - /* Tests des Fonctions Get */ - /* */ - /* ---------------------------------------------------------- */ - - // check sharing - MEDARRAY * myArrayShare = new MEDARRAY(*myArrayfull); - const int * sharevalues = myArrayShare->get(MED_EN::MED_FULL_INTERLACE); - const int * shareno = myArrayShare->get(MED_EN::MED_NO_INTERLACE); - - myArrayfull->setIJ(1, 2, 1993); - CPPUNIT_ASSERT(myArrayShare->getIJ(1,2) == 1993); - - myArrayShare->setIJ(1, 2, 1995); - CPPUNIT_ASSERT(myArrayfull->getIJ(1,2) == 1995); - - delete myArrayShare; - - // check no sharing - MEDARRAY * myArrayShare2 = new MEDARRAY(*myArrayfull, true); - sharevalues = myArrayShare2->get(MED_EN::MED_FULL_INTERLACE); - shareno = myArrayShare2->get(MED_EN::MED_NO_INTERLACE); - - myArrayfull->setIJ(1, 2, 18); - CPPUNIT_ASSERT(myArrayShare2->getIJ(1,2) == 1995); - myArrayShare2->setIJ(1, 2, 19); - CPPUNIT_ASSERT(myArrayfull->getIJ(1,2) == 18); - - // check myArrayno - myArrayno->set(MED_EN::MED_NO_INTERLACE, mynewvalues); - myArrayno->setIJ(2, 1, 1); - myValuesno = myArrayno->get(MED_EN::MED_NO_INTERLACE); - myOthersno = myArrayno->get(MED_EN::MED_FULL_INTERLACE); - - MEDARRAY * myArrayShare3 = new MEDARRAY(*myArrayno); - sharevalues = myArrayShare3->get(MED_EN::MED_FULL_INTERLACE); - shareno = myArrayShare3->get(MED_EN::MED_NO_INTERLACE); - - myArrayno->setIJ(1, 2, 1992); - CPPUNIT_ASSERT(myArrayShare3->getIJ(1,2) == 1992); - - myArrayShare3->setIJ(1, 2, 1995); - CPPUNIT_ASSERT(myArrayno->getIJ(1,2) == 1995); - - delete myArrayno; - delete [] mynewvalues; - delete myArrayfull; - delete myArrayShare2; - delete myArrayShare3; - - - //////////// - // TEST 2 // - //////////// - - MEDARRAY * myArray = - new MEDARRAY (SpaceDimension, NumberOfNodes, MED_EN::MED_FULL_INTERLACE); - - // - 1 1 1 - // - 2 2 2 - // - 3 3 3 - // - 4 4 4 - for (int i = 1; i <= NumberOfNodes; i++) - for (int j = 1; j <= SpaceDimension; j++) - myArray->setIJ(i, j, i); - - CPPUNIT_ASSERT(myArray->getLengthValue() == NumberOfNodes); - CPPUNIT_ASSERT(myArray->getLeadingValue() == SpaceDimension); - - int numberof = myArray->getLeadingValue(); // nb. of columns ~ space dimension - for (int i = 1; i <= myArray->getLengthValue(); i++) { - const int * node = myArray->getRow(i); - for (int j = 0; j < numberof; j++) { - CPPUNIT_ASSERT(node[j] == i); - } - } - - numberof = myArray->getLengthValue(); // nb. of rows ~ nb. of nodes - for (int i = 1; i <= myArray->getLeadingValue(); i++) { - const int * node = myArray->getColumn(i); - for (int j = 0; j < numberof; j++) { - CPPUNIT_ASSERT(node[j] == j + 1); - } - } - - numberof = myArray->getLeadingValue(); - for (int i = 1; i <= myArray->getLengthValue(); i++) { - for (int j = 1; j < numberof + 1; j++) { - CPPUNIT_ASSERT(myArray->getIJ(i,j) == i); - } - } - - numberof = myArray->getLeadingValue(); - int length = myArray->getLengthValue(); - const int * NoInterlaceArray = myArray->get(MED_EN::MED_NO_INTERLACE); - for (int i = 0; i < length; i++) { - for (int j = 0; j < numberof; j++) { - CPPUNIT_ASSERT(NoInterlaceArray[j*length+i] == i + 1); - } - } - - delete myArray; - - - //////////// - // TEST 3 // - //////////// - - // MEDARRAY (T* values, const int ld_values, - // const int length_values, const MED_EN::medModeSwitch mode=MED_EN::MED_FULL_INTERLACE, - // bool shallowCopy=false, bool ownershipOfValues=false); - - int ld = 7, nb = 4; - double rr = 13.0, h0 = 7.0; - double * aValues = new double [ld * nb]; - for (int nn = 0; nn < nb; nn++) { - aValues[nn*ld + 0] = nn; - aValues[nn*ld + 1] = rr * cos(nn * M_PI/4.); - aValues[nn*ld + 2] = rr * sin(nn * M_PI/4.); - aValues[nn*ld + 3] = h0 + nn; - aValues[nn*ld + 4] = 2.0 * rr * cos(nn * M_PI/4.); - aValues[nn*ld + 5] = 2.0 * rr * sin(nn * M_PI/4.); - aValues[nn*ld + 6] = h0 - nn; - } - - MEDARRAY * aSpiral = - new MEDARRAY (aValues, ld, nb, MED_EN::MED_FULL_INTERLACE, - /*shallowCopy=*/false, /*ownershipOfValues=*/false); - ///*shallowCopy=*/true, /*ownershipOfValues=*/true); - - if (aSpiral->isOtherCalculated()) - aSpiral->clearOtherMode(); - CPPUNIT_ASSERT(!aSpiral->isOtherCalculated()); - - CPPUNIT_ASSERT(aSpiral->getMode() == MED_EN::MED_FULL_INTERLACE); - aSpiral->calculateOther(); - CPPUNIT_ASSERT(aSpiral->getMode() == MED_EN::MED_FULL_INTERLACE); - CPPUNIT_ASSERT(aSpiral->getLeadingValue() == ld); - CPPUNIT_ASSERT(aSpiral->getLengthValue() == nb); - - //CPPUNIT_ASSERT_DOUBLES_EQUAL(expected, actual, delta); - double delta = 0.000001; - const double* comp5 = aSpiral->getColumn(5); - for (int nn = 0; nn < nb; nn++) { - const double* pnt = aSpiral->getRow(nn + 1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0 * rr * cos(nn * M_PI/4.), pnt[4], delta); - CPPUNIT_ASSERT_DOUBLES_EQUAL(comp5[nn], pnt[4], delta); - } - - // Check operator= and method shallowCopy() - double c7n3 = aSpiral->getIJ(3, 7); - MEDARRAY shc, cpy; - - //#ifdef ENABLE_FAULTS - // (BUG) MEDARRAY::shallowCopy() usage leads to memory leaks, - // because on attemp to free both arrays we have Segmentation Fault - - // EAP: It's misusage of shallowcopy - BUT what is a correct usage ??? - // TODO: check ownership of qrgument - //???skl shc.shallowCopy(*aSpiral); - - // hangs up - //MEDARRAY arr (10, 10); - //MEDARRAY shc; - //shc.shallowCopy(arr); - - // Segmentation fault - //MEDARRAY* arr = new MEDARRAY (10, 10); - //MEDARRAY* shc = new MEDARRAY (10, 10); - //shc->shallowCopy(*arr); - //delete arr; - //delete shc; - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("MEDARRAY::shallowCopy(): wrong memory management"); - //#endif - - cpy = *aSpiral; - - aSpiral->setIJ(3, 7, c7n3 * 2.0); - - //#ifdef ENABLE_FAULTS - //???skl CPPUNIT_ASSERT_DOUBLES_EQUAL(c7n3 * 2.0, shc.getIJ(3, 7), delta); - //#endif - - //CPPUNIT_ASSERT_DOUBLES_EQUAL(c7n3 * 2.0, cpy.getIJ(3, 7), delta); - CPPUNIT_ASSERT_DOUBLES_EQUAL(c7n3, cpy.getIJ(3, 7), delta); - -// #ifdef ENABLE_FORCED_FAILURES -// // Comments to deep copy constructor do not correspond to actual implementation -// CPPUNIT_FAIL("Comments to MEDARRAY deep copy constructor do not correspond to actual implementation"); -// #endif - - aSpiral->clearOtherMode(); - //CPPUNIT_ASSERT_THROW(MEDARRAY co (*aSpiral, true), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(MEDARRAY co (*aSpiral, true)); - - // invalid cases - //double arr3 [3] = {1., 2., 3.}; - double arr4 [4] = {1., 2., 3., 4.}; - double arr7 [7] = {1., 2., 3., 4., 5., 6., 7.}; - CPPUNIT_ASSERT_THROW(aSpiral->getRow(0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSpiral->getRow(nb + 1), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSpiral->getColumn(0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSpiral->getColumn(ld + 1), MEDEXCEPTION); - //CPPUNIT_ASSERT_THROW(aSpiral->set(MED_EN::MED_FULL_INTERLACE, NULL), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSpiral->setI(-1, arr7), MEDEXCEPTION); - //CPPUNIT_ASSERT_THROW(aSpiral->setI(1, NULL), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSpiral->setJ(-1, arr4), MEDEXCEPTION); - //CPPUNIT_ASSERT_THROW(aSpiral->setJ(1, NULL), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSpiral->setIJ(-1, -1, 13.), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSpiral->setIJ(1, 0, 13.), MEDEXCEPTION); - //CPPUNIT_ASSERT_THROW(aSpiral->setI(1, arr3), MEDEXCEPTION); // user must control itself - - delete aSpiral; - - // check empty array - - MEDARRAY anEmptyArray; - //CPPUNIT_ASSERT_NO_THROW(MEDARRAY anArr1 (anEmptyArray)); // INTERRUPTION - //CPPUNIT_ASSERT_NO_THROW(MEDARRAY anArr2 (anEmptyArray, false)); // fails - //CPPUNIT_ASSERT_NO_THROW(MEDARRAY anArr4 = anEmptyArray); // INTERRUPTION - //MEDARRAY anArr5; - //CPPUNIT_ASSERT_NO_THROW(anArr5.shallowCopy(anEmptyArray)); - - // invalid cases - CPPUNIT_ASSERT_THROW(anEmptyArray.get(MED_EN::MED_FULL_INTERLACE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.get(MED_EN::MED_NO_INTERLACE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.getRow(0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.getRow(5), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.getColumn(0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.getIJ(0, 0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.getIJ(1, 1), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(anEmptyArray.set(MED_EN::MED_FULL_INTERLACE, aValues)); - CPPUNIT_ASSERT_THROW(anEmptyArray.setI(1, aValues), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.setIJ(0, 0, 3.), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyArray.setIJ(1, 1, 3.), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(MEDARRAY bad (-1, 10), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(MEDARRAY bad (10, -1), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(MEDARRAY bad (-1, -1), MEDEXCEPTION); - - delete [] aValues; - - // construction with taking ownership of values - int ld1 = 7, nb1 = 4; - double * val1 = new double [ld * nb]; - for (int nn = 0; nn < nb1; nn++) { - for (int cc = 0; cc < ld1; cc++) { - val1[nn*ld1 + cc] = nn; - } - } - MEDARRAY * arr1 = - new MEDARRAY (val1, ld1, nb1, MED_EN::MED_FULL_INTERLACE, - /*shallowCopy=*/true, /*ownershipOfValues=*/true); - for (int nn = 1; nn <= nb1; nn++) { - for (int cc = 1; cc <= ld1; cc++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(nn - 1, arr1->getIJ(nn, cc), delta); - } - } - delete arr1; -} - -/*! - * Check methods (4), defined in MEDMEM_ArrayConvert.hxx: - * - * (+) Gauss NoInterlace->FullInterlace: - * template - * MEDMEM_Array * - * ArrayConvert(const MEDMEM_Array< T, NoInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0) - * - * (+) Gauss FullInterlace->NoInterlace: - * template - * MEDMEM_Array * - * ArrayConvert(const MEDMEM_Array< T, FullInterlaceGaussPolicy, CHECKING_POLICY > &array, T* values=0) - * - * (+) NoGauss FullInterlace->NoInterlace: - * template - * MEDMEM_Array * - * ArrayConvert(const MEDMEM_Array< T, FullInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0) - * - * (+) NoGauss NoInterlace->FullInterlace: - * template - * MEDMEM_Array * - * ArrayConvert(const MEDMEM_Array< T, NoInterlaceNoGaussPolicy, CHECKING_POLICY > &array, T* values=0) - * - * Use code of MEDMEM/test_MEDMEM_nArray.cxx - */ -void MEDMEMTest::testArrayConvert() -{ - // TEST n°1 : FullInterlaceNoGaussPolicy -> NoInterlaceNoGaussPolicy - - const int mdim = 2; - const int nbelem1 = 20; - - const double array1Ref[] = { 11 , 12 , 21 , 22 , 31 , 32 , 41 , 42 , 51 , 52 , - 61 , 62 , 71 , 72 , 81 , 82 , 91 , 92 , 101, 102, - 111, 112, 121, 122, 131, 132, 141, 142, 151, 152, - 161, 162, 171, 172, 181, 182, 191, 192, 201, 202 }; - - const double array2Ref[] = { 11 , 21 , 31 , 41 , 51 , 61 , 71 , 81 , 91 , 101, - 111, 121, 131, 141, 151, 161, 171, 181, 191, 201, - 12 , 22 , 32 , 42 , 52 , 62 , 72 , 82 , 92 , 102, - 112, 122, 132, 142, 152, 162, 172, 182, 192, 202 }; - - MEDMEM_Array myArray1 (mdim, nbelem1); - - for (int i = 1; i <= nbelem1; i++) - for (int j = 1; j <= mdim; j++) - myArray1.setIJ(i, j, i*10+j); - - const double * myArray1Ptr = myArray1.getPtr(); - for (int i = 0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT(myArray1Ptr[i] == array1Ref[i]); - - MEDMEM_Array * myArray1cin = ArrayConvert(myArray1); - myArray1Ptr = myArray1cin->getPtr(); - int elemno = 0; - for (int j = 1; j <= mdim; j++) { - for (int i = 1; i <= nbelem1; i++) { - CPPUNIT_ASSERT(myArray1cin->getIJ(i,j) == array2Ref[elemno]); - CPPUNIT_ASSERT(myArray1Ptr[elemno] == array2Ref[elemno]); - elemno++; - } - } - delete myArray1cin; - // TEST n°2 : NoInterlaceNoGaussPolicy -> FullInterlaceNoGaussPolicy - - MEDMEM_Array myArray2 (mdim, nbelem1); - - for (int i = 1; i <= nbelem1; i++) - for (int j = 1; j <= mdim; j++) - myArray2.setIJ(i, j, i*10+j); - - const double * myArray2Ptr = myArray2.getPtr(); - for (int i = 0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT(myArray2Ptr[i] == array2Ref[i]); - - MEDMEM_Array * myArray2cin = ArrayConvert(myArray2); - myArray2Ptr = myArray2cin->getPtr(); - elemno = 0; - for (int i = 1; i <= nbelem1; i++) { - for (int j = 1; j <= mdim; j++) { - CPPUNIT_ASSERT(myArray2cin->getIJ(i,j) == array1Ref[elemno]); - CPPUNIT_ASSERT(myArray2Ptr[elemno] == array1Ref[elemno]); - elemno++; - } - } - delete myArray2cin; - // TEST n°3 : FullInterlaceGaussPolicy -> NoInterlaceGaussPolicy - - const int nbelem2 = 5; - const int nbtypegeo = 2; - const int nbelgeoc[nbtypegeo+1] = {1,3,6}; - const int nbgaussgeo[nbtypegeo+1] = {-1,2,3}; - - const double * myArray3Ptr = 0; - const double array3Ref[] = { 1.11, 1.12, 1.21, 1.22, - 2.11, 2.12, 2.21, 2.22, - 13.11, 13.12, 13.21, 13.22, 13.31, 13.32, - 14.11, 14.12, 14.21, 14.22, 14.31, 14.32, - 15.11, 15.12, 15.21, 15.22, 15.31, 15.32 }; - - const double array4Ref[] = { 1.11, 1.21, 2.11, 2.21, - 13.11, 13.21, 13.31, 14.11, 14.21, 14.31, - 15.11, 15.21, 15.31, - 1.12, 1.22, 2.12, 2.22, - 13.12, 13.22, 13.32, 14.12, 14.22, 14.32, - 15.12, 15.22, 15.32 }; - - MEDMEM_Array myArray3 - (mdim, nbelem2, nbtypegeo, nbelgeoc, nbgaussgeo); - - elemno = 1; - for (int ntyp = 1; ntyp <= nbtypegeo; ntyp++) { - for (int i = 0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]); i++) { - for (int k = 1; k <= nbgaussgeo[ntyp]; k++) { - for (int j = 1; j <= mdim; j++) { - myArray3.setIJK(elemno, j, k, elemno+(ntyp-1)*10+0.1*k+0.01*j); - } - } - elemno++; - } - } - myArray3Ptr = myArray3.getPtr(); - for (int i = 0; i < myArray3.getArraySize(); i++) - CPPUNIT_ASSERT( abs(myArray3Ptr[i] - array3Ref[i]) < 1e-7); - - MEDMEM_Array * myArray3cin = ArrayConvert(myArray3); - myArray3Ptr = myArray3cin->getPtr(); - elemno = 0; - for (int j = 1; j <= mdim; j++) - for (int i = 1; i < nbelgeoc[nbtypegeo]; i++) - for (int k = 1; k <= myArray3cin->getNbGauss(i); k++) { - CPPUNIT_ASSERT( abs(myArray3cin->getIJK(i,j,k) - array4Ref[elemno]) < 1e-7); - CPPUNIT_ASSERT( abs(myArray3Ptr[elemno] - array4Ref[elemno]) < 1e-7); - elemno++; - } - delete myArray3cin; - // TEST n°4 : NoInterlaceGaussPolicy -> FullInterlaceGaussPolicy - - const double * myArray4Ptr = 0; - - MEDMEM_Array myArray4 - (mdim, nbelem2, nbtypegeo, nbelgeoc, nbgaussgeo); - - elemno = 1; - for (int ntyp = 1; ntyp <= nbtypegeo; ntyp++) { - for (int i = 0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]); i++) { - for (int k = 1; k <= nbgaussgeo[ntyp]; k++) { - for (int j = 1; j <= mdim; j++) { - myArray4.setIJK(elemno, j, k, elemno+(ntyp-1)*10+0.1*k+0.01*j); - } - } - elemno++; - } - } - myArray4Ptr = myArray4.getPtr(); - - for (int i = 0; i < myArray4.getArraySize(); i++) - CPPUNIT_ASSERT( abs(myArray4Ptr[i] - array4Ref[i]) < 1e-7); - - MEDMEM_Array * myArray4cin = ArrayConvert(myArray4); - myArray4Ptr = myArray4cin->getPtr(); - elemno = 0; - for (int i = 1; i < nbelgeoc[nbtypegeo]; i++) - for (int k = 1; k <= myArray4cin->getNbGauss(i); k++) - for (int j = 1; j <= mdim; j++) { - CPPUNIT_ASSERT( abs(myArray4cin->getIJK(i,j,k) - array3Ref[elemno]) < 1e-7); - CPPUNIT_ASSERT( abs(myArray4cin->getIJK(i,j,k) - myArray3.getIJK(i,j,k)) < 1e-7); - CPPUNIT_ASSERT( abs(myArray4Ptr[elemno] - array3Ref[elemno]) < 1e-7); - elemno++; - } - delete myArray4cin; -} -/*! - * Check methods (not in spec), defined in MEDMEM_ArrayInterface.hxx: - */ -//void MEDMEMTest::testArrayInterface() -//{ -// CPPUNIT_FAIL("Case Not Implemented (not in spec)"); -//} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Array_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_Array_fault.cxx deleted file mode 100644 index 942023ddd..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Array_fault.cxx +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Array.hxx" - -#include - -using namespace std; -using namespace MEDMEM; - -/*! - * Check method shallowCopy() - */ -int main (int argc, char** argv) -{ - int ld = 7, nb = 4; - double rr = 13.0, h0 = 7.0; - double * aValues = new double [ld * nb]; - for (int nn = 0; nn < nb; nn++) { - aValues[nn*ld + 0] = nn; - aValues[nn*ld + 1] = rr * cos(nn * M_PI/4.); - aValues[nn*ld + 2] = rr * sin(nn * M_PI/4.); - aValues[nn*ld + 3] = h0 + nn; - aValues[nn*ld + 4] = 2.0 * rr * cos(nn * M_PI/4.); - aValues[nn*ld + 5] = 2.0 * rr * sin(nn * M_PI/4.); - aValues[nn*ld + 6] = h0 - nn; - } - - MEDARRAY * aSpiral = - new MEDARRAY (aValues, ld, nb, MED_EN::MED_FULL_INTERLACE, - /*shallowCopy=*/false, /*ownershipOfValues=*/false); - - // Check method shallowCopy() - MEDARRAY shc; - - // (BUG) MEDARRAY::shallowCopy() usage leads to memory leaks, - // because on attempt to free both arrays we have Segmentation Fault - shc.shallowCopy(*aSpiral); - - delete aSpiral; - - // hangs up - //MEDARRAY arr (10, 10); - //MEDARRAY shc; - //shc.shallowCopy(arr); - - // Segmentation fault - //MEDARRAY* arr = new MEDARRAY (10, 10); - //MEDARRAY* shc = new MEDARRAY (10, 10); - //shc->shallowCopy(*arr); - //delete arr; - //delete shc; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_AsciiFieldDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_AsciiFieldDriver.cxx deleted file mode 100644 index 7d247e1b7..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_AsciiFieldDriver.cxx +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_AsciiFieldDriver.hxx" -#include "MEDMEM_STRING.hxx" - -#include - -#include -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #4: MEDMEM_AsciiFieldDriver.hxx } MEDMEMTest_AsciiFieldDriver.cxx - -/*! - * Check methods (8), defined in MEDMEM_AsciiFieldDriver.hxx: - * - * (+) template void fill(double *a, const double *b) - * (+) template bool compare(const double* a, const double* b) - * (+) template<> void fill<-1,0x3>(double *a, const double *b); - * (+) template<> bool compare<-1>(const double *a, const double *b); - * - * template - * class SDForSorting { - * (+) SDForSorting(const double *coords, const T* comp, int nbComponents); - * (+) SDForSorting(const SDForSorting& other); - * (+) ~SDForSorting(); - * (+) bool operator< (const SDForSorting& other) const; - * (+) void writeLine(ofstream& file) const; - * } - * - * template - * class ASCII_FIELD_DRIVER : public GENDRIVER { - * - * //MUST BE PRIVATE as there is no possibility to set _ptrField after this constructor usage - * (-) template ASCII_FIELD_DRIVER(); - * - * (+) template - * ASCII_FIELD_DRIVER(const string & fileName, FIELD * ptrField, - * MED_EN::med_sort_direc direction=MED_EN::ASCENDING, const char *priority=""); - * (+) ASCII_FIELD_DRIVER(const ASCII_FIELD_DRIVER& other); - * (+) void open() throw (MEDEXCEPTION); - * (+) void close(); - * (+) void read (void) throw (MEDEXCEPTION); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) GENDRIVER* copy() const; - * } - */ -void MEDMEMTest::testAsciiFieldDriver() -{ - // read a mesh from a MED file - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - string fieldname = "fieldcelldoublescalar"; - - string anyfile1 = makeTmpFile( "anyfile1" ); - string SDFfilename = makeTmpFile( "myfile" ); - ofstream aFile(SDFfilename.c_str()); - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(anyfile1); - aRemover.Register(SDFfilename); - - //Test SDForSorting class - { - double coord_1[10] = { 1.0, 2.0, - -1.0, 2.0, - 3.6, -8.7, - 10.0, -10.0, - 12.3, 9.3}; - - int comp_1[5] = {1, 3, 5, 7, 9}; - SDForSorting aSDF_1(coord_1, comp_1, 5); - - SDForSorting aSDFCpy_1 = SDForSorting(aSDF_1); - CPPUNIT_ASSERT_EQUAL(aSDFCpy_1 < aSDF_1, false); - CPPUNIT_ASSERT_NO_THROW(aSDF_1.writeLine(aFile)); - } - - // Why functions - // template<> void MEDMEM::fill<-1,0x3>(double *a, const double *b) - // and - // template<> bool MEDMEM::compare<-1>(const double *a, const double *b) - // declared in MEDMEM_AsciiFieldDriver.hxx, - // are implemented in MEDMEM_DriverFactory.cxx? - - // template void fill(double *a, const double *b) - { - // 0x3 = 110000 - double aa[3]; - double bb[3] = {1,2,3}; - - fill<2,198>(aa, bb); // ZYX // 11000110 // 012 - //MEDMEMTest_DumpArray(cout, aa, 3, "aa filled with ZYX"); - CPPUNIT_ASSERT_EQUAL(aa[0], bb[0]); - CPPUNIT_ASSERT_EQUAL(aa[1], bb[1]); - CPPUNIT_ASSERT_EQUAL(aa[2], bb[2]); - - fill<2,210>(aa, bb); // ZXY // 11010010 // 102 - //MEDMEMTest_DumpArray(cout, aa, 3, "aa filled with ZXY"); - CPPUNIT_ASSERT_EQUAL(aa[0], bb[1]); - CPPUNIT_ASSERT_EQUAL(aa[1], bb[0]); - CPPUNIT_ASSERT_EQUAL(aa[2], bb[2]); - - fill<2,228>(aa, bb); // XYZ // 11100100 // 210 - //MEDMEMTest_DumpArray(cout, aa, 3, "aa filled with XYZ"); - CPPUNIT_ASSERT_EQUAL(aa[0], bb[2]); - CPPUNIT_ASSERT_EQUAL(aa[1], bb[1]); - CPPUNIT_ASSERT_EQUAL(aa[2], bb[0]); - } - - // template bool compare(const double* a, const double* b) - { - { - // aa < bb - double aa[8] = {1,1,1,1,1,1,1,1}; - double bb[8] = {1,1,1,1,1,1,1,2}; - CPPUNIT_ASSERT(compare<7>(aa, bb)); - } - - { - // aa < bb - double aa[8] = {1,1,1,1,1,1,1,1}; - double bb[8] = {2,1,1,1,1,1,1,1}; - CPPUNIT_ASSERT(compare<7>(aa, bb)); - } - - { - // aa > bb - double aa[8] = {2,1,1,1,1,1,1,1}; - double bb[8] = {1,1,1,1,1,1,1,1}; - CPPUNIT_ASSERT(!compare<7>(aa, bb)); - } - - { - // aa == bb - double aa[8] = {1,1,1,1,1,1,1,1}; - double bb[8] = {1,1,1,1,1,1,1,1}; - CPPUNIT_ASSERT(!compare<7>(aa, bb)); - } - - { - // compare<-1> - double aa[8] = {2,1,1,1,1,1,1,1}; - double bb[8] = {1,1,1,1,1,1,1,1}; - CPPUNIT_ASSERT(!compare<-1>(aa, bb)); - } - } - - // Test ASCII_FIELD_DRIVER - FIELD * aField1 = new FIELD (MED_DRIVER, filename, fieldname); - const SUPPORT * aSupport = aField1->getSupport(); - MESH * aMesh = new MESH(MED_DRIVER, filename, aSupport->getMeshName()); - aSupport->setMesh(aMesh); - - // create an ASCII driver for a field - ASCII_FIELD_DRIVER * aDriver1 = - new ASCII_FIELD_DRIVER (anyfile1, aField1, MED_EN::ASCENDING, ""); - CPPUNIT_ASSERT(aDriver1); - - CPPUNIT_ASSERT(aDriver1->getFileName() == anyfile1); - CPPUNIT_ASSERT(aDriver1->getAccessMode() == MED_EN::WRONLY); - - // and write the field on disk - - // must throw because the file is not opened - - CPPUNIT_ASSERT_THROW(aDriver1->write(), MEDEXCEPTION); - - aDriver1->open(); - - // must throw because the file is opened - CPPUNIT_ASSERT_THROW(aDriver1->setFileName("anyfile2"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aDriver1->setFileName(anyfile1), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(aDriver1->open(), MEDEXCEPTION); - - - // must throw because it is a writeonly driver - CPPUNIT_ASSERT_THROW(aDriver1->read(), MEDEXCEPTION); - - aDriver1->write(); - aDriver1->close(); - - // must throw because the file is not opened - - CPPUNIT_ASSERT_THROW(aDriver1->write(), MEDEXCEPTION); - - //CPPUNIT_ASSERT_THROW(aDriver1->close(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aDriver1->close()); // do not make troubles to the user - - // check priority definition - int spaceDimension = aMesh->getSpaceDimension(); - if (spaceDimension == 3) { - // good - CPPUNIT_ASSERT_NO_THROW(ASCII_FIELD_DRIVER aDriver2 - ("anyfile2", aField1, MED_EN::ASCENDING, "XYZ")); - // too long - CPPUNIT_ASSERT_THROW(ASCII_FIELD_DRIVER aDriver3 - ("anyfile3", aField1, MED_EN::ASCENDING, "XYZX"), MEDEXCEPTION); - // too short - CPPUNIT_ASSERT_THROW(ASCII_FIELD_DRIVER aDriver4 - ("anyfile4", aField1, MED_EN::ASCENDING, "XY"), MEDEXCEPTION); - // invalid - CPPUNIT_ASSERT_THROW(ASCII_FIELD_DRIVER aDriver5 - ("anyfile5", aField1, MED_EN::ASCENDING, "ABC"), MEDEXCEPTION); - } - else if (spaceDimension == 2) { - // good - CPPUNIT_ASSERT_NO_THROW(ASCII_FIELD_DRIVER aDriver2 - ("anyfile2", aField1, MED_EN::ASCENDING, "XY")); - // too long - CPPUNIT_ASSERT_THROW(ASCII_FIELD_DRIVER aDriver3 - ("anyfile3", aField1, MED_EN::ASCENDING, "XYZ"), MEDEXCEPTION); - // too short - CPPUNIT_ASSERT_THROW(ASCII_FIELD_DRIVER aDriver4 - ("anyfile4", aField1, MED_EN::ASCENDING, "X"), MEDEXCEPTION); - // invalid - CPPUNIT_ASSERT_THROW(ASCII_FIELD_DRIVER aDriver5 - ("anyfile5", aField1, MED_EN::ASCENDING, "AB"), MEDEXCEPTION); - } - else { - CPPUNIT_FAIL("Cannot test ASCII_FIELD_DRIVER because file pointe.med" - " contains mesh of wrong dimension: must be 2 or 3"); - } - - //Copy constructor - ASCII_FIELD_DRIVER aDriver1_Cpy1 = ASCII_FIELD_DRIVER (*aDriver1); - - //Test copy() function - ASCII_FIELD_DRIVER *aDriver1_Cpy2 = (ASCII_FIELD_DRIVER*)aDriver1->copy(); - CPPUNIT_ASSERT(aDriver1_Cpy2); - delete aDriver1_Cpy2; - // free memory - delete aDriver1; - aField1->removeReference(); - aMesh->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Connectivity.cxx b/src/MEDMEMCppTest/MEDMEMTest_Connectivity.cxx deleted file mode 100644 index eaf6acc3b..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Connectivity.cxx +++ /dev/null @@ -1,1522 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #7: MEDMEM_Connectivity.hxx } MEDMEMTest_Connectivity.cxx - -/*! - * Check methods (56), defined in MEDMEM_Connectivity.hxx: - * class CONNECTIVITY { - * (+) friend ostream & operator<<(ostream &os, CONNECTIVITY &connectivity); - * (+) CONNECTIVITY (MED_EN::medEntityMesh Entity=MED_EN::MED_CELL); - * (+) CONNECTIVITY (int numberOfTypes, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL); - * (+) CONNECTIVITY (const CONNECTIVITY & m); - * (+) virtual ~CONNECTIVITY (); - * (+) void setConstituent (CONNECTIVITY * Constituent) throw (MEDEXCEPTION); - * (+) void setGeometricTypes (const MED_EN::medGeometryElement * Types, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setCount (const int * Count, const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setNodal (const int * Connectivity, - * const MED_EN::medEntityMesh Entity, - * const MED_EN::medGeometryElement Type, - * const int * PolyConnectivityIndex=0) throw (MEDEXCEPTION); - * (+) inline void setNumberOfNodes(int NumberOfNodes); - * (+) inline int getEntityDimension() const; - * (+) inline void setEntityDimension(int EntityDimension); - * ----------------------------------------------------------------------------------------------------- - * (+) inline bool existConnectivity (MED_EN::medConnectivity connectivityType, - * MED_EN::medEntityMesh Entity) const; - * (+) virtual void calculateConnectivity (MED_EN::medConnectivity connectivityType, - * MED_EN::medEntityMesh Entity); - * (?) virtual void updateFamily (const vector& myFamilies); - * - * (+) inline MED_EN::medEntityMesh getEntity() const; - * ----------------------------------------------------------------------------------------------------- - * (+) inline int getNumberOfTypes (MED_EN::medEntityMesh Entity) const; - * (+) inline const MED_EN::medGeometryElement * getGeometricTypes - * (MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - * (+) MED_EN::medGeometryElement getElementType (MED_EN::medEntityMesh Entity, int Number) const; - * (+) inline MED_EN::medGeometryElement getPolyTypeRelativeTo() const; - * ----------------------------------------------------------------------------------------------------- - * (+) virtual inline const int * getGlobalNumberingIndex - * (MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - * ----------------------------------------------------------------------------------------------------- - * (+) virtual const int * getConnectivity (MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type); - * (+) virtual int getConnectivityLength (MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type); - * (+) virtual const int * getConnectivityIndex (MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity); - * (+) int *getNodesOfPolyhedron(int polyhedronId, int& lgthOfTab) const; - * (+) int **getNodesPerFaceOfPolyhedron(int polyhedronId, int& nbOfFaces, - * int* & nbOfNodesPerFaces) const; - * ----------------------------------------------------------------------------------------------------- - * (+) const CELLMODEL & getType (MED_EN::medGeometryElement Type) const; - * (+) const CELLMODEL * getCellsTypes (MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - * (+) string * getCellTypeNames (MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - * (+) int getNumberOfNodesInType (MED_EN::medGeometryElement Type) const; - * (+) int getNumberOfSubCellInType (MED_EN::medGeometryElement Type) const; - * ----------------------------------------------------------------------------------------------------- - * (+) virtual int getNumberOf (MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const; - * ----------------------------------------------------------------------------------------------------- - * (+) virtual const int* getValue (MED_EN::medConnectivity TypeConnectivity, - * MED_EN::medGeometryElement Type); - * (+) virtual const int* getValueIndex (MED_EN::medConnectivity TypeConnectivity); - * ----------------------------------------------------------------------------------------------------- - * (+) virtual inline const int* getReverseConnectivity (MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) throw (MEDEXCEPTION); - * (+) virtual inline const int* getReverseConnectivityIndex (MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) throw (MEDEXCEPTION); - * (NOT YET IMPLEMENTED!!!) const int* getNeighbourhood() const; - * (+) void invertConnectivityForAFace(int faceId, const int *nodalConnForFace); - * ----------------------------------------------------------------------------------------------------- - * (+) bool deepCompare(const CONNECTIVITY& other) const; - * - * Use code of MEDMEM/test_copie_connectivity.cxx - * } - */ -static void checkConnectivity(CONNECTIVITY * myConnectivity, - int MeshDimension, int NumberOfNodes, - MED_EN::medEntityMesh Entity, - int NumberOfTypes) -{ - int entityDim = myConnectivity->getEntityDimension(); - CPPUNIT_ASSERT_EQUAL(MeshDimension, entityDim); - - int nodesNb = myConnectivity->getNumberOf(MED_EN::MED_NODE, MED_EN::MED_NONE); - CPPUNIT_ASSERT_EQUAL(NumberOfNodes, nodesNb); //? - - // MED_EN::MED_CELL - MED_EN::medEntityMesh entity = myConnectivity->getEntity(); - CPPUNIT_ASSERT_EQUAL(Entity, entity); - - int typesNb = myConnectivity->getNumberOfTypes(Entity); - CPPUNIT_ASSERT_EQUAL(NumberOfTypes, typesNb); - - const MED_EN::medGeometryElement * Types = myConnectivity->getGeometricTypes(Entity); - CPPUNIT_ASSERT( Types ); - - // TODO: implement some more checks - int NumberOfElements; - const int * connectivity; - const int * connectivity_index; - myConnectivity->calculateConnectivity(MED_EN::MED_DESCENDING, Entity); - try { - NumberOfElements = myConnectivity->getNumberOf(Entity, MED_EN::MED_ALL_ELEMENTS); - connectivity = myConnectivity->getConnectivity(MED_EN::MED_DESCENDING, Entity, - MED_EN::MED_ALL_ELEMENTS); - connectivity_index = myConnectivity->getConnectivityIndex(MED_EN::MED_DESCENDING, Entity); - } - catch (MEDEXCEPTION m) { - CPPUNIT_FAIL(m.what()); - } - - // Get constituent entity type and quantity - int NumberOfConstituents = 0; - string constituent; - MED_EN::medEntityMesh constituentEntity; - - if (MeshDimension == 3) { - constituent = "Face"; - constituentEntity = MED_EN::MED_FACE; - } - - if (MeshDimension == 2) { - constituent = "Edge"; - constituentEntity = MED_EN::MED_EDGE; - } - - if (MeshDimension == 1) { - MESSAGE_MED("ERROR : MeshDimension = 1 !"); - MESSAGE_MED("We could not see Reverse Descending Connectivity."); - return; - } - - myConnectivity->getReverseConnectivity(MED_EN::MED_DESCENDING, Entity); - myConnectivity->getReverseConnectivityIndex(MED_EN::MED_DESCENDING, Entity); - - NumberOfConstituents = myConnectivity->getNumberOf(constituentEntity, MED_EN::MED_ALL_ELEMENTS); - myConnectivity->getConnectivity(MED_EN::MED_NODAL, constituentEntity, MED_EN::MED_ALL_ELEMENTS); - myConnectivity->getConnectivityIndex(MED_EN::MED_NODAL, constituentEntity); -} - -///////////////////////////////////////// -// TEST 2: test_copie_connectivity.cxx // -///////////////////////////////////////// -static void checkCopyConnectivity() -{ - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - - //Construction d'un maillage - MESH * myMesh = new MESH; - myMesh->setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver (filename, myMesh); - myMeshDriver.setMeshName(meshname); - myMeshDriver.open(); - myMeshDriver.read(); //A partir d'ici la connectivité est construite - myMeshDriver.close(); - - int aMeshDimension = myMesh->getMeshDimension(); - int aNumberOfNodes = myMesh->getNumberOfNodes(); - - const CONNECTIVITY * myConnectivity0 = myMesh->getConnectivityptr(); - CONNECTIVITY * myConnectivity1 = const_cast(myConnectivity0); - - // DATA: - MED_EN::medEntityMesh anEntity0 = myConnectivity0->getEntity(); - - int nbOfTypes = myConnectivity0->getNumberOfTypes(anEntity0); - - checkConnectivity(myConnectivity1, aMeshDimension, aNumberOfNodes, anEntity0, nbOfTypes); - - ostringstream ostr1; - ostr1 << *myConnectivity1; - CPPUNIT_ASSERT(ostr1.str() != ""); - - // COPY - CONNECTIVITY * myConnectivity2 = new CONNECTIVITY(* myConnectivity0); - - // Compare - CPPUNIT_ASSERT(myConnectivity2->deepCompare(*myConnectivity0)); - - // Compare after deleting the initial connectivity - myMesh->removeReference(); - myMesh = NULL; - myConnectivity0 = NULL; - - MED_EN::medEntityMesh anEntity2 = myConnectivity2->getEntity(); - CPPUNIT_ASSERT_EQUAL(anEntity0, anEntity2); - - checkConnectivity(myConnectivity2, aMeshDimension, aNumberOfNodes, anEntity0, nbOfTypes); - - ostringstream ostr2; - ostr2 << *myConnectivity2; - CPPUNIT_ASSERT(ostr1.str() == ostr2.str()); - - // ONE MORE COPY - CONNECTIVITY * myConnectivity3 = new CONNECTIVITY(* myConnectivity2); - delete myConnectivity2; - - MED_EN::medEntityMesh anEntity3 = myConnectivity3->getEntity(); - CPPUNIT_ASSERT_EQUAL(anEntity0, anEntity3); - - checkConnectivity(myConnectivity3, aMeshDimension, aNumberOfNodes, anEntity0, nbOfTypes); - - ostringstream ostr3; - ostr3 << *myConnectivity3; - CPPUNIT_ASSERT_EQUAL(ostr1.str(), ostr3.str()); - - delete myConnectivity3; -} - -static void createOrCheck (CONNECTIVITY * theC, string msg, bool create = false) -{ - // Preconditions: Entity and NumberOfTypes - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, MED_EN::MED_CELL, theC->getEntity()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, theC->getNumberOfTypes(MED_EN::MED_CELL)); - - // EntityDimension - if (create) - // It would be good to set EntityDimension automatically for EDGEs and FACEs, - // and warn about not set EntityDimension for CELLs - // (or calculate it from given geometric types) - theC->setEntityDimension(3); - else - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, theC->getEntityDimension()); - - // NumberOfNodes - int nbNodes = 20; - - if (create) { - theC->setNumberOfNodes(nbNodes); - } - else { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nbNodes, theC->getNumberOf - (MED_EN::MED_NODE, MED_EN::MED_NONE)); - } - - // GeometricTypes - MED_EN::medGeometryElement aCellTypes[3] = {MED_EN::MED_PYRA5, MED_EN::MED_HEXA8,MED_EN::MED_POLYHEDRA}; - - // this variable is needed in check mode (!create) - // because of bug with getGlobalNumberingIndex() method (see below) - bool triaFirst = true; - - if (create) { - theC->setGeometricTypes(aCellTypes, MED_EN::MED_CELL); - CPPUNIT_ASSERT_THROW(theC->setGeometricTypes(aCellTypes, MED_EN::MED_NODE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setGeometricTypes(aCellTypes, MED_EN::MED_FACE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setGeometricTypes(aCellTypes, MED_EN::MED_EDGE), MEDEXCEPTION); - } - else { - // CELLS: theC - const MED_EN::medGeometryElement * aCellTypesBack = theC->getGeometricTypes(MED_EN::MED_CELL); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aCellTypes[0], aCellTypesBack[0]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aCellTypes[1], aCellTypesBack[1]); - - const CELLMODEL * aCellModels = theC->getCellsTypes(MED_EN::MED_CELL); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aCellTypes[0], aCellModels[0].getType()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aCellTypes[1], aCellModels[1].getType()); - - string * aCellTypesNames = theC->getCellTypeNames(MED_EN::MED_CELL); - CPPUNIT_ASSERT_MESSAGE(msg, aCellTypesNames[0] == "MED_PYRA5"); - CPPUNIT_ASSERT_MESSAGE(msg, aCellTypesNames[1] == "MED_HEXA8"); - delete [] aCellTypesNames; - - // FACES: theC->_constituent - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, theC->getNumberOfTypes(MED_EN::MED_FACE)); - const MED_EN::medGeometryElement * aFaceTypesBack = theC->getGeometricTypes(MED_EN::MED_FACE); - triaFirst = (aFaceTypesBack[0] == MED_EN::MED_TRIA3 && aFaceTypesBack[1] == MED_EN::MED_QUAD4); - CPPUNIT_ASSERT_MESSAGE(msg, triaFirst || (aFaceTypesBack[1] == MED_EN::MED_TRIA3 && - aFaceTypesBack[0] == MED_EN::MED_QUAD4)); - - const CELLMODEL * aFaceModels = theC->getCellsTypes(MED_EN::MED_FACE); - bool case1 = (aFaceModels[0].getType() == MED_EN::MED_TRIA3 && - aFaceModels[1].getType() == MED_EN::MED_QUAD4); - bool case2 = (aFaceModels[1].getType() == MED_EN::MED_TRIA3 && - aFaceModels[0].getType() == MED_EN::MED_QUAD4); - CPPUNIT_ASSERT_MESSAGE(msg, case1 || case2); - - string * aFaceTypesNames = theC->getCellTypeNames(MED_EN::MED_FACE); - CPPUNIT_ASSERT_MESSAGE(msg, - (aFaceTypesNames[0] == "MED_TRIA3" && aFaceTypesNames[1] == "MED_QUAD4") || - (aFaceTypesNames[1] == "MED_TRIA3" && aFaceTypesNames[0] == "MED_QUAD4")); - delete [] aFaceTypesNames; - // EDGES: theC->_constituent->_constituent - //CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, theC->getNumberOfTypes(MED_EN::MED_EDGE)); - //const MED_EN::medGeometryElement * anEdgeTypesBack = theC->getGeometricTypes(MED_EN::MED_EDGE); - //const CELLMODEL * anEdgeModels = theC->getCellsTypes(MED_EN::MED_EDGE); - - // invalid cases - CPPUNIT_ASSERT(!theC->getGeometricTypes(MED_EN::MED_NODE)); - CPPUNIT_ASSERT(!theC->getGeometricTypes(MED_EN::MED_ALL_ENTITIES)); - CPPUNIT_ASSERT_THROW(theC->getCellsTypes(MED_EN::MED_NODE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getCellTypeNames(MED_EN::MED_ALL_ENTITIES), MEDEXCEPTION); - } - - // 2 POLYHEDRA - const int nbPolyhedron = 2; - //const int nbPolyFaces = 14; // 13 unique - const int nbPolyNodes = 52 + 14 - 2; // = 64 - - int aPolyhedronIndex[nbPolyhedron + 1] = {1,33, 65}; - - int aPolyhedronNodalConnectivity[nbPolyNodes] = { - 11,15,19,20,17,13,-1, 11,13,14,-1, 14,13,17,18,-1, 18,17,20,-1, 11,14,15,-1, 15,14,18,19,-1, 19,18,20, - 11,13,17,20,19,15,-1, 11,12,13,-1, 13,12,16,17,-1, 17,16,20,-1, 11,15,12,-1, 12,15,19,16,-1, 16,19,20}; - - // .11 - // - // 13.---------.14 - // /|\ /| - // / | \ / | - // / | \ / | - // 12.---------.15 | - // | | | | - // | 17.-----|---.18 - // | / \ | / - // | / \ | / - // |/ \|/ - // 16.---------.19 - // - // .20 - - // Nodal Connectivity - int countCells[4] = {1, 3, 4, 6}; // 2 PYRA5 and 1 HEXA8 and 2 POLYHEDRA - int nodesCells_PYRA5[10] = {2,3,4,5,1, 6,7,8,9,10}; - int nodesCells_HEXA8[8] = {2,3,4,5, 6,7,8,9}; - const int nbClassicCells = countCells[2]-countCells[0]; - - // .1 - // - // 3.---------.4 - // /| /| - // / | / | - // / | / | - // 2.---------.5 | - // | | | | - // | 7.-----|---.8 - // | / | / - // | / | / - // |/ |/ - // 6.---------.9 - // - // .10 - - // cells index will be: {1, 6, 11, 19} - - if (create) { - theC->setCount(countCells, MED_EN::MED_CELL); - theC->setNodal(nodesCells_PYRA5, MED_EN::MED_CELL, MED_EN::MED_PYRA5); - theC->setNodal(nodesCells_HEXA8, MED_EN::MED_CELL, MED_EN::MED_HEXA8); - theC->setNodal(aPolyhedronNodalConnectivity, MED_CELL, MED_POLYHEDRA, aPolyhedronIndex); - - // Invalid cases - CPPUNIT_ASSERT_THROW(theC->setCount(countCells, MED_EN::MED_NODE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setCount(countCells, MED_EN::MED_EDGE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setCount(countCells, MED_EN::MED_FACE), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(theC->setNodal(nodesCells_PYRA5, MED_EN::MED_FACE, MED_EN::MED_PYRA5), MEDEXCEPTION); - } - else { - // CELLS(3D): theC - CPPUNIT_ASSERT_MESSAGE(msg, theC->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL)); - CPPUNIT_ASSERT_MESSAGE(msg, theC->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 2, theC->getNumberOf(MED_EN::MED_CELL, MED_EN::MED_PYRA5)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, theC->getNumberOf(MED_EN::MED_CELL, MED_EN::MED_HEXA8)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 2, theC->getNumberOf(MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 5, theC->getNumberOf(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS)); - - // sorted by geometric type (order is given by the typedef enum medGeometryElement) - const int * countCellsBack = theC->getGlobalNumberingIndex(MED_EN::MED_CELL); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, countCells[0], countCellsBack[0]); // 1: always - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, countCells[1], countCellsBack[1]); // 3: +2 PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, countCells[2], countCellsBack[2]); // 4: +1 HEXA8 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, countCells[3], countCellsBack[3]); // 6: +2 POLYHEDRA - - // nodal connectivity length - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 18+64, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 10, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_PYRA5)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 8, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_HEXA8)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 64, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_POLYHEDRA)); - - // nodal connectivity index - const int * connAllIndex = theC->getConnectivityIndex(MED_EN::MED_NODAL, MED_EN::MED_CELL); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, connAllIndex[0]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, connAllIndex[1]); // +5 nodes of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 11, connAllIndex[2]); // +5 nodes of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 19, connAllIndex[3]); // +8 nodes of HEXA8 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 19+32, connAllIndex[4]); // +32 nodes of POLYHEDRA - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 19+64, connAllIndex[5]); // +32 nodes of POLYHEDRA - - // nodal connectivity - const int * connAll = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS); - const int * connPYRA5 = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_PYRA5); - const int * connHEXA8 = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_HEXA8); - const int * connPOLYH = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_POLYHEDRA); - for (int i = 0; i < 10; i++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_PYRA5[i], connPYRA5[i]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_PYRA5[i], connAll[i]); - } - for (int i = 0; i < 8; i++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_HEXA8[i], connHEXA8[i]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_HEXA8[i], connAll[10 + i]); - } - for (int i = 0; i < 64; i++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aPolyhedronNodalConnectivity[i], connPOLYH[i]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aPolyhedronNodalConnectivity[i], connAll[18 + i]); - } - - // descending connectivity length - // 10 faces in 2 pyra - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 10, theC->getConnectivityLength - (MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_PYRA5)); - // 6 faces in 1 hexa - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, theC->getConnectivityLength - (MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_HEXA8)); - // 14 faces in 2 polyhedrons - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 14, theC->getConnectivityLength - (MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA)); - // 10 + 6 + 14 faces - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 30, theC->getConnectivityLength - (MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS)); - - // descending connectivity index - const int * descAllIndex = theC->getConnectivityIndex(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, descAllIndex[0]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, descAllIndex[1]); // +5 faces of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 11, descAllIndex[2]); // +5 faces of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 17, descAllIndex[3]); // +6 faces of HEXA8 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 24, descAllIndex[4]); // +7 faces of POLYHEDRA - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 31, descAllIndex[5]); // +7 faces of POLYHEDRA - - // descending connectivity - { - const int * descAll = theC->getConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS); - const int * descPYRA5 = theC->getConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL, - MED_EN::MED_PYRA5); - const int * descHEXA8 = theC->getConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL, - MED_EN::MED_HEXA8); - const int * descPOLYH = theC->getConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL, - MED_EN::MED_POLYHEDRA); - for (int i = 0; i < 10; i++) { - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(descPYRA5[i]) && labs(descPYRA5[i]) < 16); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, descAll[i], descPYRA5[i]); - } - for (int i = 0; i < 6; i++) { - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(descHEXA8[i]) && labs(descHEXA8[i]) < 16); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, descAll[10 + i], descHEXA8[i]); - } - for (int i = 0; i < 14; i++) { - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(descPOLYH[i]) && labs(descPOLYH[i]) < 31); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, descAll[16 + i], descPOLYH[i]); - } - } - - // FACES: theC->_constituent - CPPUNIT_ASSERT_MESSAGE(msg, theC->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE)); - //CPPUNIT_ASSERT_MESSAGE(msg, theC->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_FACE)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 8, theC->getNumberOf(MED_EN::MED_FACE, MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, theC->getNumberOf(MED_EN::MED_FACE, MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 13, theC->getNumberOf(MED_EN::MED_FACE, MED_EN::MED_POLYGON)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 27, theC->getNumberOf(MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS)); - - // sorted by geometric type - const int * countFacesBack = theC->getGlobalNumberingIndex(MED_EN::MED_FACE); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, countFacesBack[0]); // always - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 9, countFacesBack[1]); // +8 TRIA3 - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 15, countFacesBack[2]); // 1+8+6 - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 28, countFacesBack[3]); // 1+8+6+13 - - // nodal connectivity length // 8*3 + 6*4 + 46 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 48+46, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_FACE, - MED_EN::MED_ALL_ELEMENTS)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 24, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_FACE, - MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 24, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_FACE, - MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 46, theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_FACE, - MED_EN::MED_POLYGON)); - - // nodal connectivity index - const int * connFaceAllIndex = theC->getConnectivityIndex(MED_EN::MED_NODAL, MED_EN::MED_FACE); - { - CPPUNIT_ASSERT(triaFirst); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, connFaceAllIndex[0]); - int typeChangeIndex = 8; - int nbNodes1 = 3; - int nbNodes2 = 4; - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 25, connFaceAllIndex[typeChangeIndex]); // + 3*8 or 4*6 - for (int i = 1; i < 14; i++) { - if (i < typeChangeIndex) - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1 + i*nbNodes1, connFaceAllIndex[i]); - else - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 25 + (i-typeChangeIndex)*nbNodes2, connFaceAllIndex[i]); - } - // + 3*8 nodes of TRIA3 + 4*6 nodes of QUAD4 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 49, connFaceAllIndex[14]); - } - - // nodal connectivity - const int * connFaceAll = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE, - MED_EN::MED_ALL_ELEMENTS); - const int * connTRIA3 = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE, - MED_EN::MED_TRIA3); - const int * connQUAD4 = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE, - MED_EN::MED_QUAD4); - for (int i = 0; i < 24; i++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, connFaceAll[ i], connTRIA3[i]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, connFaceAll[24+i], connQUAD4[i]); - } - - // EDGES: theC->_constituent->_constituent - //CPPUNIT_ASSERT_MESSAGE(msg, theC->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_EDGE)); - - // Invalid cases - CPPUNIT_ASSERT_MESSAGE(msg, !theC->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_NODE)); - CPPUNIT_ASSERT_MESSAGE(msg, !theC->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_EDGE)); - CPPUNIT_ASSERT_MESSAGE(msg, !theC->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_NODE)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 0, theC->getNumberOf(MED_EN::MED_CELL, MED_EN::MED_TETRA4)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 0, theC->getNumberOf(MED_EN::MED_CELL, - MED_EN::MED_TETRA4)); - CPPUNIT_ASSERT_THROW(theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_TRIA3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getConnectivityLength(MED_EN::MED_DESCENDING, MED_EN::MED_CELL, - MED_EN::MED_NONE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getConnectivityLength(MED_EN::MED_NODAL, MED_EN::MED_CELL, - MED_EN::MED_POLYGON), MEDEXCEPTION); - } - - - if (create) { - } - else { - // CELLS(3D): theC - { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, theC->getNumberOfTypes(MED_EN::MED_CELL)); - - { - const MED_EN::medGeometryElement * aCellTypesBack = theC->getGeometricTypes(MED_EN::MED_CELL); - CPPUNIT_ASSERT_MESSAGE(msg, ((aCellTypesBack[0] == MED_EN::MED_PYRA5 && - aCellTypesBack[1] == MED_EN::MED_HEXA8) || - (aCellTypesBack[0] == MED_EN::MED_HEXA8 && - aCellTypesBack[1] == MED_EN::MED_PYRA5))); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, MED_EN::MED_POLYHEDRA, aCellTypesBack[2]); - } - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 2, theC->getNumberOf(MED_EN::MED_CELL, - MED_EN::MED_POLYHEDRA)); - //checking that 0 is returned if polygons are asked as cells instead of faces - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 0, theC->getNumberOf(MED_EN::MED_CELL, - MED_EN::MED_POLYGON)); - - - int nbCellAll = 5; // 2 (PYRA5) + 1 (HEXA8) + 2 (POLYHEDRA) - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nbCellAll, theC->getNumberOf - (MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS)); - - - // first PYRA5 {1,2,3,4,5} - { - int len; - const int * c1 = theC->getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_CELL, /*Number*/1, len); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 5, len); - for (int i = 0; i < len; i++) { - if (c1[i] < 1 || 5 < c1[i]) CPPUNIT_FAIL(msg); - } - } - - // first POLYHEDRA - { - int len; - const int* con = 0; - CPPUNIT_ASSERT_NO_THROW(con=theC->getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_CELL, /*Number*/4, len)); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 32, len); - for (int i = 0; i < len; i++) - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg,aPolyhedronNodalConnectivity[i],con[i]); - } - - // cells descending connectivity - for (int i = 1; i <= nbCellAll; i++) { - int len; - const int * ci = theC->getConnectivityOfAnElement - (MED_EN::MED_DESCENDING, MED_EN::MED_CELL, /*Number*/i, len); - - MED_EN::medGeometryElement aCurElemType = theC->getElementType(MED_EN::MED_CELL, i); - - if (i <= 3) { // nb.standard cells = 3 - // sign of connectivity array value means element direction - for (int j = 0; j < len; j++) { - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(ci[j]) && labs(ci[j]) <= 14); // nb.standard faces = 14 - } - } - else { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, MED_EN::MED_POLYHEDRA, aCurElemType); - for (int j = 0; j < len; j++) { - CPPUNIT_ASSERT_MESSAGE(msg, 14 < labs(ci[j]) && labs(ci[j]) <= 27); // nb.polygons = 13 - } - } - - switch (aCurElemType) { - case MED_EN::MED_PYRA5: CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 5, len); break; - case MED_EN::MED_HEXA8: CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, len); break; - case MED_EN::MED_POLYHEDRA: CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 7, len); break; - default: - CPPUNIT_FAIL(msg); // wrong element type - } - } - - // Polyhedron-specific methods - { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 2, theC->getNumberOf(MED_EN::MED_CELL, - MED_EN::MED_POLYHEDRA)); - - // getNodesOfPolyhedron - int lenPolyh1nodes, lenPolyh2nodes; // nb of unique nodes - int * polyh1nodes = theC->getNodesOfPolyhedron(/*polyhedronId*/3+1, lenPolyh1nodes); - int * polyh2nodes = theC->getNodesOfPolyhedron(/*polyhedronId*/3+2, lenPolyh2nodes); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 8, lenPolyh1nodes); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 8, lenPolyh2nodes); - - set polyh1nodesCheck; - set polyh2nodesCheck; - - polyh1nodesCheck.insert(11); - polyh1nodesCheck.insert(13); - polyh1nodesCheck.insert(14); - polyh1nodesCheck.insert(15); - polyh1nodesCheck.insert(17); - polyh1nodesCheck.insert(18); - polyh1nodesCheck.insert(19); - polyh1nodesCheck.insert(20); - - polyh2nodesCheck.insert(11); - polyh2nodesCheck.insert(12); - polyh2nodesCheck.insert(13); - polyh2nodesCheck.insert(15); - polyh2nodesCheck.insert(16); - polyh2nodesCheck.insert(17); - polyh2nodesCheck.insert(19); - polyh2nodesCheck.insert(20); - - for (int i = 0; i < 8; i++) { - CPPUNIT_ASSERT_MESSAGE(msg, polyh1nodesCheck.count(polyh1nodes[i])); - CPPUNIT_ASSERT_MESSAGE(msg, polyh2nodesCheck.count(polyh2nodes[i])); - } - delete [] polyh1nodes; - delete [] polyh2nodes; - - // getNodesPerFaceOfPolyhedron - int nbFaces1, nbFaces2; - int *nbNodes1, *nbNodes2; // len = nb.faces (7) - int ** polyh1nodesPerFace = - theC->getNodesPerFaceOfPolyhedron(/*polyhedronId*/3+1, nbFaces1, nbNodes1); - int ** polyh2nodesPerFace = - theC->getNodesPerFaceOfPolyhedron(/*polyhedronId*/3+2, nbFaces2, nbNodes2); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 7, nbFaces1); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 7, nbFaces2); - - int nbNodesCheck [7] = {6,3,4,3,3,4,3}; - int startNode1 = aPolyhedronIndex[0] - 1; - int startNode2 = aPolyhedronIndex[1] - 1; - for (int i = 0; i < 7; i++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nbNodesCheck[i], nbNodes1[i]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nbNodesCheck[i], nbNodes2[i]); - - for (int j = 0; j < nbNodesCheck[i]; j++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aPolyhedronNodalConnectivity[startNode1], - polyh1nodesPerFace[i][j]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, aPolyhedronNodalConnectivity[startNode2], - polyh2nodesPerFace[i][j]); - startNode1++; - startNode2++; - } - startNode1++; - startNode2++; - } - - delete [] nbNodes1; - delete [] nbNodes2; - delete [] polyh1nodesPerFace; - delete [] polyh2nodesPerFace; - - // invalid polyhedron Id - - int lenPolyh3nodes; - int nbFaces3; - int *nbNodes3; - - CPPUNIT_ASSERT_THROW(theC->getNodesOfPolyhedron(1, lenPolyh3nodes), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNodesOfPolyhedron(3+3, lenPolyh3nodes), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNodesPerFaceOfPolyhedron - (/*polyhedronId*/1, nbFaces3, nbNodes3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNodesPerFaceOfPolyhedron - (/*polyhedronId*/3+3, nbFaces3, nbNodes3), MEDEXCEPTION); - - - // Descending - - // PolyhedronIndex: array of size (NumberOfPolyhedron + 1) - const int* polyhDesceIndex = theC->getConnectivityIndex(MED_EN::MED_DESCENDING,MED_EN::MED_CELL); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, polyhDesceIndex[nbClassicCells+0]+7, polyhDesceIndex[nbClassicCells+1]); // +7 faces - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, polyhDesceIndex[nbClassicCells+1]+7, polyhDesceIndex[nbClassicCells+2]); // +7 faces - - // Polyhedron Descending Connectivity: array of size (NumberOfPolyhedronFaces) - const int* polyhDesceConn = theC->getConnectivity(MED_EN::MED_DESCENDING,MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA); - // 15,16,17,18,19,20,21, -15,22,23,24,25,26,27 - for (int i = 0; i < 14; i++) { - // nb. poly faces = 13, because one face is common for two polyhedra - // nb. standard faces < poly-face id <= 27 (27 = 14 + 13) - CPPUNIT_ASSERT_MESSAGE(msg, 14 < labs(polyhDesceConn[i]) && labs(polyhDesceConn[i]) <= 27); - } - } // Polyhedron-specific methods - - // Polygon-specific methods - { - // Invalid cases: no polygons for MED_CELL in theC - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 0, theC->getNumberOf(MED_EN::MED_CELL,MED_EN::MED_POLYGON)); - CPPUNIT_ASSERT_THROW(theC->getConnectivity(MED_EN::MED_DESCENDING, - MED_EN::MED_CELL,MED_EN::MED_POLYGON), MEDEXCEPTION); - } - } // CELLS: theC - - // FACES: theC->_constituent - { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, theC->getNumberOfTypes(MED_EN::MED_FACE)); - - const MED_EN::medGeometryElement * aFaceTypesBack = theC->getGeometricTypes(MED_EN::MED_FACE); - CPPUNIT_ASSERT_MESSAGE(msg, ((aFaceTypesBack[0] == MED_EN::MED_TRIA3 && - aFaceTypesBack[1] == MED_EN::MED_QUAD4) || - (aFaceTypesBack[0] == MED_EN::MED_QUAD4 && - aFaceTypesBack[1] == MED_EN::MED_TRIA3))); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, MED_EN::MED_POLYGON, aFaceTypesBack[2]); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 0, theC->getNumberOf - (MED_EN::MED_FACE, MED_EN::MED_POLYHEDRA)); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 13, theC->getNumberOf - (MED_EN::MED_FACE, MED_EN::MED_POLYGON)); - - int nbFaAll = 27; // 6 (QUAD4) + 8 (TRIA3) + 13 (POLYGON) - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nbFaAll, theC->getNumberOf - (MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS)); - - - bool isHexagon = false; - for (int i = 1; i <= nbFaAll; i++) { - int len; - const int * ci = theC->getConnectivityOfAnElement(MED_EN::MED_NODAL, - MED_EN::MED_FACE, /*Number*/i, len); - MED_EN::medGeometryElement aCurElemType = theC->getElementType(MED_EN::MED_FACE, i); - - if (len == 6) { - CPPUNIT_ASSERT_MESSAGE(msg, !isHexagon); // because only one hexagon must exist - - // check nodes {11,15,19,20,17,13} - int nij; - for (int j = 0; j < len; j++) { - nij = ci[j]; - CPPUNIT_ASSERT_MESSAGE(msg, nij==11 || nij==15 || nij==19 || nij==20 || nij==17 || nij==13); - } - - isHexagon = true; - } - - switch (aCurElemType) { - case MED_EN::MED_TRIA3: CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, len); break; - case MED_EN::MED_QUAD4: CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 4, len); break; - case MED_EN::MED_POLYGON: CPPUNIT_ASSERT_MESSAGE(msg, len == 3 || len == 4 || len == 6); break; - default: - CPPUNIT_FAIL(msg); // wrong element type - } - } - CPPUNIT_ASSERT_MESSAGE(msg, isHexagon); // hexagon must exist - - // Polygon-specific methods - { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 13, theC->getNumberOf(MED_EN::MED_FACE,MED_EN::MED_POLYGON)); - - const int * pgIndx = theC->getConnectivityIndex(MED_EN::MED_NODAL, MED_EN::MED_FACE) + 8+6; - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 46, pgIndx[13]-pgIndx[0]); - - const int * pgConn = theC->getConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS); - - // face # 1: 11 15 19 20 17 13 - // face # 2: 11 13 14 - // face # 3: 14 13 17 18 - // face # 4: 18 17 20 - // face # 5: 11 14 15 - // face # 6: 15 14 18 19 - // face # 7: 19 18 20 - // face # 8: 11 12 13 - // face # 9: 13 12 16 17 - // face # 10: 17 16 20 - // face # 11: 11 15 12 - // face # 12: 12 15 19 16 - // face # 13: 16 19 20 - - for (int i = 0; i < 13; i++) { - int startNode = pgIndx[i]; - int finishNode = pgIndx[i+1]; - // check nodes uniqueness inside one polygon - set curNodes; - for (int j = startNode; j < finishNode; j++) { - CPPUNIT_ASSERT_MESSAGE(msg, (curNodes.insert(pgConn[j - 1])).second); - } - } - } - } // FACES: theC->_constituent - - // EDGES: theC->_constituent->_constituent - //CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 2, theC->getNumberOfTypes(MED_EN::MED_EDGE)); - } - - if (create) { - // force _constituent computation - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, theC->getNumberOfTypes(MED_EN::MED_FACE)); - - - //N-2 Connectivity not supported in MEDMEM - //CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, theC->getNumberOfTypes(MED_EN::MED_EDGE)); - - } - else { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, MED_EN::MED_POLYHEDRA, theC->getPolyTypeRelativeTo()); - - // The following methods are not recursive, i.e. they return types - // of this connectivity, but do not return types of _constituent. - // And these methods DO work with poly-types. - - // getType - const CELLMODEL & aPYRA5_type = theC->getType(MED_EN::MED_PYRA5); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, MED_EN::MED_PYRA5, aPYRA5_type.getType()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 5, aPYRA5_type.getNumberOfVertexes()); - - const CELLMODEL & aHEXA8_type = theC->getType(MED_EN::MED_HEXA8); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 8, aHEXA8_type.getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, aHEXA8_type.getDimension()); - // nb. of sub-faces (nb. of constituents with dimension = 3 - 1) - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, aHEXA8_type.getNumberOfConstituents(1)); - - const CELLMODEL & aPOLYH_type = theC->getType(MED_EN::MED_POLYHEDRA); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 0, aPOLYH_type.getNumberOfNodes()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 3, aPOLYH_type.getDimension()); - - CPPUNIT_ASSERT_THROW(theC->getType(MED_EN::MED_TRIA3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getType(MED_EN::MED_POLYGON), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getType(MED_EN::MED_NONE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getType(MED_EN::MED_ALL_ELEMENTS), MEDEXCEPTION); - - // getNumberOfNodesInType - int nbNodesInPYRA5 = theC->getNumberOfNodesInType(MED_EN::MED_PYRA5); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 5, nbNodesInPYRA5); - - CPPUNIT_ASSERT_THROW(theC->getNumberOfNodesInType(MED_EN::MED_TRIA3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNumberOfNodesInType(MED_EN::MED_POLYGON), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNumberOfNodesInType(MED_EN::MED_NONE), MEDEXCEPTION); - - // getNumberOfSubCellInType - int nbFacesInHEXA8 = theC->getNumberOfSubCellInType(MED_EN::MED_HEXA8); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, nbFacesInHEXA8); - - int nbFacesInPOLYH = theC->getNumberOfSubCellInType(MED_EN::MED_POLYHEDRA); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 0, nbFacesInPOLYH); - - CPPUNIT_ASSERT_THROW(theC->getNumberOfSubCellInType(MED_EN::MED_QUAD4), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNumberOfSubCellInType(MED_EN::MED_ALL_ELEMENTS), MEDEXCEPTION); - - // getValueIndex - const int* nodalIndex = theC->getValueIndex(MED_EN::MED_NODAL); - const int* desceIndex = theC->getValueIndex(MED_EN::MED_DESCENDING); - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, nodalIndex[0]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, nodalIndex[1]); // +5 nodes of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 11, nodalIndex[2]); // +5 nodes of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 19, nodalIndex[3]); // +8 nodes of HEXA8 - - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 1, desceIndex[0]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 6, desceIndex[1]); // +5 faces of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 11, desceIndex[2]); // +5 faces of PYRA5 - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 17, desceIndex[3]); // +6 faces of HEXA8 - - // getValue - const int* nodalValue = theC->getValue(MED_EN::MED_NODAL, MED_EN::MED_ALL_ELEMENTS); - const int* nodalPYRA5 = theC->getValue(MED_EN::MED_NODAL, MED_EN::MED_PYRA5); - const int* nodalHEXA8 = theC->getValue(MED_EN::MED_NODAL, MED_EN::MED_HEXA8); - - for (int i = 0; i < 10; i++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_PYRA5[i], nodalPYRA5[i]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_PYRA5[i], nodalValue[i]); - } - for (int i = 0; i < 8; i++) { - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_HEXA8[i], nodalHEXA8[i]); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, nodesCells_HEXA8[i], nodalValue[10 + i]); - } - - const int* desceValue = theC->getValue(MED_EN::MED_DESCENDING, MED_EN::MED_ALL_ELEMENTS); - const int* descePYRA5 = theC->getValue(MED_EN::MED_DESCENDING, MED_EN::MED_PYRA5); - const int* desceHEXA8 = theC->getValue(MED_EN::MED_DESCENDING, MED_EN::MED_HEXA8); - - for (int i = 0; i < 10; i++) { - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(descePYRA5[i]) && labs(descePYRA5[i]) < 16); - - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(desceValue[i]) && labs(desceValue[i]) < 16); - } - for (int i = 0; i < 6; i++) { - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(desceHEXA8[i]) && labs(desceHEXA8[i]) < 16); - CPPUNIT_ASSERT_MESSAGE(msg, 0 < labs(desceValue[10 + i]) && labs(desceValue[10 + i]) < 16); - } - - CPPUNIT_ASSERT_THROW(theC->getValue(MED_EN::MED_NODAL, MED_EN::MED_QUAD4), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getValue(MED_EN::MED_NODAL, MED_EN::MED_POLYGON), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getValue(MED_EN::MED_DESCENDING, MED_EN::MED_NONE), MEDEXCEPTION); - } -} - -void MEDMEMTest::testConnectivity() -{ - ////////////////////////////////////////////// - // TEST 1: test_MEDMEM_PolyConnectivity.cxx // - ////////////////////////////////////////////// - CONNECTIVITY myNodalConnectivity(1); // one type - myNodalConnectivity.setEntityDimension(3); - - MED_EN::medGeometryElement types[] = { MED_EN::MED_POLYHEDRA }; - - //POLYHEDRON - const int NumberOfPolyhedron = 2; - int PolyhedronIndex[NumberOfPolyhedron+1] = {1,47,91}; - - //Nodal - const int NumberOfFaces = 19; - int PolyhedronNodalConnectivity[] ={1, 2, 3, 4, 5, 6, -1,// Polyhedron 1 - 1, 7, 8, 2, -1, - 2, 8, 9, 3, -1, - 4, 3, 9, 10, -1, - 5, 4, 10, 11, -1, - 6, 5, 11, 12, -1, - 1, 6, 12, 7, -1, - 7, 12, 8, -1, - 10, 9, 8, 12, 11, - - 13, 14, 15, 3, 2, -1,// Polyhedron 2 - 13, 2, 8, 16, -1, - 14, 13, 16, 17, -1, - 15, 14, 17, -1, - 15, 17, 18, -1, - 15, 18, 9, -1, - 3, 15, 9, -1, - 2, 3, 9, 8, -1, - 8, 9, 17, 16, -1, - 9, 18, 17 }; - - const int count[] = { 1, 1+NumberOfPolyhedron }; - myNodalConnectivity.setGeometricTypes( &types[0], MED_EN::MED_CELL ); - myNodalConnectivity.setCount( count, MED_EN::MED_CELL ); - myNodalConnectivity.setNodal( PolyhedronNodalConnectivity, MED_EN::MED_CELL, - MED_EN::MED_POLYHEDRA, PolyhedronIndex); - - myNodalConnectivity.setNumberOfNodes(777); - CPPUNIT_ASSERT_EQUAL(777, myNodalConnectivity.getNumberOf - (MED_EN::MED_NODE, MED_EN::MED_NONE)); -// // Throws because _constituent is not calculated -// CPPUNIT_ASSERT_THROW(myNodalConnectivity.getNumberOf -// (MED_EN::MED_FACE, MED_EN::MED_NONE), MEDEXCEPTION); - -// // Returns zero, because EntityDimension is not set -// CPPUNIT_ASSERT_EQUAL(0, myNodalConnectivity.getNumberOf -// (MED_EN::MED_CELL, MED_EN::MED_POLYGON)); -// CPPUNIT_ASSERT_EQUAL(0, myNodalConnectivity.getNumberOf -// (MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA)); - - // Throws because entity must differ from MED_NONE and MED_ALL_ELEMENTS - CPPUNIT_ASSERT_THROW(myNodalConnectivity.getNumberOfNodesInType(MED_EN::MED_NONE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(myNodalConnectivity.getNumberOfNodesInType(MED_EN::MED_ALL_ELEMENTS), MEDEXCEPTION); - - // Throws because types are not defined - CPPUNIT_ASSERT_THROW(myNodalConnectivity.getNumberOfNodesInType(MED_EN::MED_ALL_ELEMENTS), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(myNodalConnectivity.getNumberOfNodesInType(MED_EN::MED_POLYGON), MEDEXCEPTION); - - // does not throw any more exception because - // it is now possible to work on meshes with only polyhedric elements - CPPUNIT_ASSERT_NO_THROW(myNodalConnectivity.calculateConnectivity (MED_EN::MED_DESCENDING, - MED_EN::MED_CELL)); - - // existPolygonsConnectivity - CPPUNIT_ASSERT(myNodalConnectivity.existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE)); - CPPUNIT_ASSERT(!myNodalConnectivity.existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_FACE)); - - // existPolyhedronConnectivity - CPPUNIT_ASSERT(myNodalConnectivity.existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL)); - CPPUNIT_ASSERT(myNodalConnectivity.existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL)); - - - // setEntityDimension - // it contains cells of different dimension (2D and 3D) - // We set here EntityDimension for good work of below methods - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_POLYHEDRA, myNodalConnectivity.getPolyTypeRelativeTo()); - - // Poly types - CPPUNIT_ASSERT_EQUAL(1, myNodalConnectivity.getNumberOfTypes(MED_EN::MED_CELL)); - - CPPUNIT_ASSERT_EQUAL(1, myNodalConnectivity.getNumberOfTypes(MED_EN::MED_FACE)); - - // getNumberOf - CPPUNIT_ASSERT_EQUAL(NumberOfPolyhedron, myNodalConnectivity.getNumberOf - (MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA)); - CPPUNIT_ASSERT_EQUAL(0, myNodalConnectivity.getNumberOf - (MED_EN::MED_CELL, MED_EN::MED_POLYGON)); - //Minus 1 because 2,3,8,9 is a given twice in connectivity - CPPUNIT_ASSERT_EQUAL(NumberOfFaces-1, myNodalConnectivity.getNumberOf (MED_EN::MED_FACE, - MED_EN::MED_POLYGON)); - - // getConnectivityOfAnElement - { - //first polyhedron - const int *ph1, *ph2; - int len_ph1, len_ph2; - CPPUNIT_ASSERT_NO_THROW(ph1 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_CELL, /*Number*/1, len_ph1)); - CPPUNIT_ASSERT_EQUAL( PolyhedronIndex[1]-PolyhedronIndex[0], len_ph1 ); - CPPUNIT_ASSERT( vector( PolyhedronNodalConnectivity, PolyhedronNodalConnectivity + len_ph1) == - vector( ph1, ph1+len_ph1 )); - - //second polyhedron - CPPUNIT_ASSERT_NO_THROW(ph2 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_CELL, /*Number*/2, len_ph2)); - CPPUNIT_ASSERT_EQUAL( PolyhedronIndex[2]-PolyhedronIndex[1], len_ph2 ); - CPPUNIT_ASSERT( vector( PolyhedronNodalConnectivity + len_ph1, PolyhedronNodalConnectivity + len_ph1 + len_ph2) == - vector( ph2, ph2+len_ph2 )); - - // MED_DESCENDING - //first polyhedron - CPPUNIT_ASSERT_NO_THROW(ph1 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_DESCENDING, MED_EN::MED_CELL, /*Number*/1, len_ph1)); - CPPUNIT_ASSERT_EQUAL( 9, len_ph1 ); - const int faces1[] = { 1,2,3,4,5,6,7,8,9 }; - CPPUNIT_ASSERT( vector( faces1, faces1 + len_ph1 ) == - vector( ph1, ph1+len_ph1 )); - - //second polyhedron - CPPUNIT_ASSERT_NO_THROW(ph2 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_DESCENDING, MED_EN::MED_CELL, /*Number*/2, len_ph2)); - CPPUNIT_ASSERT_EQUAL( 10, len_ph2 ); - const int faces2[] = { 10,11,12,13,14,15,16,-3,17,18 }; - CPPUNIT_ASSERT( vector( faces2, faces2 + len_ph2 ) == - vector( ph2, ph2+len_ph2 )); - } - - // We reset here EntityDimension to check getConnectivityOfAnElement() - //myNodalConnectivity.setEntityDimension(2); - - { - const int *ph1, *ph2; - int len_ph1, len_ph2; - // first polygon - CPPUNIT_ASSERT_NO_THROW(ph1 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_FACE, /*Number*/1, len_ph1)); - CPPUNIT_ASSERT_EQUAL( 6, len_ph1 ); - CPPUNIT_ASSERT( vector( PolyhedronNodalConnectivity, PolyhedronNodalConnectivity + len_ph1) == - vector( ph1, ph1+len_ph1 )); - - // second polygon - CPPUNIT_ASSERT_NO_THROW(ph2 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_FACE, /*Number*/2, len_ph2)); - CPPUNIT_ASSERT_EQUAL( 4, len_ph2 ); - CPPUNIT_ASSERT( vector( PolyhedronNodalConnectivity + len_ph1 + 1, PolyhedronNodalConnectivity + len_ph1 + 1 + len_ph2) == - vector( ph2, ph2+len_ph2 )); - - // MED_DESCENDING - // first polygon - CPPUNIT_ASSERT_NO_THROW(ph1 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_DESCENDING, MED_EN::MED_FACE, /*Number*/1, len_ph1)); - CPPUNIT_ASSERT_EQUAL( 6, len_ph1 ); - const int edges1[6] = { 1,2,3,4,5,6 }; - CPPUNIT_ASSERT( vector( edges1, edges1 + len_ph1 ) == - vector( ph1, ph1+len_ph1 )); - - // second polygon - CPPUNIT_ASSERT_NO_THROW(ph2 = myNodalConnectivity.getConnectivityOfAnElement - (MED_EN::MED_DESCENDING, MED_EN::MED_FACE, /*Number*/2, len_ph2)); - CPPUNIT_ASSERT_EQUAL( 4, len_ph2 ); - const int edges2[4] = { 7,8,9,-1 }; - CPPUNIT_ASSERT( vector( edges2, edges2 + len_ph2 ) == - vector( ph2, ph2+len_ph2 )); - } - - //////////// - // TEST 2 // - //////////// - checkCopyConnectivity(); - - //////////// - // TEST 3 // - //////////// - - CONNECTIVITY *aCells1=new CONNECTIVITY(/*numberOfTypes*/2, /*Entity*/MED_EN::MED_CELL); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aCells1->getEntity()); - CPPUNIT_ASSERT_EQUAL(2, aCells1->getNumberOfTypes(MED_EN::MED_CELL)); - CPPUNIT_ASSERT_EQUAL(2, aCells1->getNumberOfTypes(MED_EN::MED_CELL)); - - CONNECTIVITY aCells2 (/*numberOfTypes*/3/*, Entity=MED_EN::MED_CELL*/); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aCells2.getEntity()); - CPPUNIT_ASSERT_EQUAL(3, aCells2.getNumberOfTypes(MED_EN::MED_CELL)); - CPPUNIT_ASSERT_EQUAL(3, aCells2.getNumberOfTypes(MED_EN::MED_CELL)); - - CONNECTIVITY * anEdges1 = new CONNECTIVITY(/*numberOfTypes*/1, /*Entity*/MED_EN::MED_EDGE); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_EDGE, anEdges1->getEntity()); - CPPUNIT_ASSERT_EQUAL(1, anEdges1->getNumberOfTypes(MED_EN::MED_EDGE)); - CPPUNIT_ASSERT_EQUAL(1, anEdges1->getNumberOfTypes(MED_EN::MED_EDGE)); - - CONNECTIVITY * anEdges2 = new CONNECTIVITY(/*numberOfTypes*/2, /*Entity*/MED_EN::MED_EDGE); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_EDGE, anEdges2->getEntity()); - CPPUNIT_ASSERT_EQUAL(2, anEdges2->getNumberOfTypes(MED_EN::MED_EDGE)); - CPPUNIT_ASSERT_EQUAL(2, anEdges2->getNumberOfTypes(MED_EN::MED_EDGE)); - - CONNECTIVITY * aFaces1 = new CONNECTIVITY(/*numberOfTypes*/2, /*Entity*/MED_EN::MED_FACE); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces1->getEntity()); - CPPUNIT_ASSERT_EQUAL(2, aFaces1->getNumberOfTypes(MED_EN::MED_FACE)); - CPPUNIT_ASSERT_EQUAL(2, aFaces1->getNumberOfTypes(MED_EN::MED_FACE)); - - // No need to delete anEdges1 and aFaces1, because they are owned by aCells1 - // (anEdges1 is owned by aFaces1 to be precise) - // No need to delete anEdges2, because they are owned by aCells2 - - // EntityDimension - // It would be good to set EntityDimension automatically for EDGEs and FACEs, - // and warn about not set EntityDimension for CELLs - // (or calculate it by given geometric types) - aCells1->setEntityDimension(3); - aCells2.setEntityDimension(2); // for 2D mesh - anEdges1->setEntityDimension(1); - anEdges2->setEntityDimension(1); - aFaces1->setEntityDimension(2); - - CPPUNIT_ASSERT_EQUAL(3, aCells1->getEntityDimension()); - CPPUNIT_ASSERT_EQUAL(2, aCells2.getEntityDimension()); - CPPUNIT_ASSERT_EQUAL(1, anEdges1->getEntityDimension()); - CPPUNIT_ASSERT_EQUAL(1, anEdges2->getEntityDimension()); - CPPUNIT_ASSERT_EQUAL(2, aFaces1->getEntityDimension()); - - // getPolyTypeRelativeTo - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_POLYHEDRA, aCells1->getPolyTypeRelativeTo()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_POLYGON , aCells2.getPolyTypeRelativeTo()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_POLYGON , aFaces1->getPolyTypeRelativeTo()); - // because there is no poly types for edges (2D entities) - CPPUNIT_ASSERT_THROW(anEdges1->getPolyTypeRelativeTo(), MEDEXCEPTION); - - // setConstituent - CPPUNIT_ASSERT_THROW(aCells1->setConstituent(&aCells2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aCells1->setConstituent(anEdges1), MEDEXCEPTION); - - aCells1->setConstituent(aFaces1); - aCells1->setConstituent(anEdges1); - - CPPUNIT_ASSERT_EQUAL(1, aCells1->getNumberOfTypes(MED_EN::MED_EDGE)); - CPPUNIT_ASSERT_EQUAL(2, aCells1->getNumberOfTypes(MED_EN::MED_FACE)); - - aCells2.setConstituent(anEdges2); - CPPUNIT_ASSERT_EQUAL(2, aCells2.getNumberOfTypes(MED_EN::MED_EDGE)); - - // setGeometricTypes - MED_EN::medGeometryElement aCellTypes2D[3] = {MED_EN::MED_TRIA3, MED_EN::MED_QUAD4, MED_EN::MED_TRIA6}; - MED_EN::medGeometryElement aCellTypes3D[2] = {MED_EN::MED_PYRA5, MED_EN::MED_HEXA8}; - MED_EN::medGeometryElement anEdgeTypes1[1] = {MED_EN::MED_SEG2}; - MED_EN::medGeometryElement anEdgeTypes2[2] = {MED_EN::MED_SEG2, MED_EN::MED_SEG3}; - MED_EN::medGeometryElement aFaceTypes2[2] = - {MED_EN::MED_TRIA3, MED_EN::MED_QUAD4}; - - aCells1->setGeometricTypes(aCellTypes3D, MED_EN::MED_CELL); - aCells1->setGeometricTypes(aFaceTypes2, MED_EN::MED_FACE); - aCells1->setGeometricTypes(anEdgeTypes1, MED_EN::MED_EDGE); - CPPUNIT_ASSERT_THROW(aCells1->setGeometricTypes(anEdgeTypes1, MED_EN::MED_NODE), MEDEXCEPTION); - - aCells2.setGeometricTypes(aCellTypes2D, MED_EN::MED_CELL); - anEdges2->setGeometricTypes(anEdgeTypes2, MED_EN::MED_EDGE); - CPPUNIT_ASSERT_THROW(aCells2.setGeometricTypes(aFaceTypes2, MED_EN::MED_FACE), MEDEXCEPTION); - - // setCount - int countCell2D[4] = {1, 5, 6, 10}; - int countCell3D[3] = {1, 3, 4}; - int countEdges1[2] = {1, 21}; - int countEdges2[3] = {1, 13, 21}; - int countFaces1[3] = {1, 9, 15}; - - aCells1->setCount(countCell3D, MED_EN::MED_CELL); - aCells1->setCount(countEdges1, MED_EN::MED_EDGE); - aCells1->setCount(countFaces1, MED_EN::MED_FACE); - CPPUNIT_ASSERT_THROW(aCells1->setCount(countEdges1, MED_EN::MED_NODE), MEDEXCEPTION); - - aCells2.setCount(countCell2D, MED_EN::MED_CELL); - aCells2.setCount(countEdges2, MED_EN::MED_EDGE); - CPPUNIT_ASSERT_THROW(aCells2.setCount(countFaces1, MED_EN::MED_FACE), MEDEXCEPTION); - - // setNodal - - // aCells2 - int nodesCell2D_TRIA3[12] = {3,8,7, 10,7,13, 18,13,14, 11,14,8}; - int nodesCell2D_QUAD4[4] = {7,8,14,13}; - int nodesCell2D_TRIA6[24] = {1,2,3,7,10,6, 3,4,5,9,11,8, 11,15,20,19,18,14, 18,17,16,12,10,13}; - - aCells2.setNodal(nodesCell2D_TRIA3, MED_EN::MED_CELL, MED_EN::MED_TRIA3); - aCells2.setNodal(nodesCell2D_QUAD4, MED_EN::MED_CELL, MED_EN::MED_QUAD4); - aCells2.setNodal(nodesCell2D_TRIA6, MED_EN::MED_CELL, MED_EN::MED_TRIA6); - - int nodesEdges2_SEG2[24] = {3,8, 8,11, 11,14, 14,18, 18,13, 13,10, 10,7, - 7,3, 7,8, 8,14, 14,13, 13,7}; - int nodesEdges2_SEG3[24] = {1,2,3, 3,4,5, 5,9,11, 11,15,20, - 20,19,18, 18,17,16, 16,12,10, 10,6,1}; - - aCells2.setNodal(nodesEdges2_SEG2, MED_EN::MED_EDGE, MED_EN::MED_SEG2); - aCells2.setNodal(nodesEdges2_SEG3, MED_EN::MED_EDGE, MED_EN::MED_SEG3); - - // aCells1 - int nodesCell3D_PYRA5[10] = {5,4,3,2,1, 6,7,8,9,10}; - int nodesCell3D_HEXA8[8] = {2,3,4,5, 6,7,8,9}; - - aCells1->setNodal(nodesCell3D_PYRA5, MED_EN::MED_CELL, MED_EN::MED_PYRA5); - aCells1->setNodal(nodesCell3D_HEXA8, MED_EN::MED_CELL, MED_EN::MED_HEXA8); - - int nodesFaces1_TRIA3[24] = {1,2,3, 1,3,4, 1,4,5, 1,5,2, - 10,6,7, 10,7,8, 10,8,9, 10,9,6}; - int nodesFaces1_QUAD4[24] = {2,3,4,5, 6,7,8,9, 2,3,7,6, 5,4,8,9, 2,5,9,6, 3,4,8,7}; - // int nodesFaces1_TRIA6[6] = {11,12,13,14,15,16}; - // int nodesFaces1_QUAD8[8] = {15,14,13,17,18,19,20,21}; - - aCells1->setNodal(nodesFaces1_TRIA3, MED_EN::MED_FACE, MED_EN::MED_TRIA3); - aCells1->setNodal(nodesFaces1_QUAD4, MED_EN::MED_FACE, MED_EN::MED_QUAD4); - //aCells1->setNodal(nodesFaces1_TRIA6, MED_EN::MED_FACE, MED_EN::MED_TRIA6); - //aCells1->setNodal(nodesFaces1_QUAD8, MED_EN::MED_FACE, MED_EN::MED_QUAD8); - - int nodesEdges1_SEG2[40] = {1,2, 1,3, 1,4, 1,5, 10,6, 10,7, 10,8, 10,9, - 2,3, 3,4, 4,5, 5,2, 6,7, 7,8, 8,9, 9,6, - 2,6, 3,7, 4,8, 5,9}; - - aCells1->setNodal(nodesEdges1_SEG2, MED_EN::MED_EDGE, MED_EN::MED_SEG2); - - // setNumberOfNodes - aCells2.setNumberOfNodes(20); - anEdges2->setNumberOfNodes(20); - - aCells1->setNumberOfNodes(10); - anEdges1->setNumberOfNodes(10); - aFaces1->setNumberOfNodes(10); - - // existConnectivity - CPPUNIT_ASSERT(aCells1->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL)); - CPPUNIT_ASSERT(aCells1->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE)); - CPPUNIT_ASSERT(aCells1->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_EDGE)); - CPPUNIT_ASSERT(!aCells1->existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_NODE)); - - CPPUNIT_ASSERT(!aCells1->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL)); - CPPUNIT_ASSERT(!aCells1->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_FACE)); - CPPUNIT_ASSERT(!aCells1->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_EDGE)); - CPPUNIT_ASSERT(!aCells1->existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_NODE)); - - CPPUNIT_ASSERT(aCells2.existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_CELL)); - CPPUNIT_ASSERT(!aCells2.existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_FACE)); - CPPUNIT_ASSERT(aCells2.existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_EDGE)); - CPPUNIT_ASSERT(!aCells2.existConnectivity(MED_EN::MED_NODAL, MED_EN::MED_NODE)); - - CPPUNIT_ASSERT(!aCells2.existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL)); - CPPUNIT_ASSERT(!aCells2.existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_FACE)); - CPPUNIT_ASSERT(!aCells2.existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_EDGE)); - CPPUNIT_ASSERT(!aCells2.existConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_NODE)); - - // getConnectivityOfAnElement - { - int len_e1, len_e2, i; - const int * nc_e1 = aCells1->getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_CELL, /*Number*/1, len_e1); - CPPUNIT_ASSERT_EQUAL(5, len_e1); // PYRA5 {1,2,3,4,5} - for (i = 0; i < len_e1; i++) { - if (nc_e1[i] < 1 || 5 < nc_e1[i]) - CPPUNIT_FAIL("Wrong node in element"); - } - - const int * nc_e2 = aCells2.getConnectivityOfAnElement - (MED_EN::MED_NODAL, MED_EN::MED_CELL, /*Number*/2, len_e2); - CPPUNIT_ASSERT_EQUAL(3, len_e2); // TRIA3 {7,10,13} - for (i = 0; i < len_e2; i++) { - if (nc_e2[i] != 7 && nc_e2[i] != 10 && nc_e2[i] != 13) - CPPUNIT_FAIL("Wrong node in element"); - } - } - - // aCells1 (2 types) | - // | | - // aFaces1 (4 types) | aCells2 (3 types) - // | | | - // anEdges1 (1 type) | anEdges2 (2 types) - - MESH* mesh=new MESH; //updateFamily method requires a pointer to the mesh - mesh->setConnectivityptr(aCells1); - // updateFamily - { - FAMILY *aFamilyOnFaces=new FAMILY; - aFamilyOnFaces->setEntity(MED_EN::MED_FACE); - aFamilyOnFaces->setMeshName("Mesh 1"); - aFamilyOnFaces->setMesh(mesh); - mesh->removeReference(); - aFamilyOnFaces->setName("Support On Faces 1"); - //aFamilyOnFaces->setAll(true); - - int nbTypesFam1 = 2; - MED_EN::medGeometryElement aSCTypes[4] = {MED_EN::MED_TRIA3, MED_EN::MED_QUAD4}; - int nbEltsSC[4] = {8,6}; - int indexSC[5] = {1,9,15}; // length = nb.types + 1 - int valueSC[16] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14}; // length = total nb. of elements - //int nbTypesFam1 = 1; - //MED_EN::medGeometryElement aSCTypes[1] = {MED_EN::MED_TRIA3}; - //int nbEltsSC[1] = {8}; - //int indexSC[2] = {1,9}; // length = nb.types + 1 - //int valueSC[8] = {1,3,5,7,9,11,13,15}; // length = total nb. of elements - - aFamilyOnFaces->setNumberOfGeometricType(nbTypesFam1); - aFamilyOnFaces->setGeometricType(aSCTypes); - aFamilyOnFaces->setNumberOfElements(nbEltsSC); - aFamilyOnFaces->setNumber(indexSC, valueSC); - - vector aFamsOnFaces (1); - aFamsOnFaces[0] = aFamilyOnFaces; - - // Attention!!! By default ENABLE_UPDATE_FAMILY is not defined!!! - // I do not undestand, what this method should do - // and what I must give to it to obtain good result - - CPPUNIT_ASSERT_NO_THROW(aCells1->updateFamily(aFamsOnFaces)); - aFamilyOnFaces->removeReference(); - } - - //////////// - // TEST 4 // - //////////// - CONNECTIVITY * c1 = new CONNECTIVITY(/*numberOfTypes*/3, MED_EN::MED_CELL); - createOrCheck(c1, "Creation", /*create*/true); - createOrCheck(c1, "Check just created", /*create*/false); - - CONNECTIVITY * c2 = new CONNECTIVITY(*c1); - createOrCheck(c2, "Check copy constructor", /*create*/false); - - // invertConnectivityForAFace - int nbFacesC2 = c2->getNumberOf(MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS); - for (int faceId = 1; faceId <= nbFacesC2; faceId++) { - - // this face nodal connectivity before inversion: - int oldLen, newLen; - const int * oldConn = c2->getConnectivityOfAnElement(MED_EN::MED_NODAL, - MED_EN::MED_FACE, faceId, oldLen); - - // descending connectivity before inversion: - int before_NumberOfElements = c2->getNumberOf(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - const int * before_connectivity_shared = - c2->getConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - const int * before_connectivity_index = - c2->getConnectivityIndex(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - - // copy connectivity, because the pointer, returned by getConnectivity, - // will point to the same memory before and after inversion - int lenDC = before_connectivity_index[before_NumberOfElements] - 1; - int * before_connectivity = new int[lenDC]; - for (int i = 0; i < lenDC; i++) - before_connectivity[i] = before_connectivity_shared[i]; - - // reverse descending connectivity before inversion: - const int * before_ReverseDescendingConnectivity_shared = - c2->getReverseConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - const int * before_ReverseDescendingConnectivityIndex = - c2->getReverseConnectivityIndex(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - - int lenRDC = before_ReverseDescendingConnectivityIndex[nbFacesC2] - 1; - int * before_ReverseDescendingConnectivity = new int[lenRDC]; - for (int i = 0; i < lenRDC; i++) - before_ReverseDescendingConnectivity[i] = before_ReverseDescendingConnectivity_shared[i]; - - // perform inversion - int * newNodesForFace = new int[oldLen]; - if (oldLen == 3) { - newNodesForFace[0] = oldConn[1]; - newNodesForFace[1] = oldConn[0]; - newNodesForFace[2] = oldConn[2]; - } else { - newNodesForFace[0] = oldConn[2]; - newNodesForFace[1] = oldConn[1]; - newNodesForFace[2] = oldConn[0]; - newNodesForFace[3] = oldConn[3]; - } - c2->invertConnectivityForAFace(faceId, newNodesForFace); - - // reverse descending connectivity after inversion: - const int * after_ReverseDescendingConnectivity = - c2->getReverseConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - const int * after_ReverseDescendingConnectivityIndex = - c2->getReverseConnectivityIndex(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - - // Faces, which are on bound (have one neighbouring), are not inverted. - bool isOnBound = false; - - for (int i = 0; i < nbFacesC2; i++) { - int plus = after_ReverseDescendingConnectivityIndex[i] - 1; - // always two neighbourings - if ((i + 1) == faceId) { - // no second neighbouring - isOnBound = (before_ReverseDescendingConnectivity[plus + 1] == 0); - } - if ((i + 1) == faceId && !isOnBound) { - CPPUNIT_ASSERT_EQUAL(before_ReverseDescendingConnectivity[plus + 0], - after_ReverseDescendingConnectivity[plus + 1]); - CPPUNIT_ASSERT_EQUAL(before_ReverseDescendingConnectivity[plus + 1], - after_ReverseDescendingConnectivity[plus + 0]); - } - else { - CPPUNIT_ASSERT_EQUAL(before_ReverseDescendingConnectivity[plus + 0], - after_ReverseDescendingConnectivity[plus + 0]); - CPPUNIT_ASSERT_EQUAL(before_ReverseDescendingConnectivity[plus + 1], - after_ReverseDescendingConnectivity[plus + 1]); - } - } - - // descending connectivity after inversion: - int after_NumberOfElements = c2->getNumberOf(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - const int * after_connectivity = - c2->getConnectivity(MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - const int * after_connectivity_index = - c2->getConnectivityIndex(MED_EN::MED_DESCENDING, MED_EN::MED_CELL); - - CPPUNIT_ASSERT_EQUAL(before_NumberOfElements, after_NumberOfElements); - - for (int j = 0; j < before_NumberOfElements; j++) { - for (int k = after_connectivity_index[j]; k < after_connectivity_index[j+1]; k++) { - if (labs(before_connectivity[k-1]) == faceId && !isOnBound) { - CPPUNIT_ASSERT_EQUAL(before_connectivity[k-1], - after_connectivity[k-1]); - } - else { - CPPUNIT_ASSERT_EQUAL(before_connectivity[k-1], after_connectivity[k-1]); - } - } - } - - // this face nodal connectivity after inversion: - if (!isOnBound) { - const int * newConn = c2->getConnectivityOfAnElement(MED_EN::MED_NODAL, - MED_EN::MED_FACE, faceId, newLen); - CPPUNIT_ASSERT_EQUAL(oldLen, newLen); - for (int i = 0; i < newLen && i < 4; i++) { - CPPUNIT_ASSERT_EQUAL(newNodesForFace[i], newConn[i]); - } - } - delete [] newNodesForFace; - - delete [] before_connectivity; - delete [] before_ReverseDescendingConnectivity; - - // ATTENTION: invertConnectivityForAFace() is not tested on polygons!!! - } - - - delete c1; - delete c2; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Connectivity_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_Connectivity_fault.cxx deleted file mode 100644 index 7c7a1e99f..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Connectivity_fault.cxx +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -using namespace std; -using namespace MEDMEM; - -static void createOrCheck (CONNECTIVITY * theC, string msg, bool create = false) -{ - // Preconditions: Entity and NumberOfTypes - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, MED_EN::MED_CELL, theC->getEntity()); - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 2, theC->getNumberOfTypes(MED_EN::MED_CELL)); - - // EntityDimension - if (create) - theC->setEntityDimension(3); - - // NumberOfNodes - int nbNodes = 20; - - if (create) { - theC->setNumberOfNodes(nbNodes); - } - - // GeometricTypes - MED_EN::medGeometryElement aCellTypes[2] = {MED_EN::MED_PYRA5, MED_EN::MED_HEXA8}; - - // this variable is needed in check mode (!create) - // because of bug with getGlobalNumberingIndex() method (see below) - - if (create) { - theC->setGeometricTypes(aCellTypes, MED_EN::MED_CELL); - CPPUNIT_ASSERT_THROW(theC->setGeometricTypes(aCellTypes, MED_EN::MED_NODE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setGeometricTypes(aCellTypes, MED_EN::MED_FACE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setGeometricTypes(aCellTypes, MED_EN::MED_EDGE), MEDEXCEPTION); - } - - // Nodal Connectivity for standard types - int countCells[3] = {1, 3, 4}; // 2 PYRA5 and 1 HEXA8 - int nodesCells_PYRA5[10] = {2,3,4,5,1, 6,7,8,9,10}; - int nodesCells_HEXA8[8] = {2,3,4,5, 6,7,8,9}; - - if (create) { - theC->setCount(countCells, MED_EN::MED_CELL); - theC->setNodal(nodesCells_PYRA5, MED_EN::MED_CELL, MED_EN::MED_PYRA5); - theC->setNodal(nodesCells_HEXA8, MED_EN::MED_CELL, MED_EN::MED_HEXA8); - - // Invalid cases - CPPUNIT_ASSERT_THROW(theC->setCount(countCells, MED_EN::MED_NODE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setCount(countCells, MED_EN::MED_EDGE), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->setCount(countCells, MED_EN::MED_FACE), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(theC->setNodal(nodesCells_PYRA5, MED_EN::MED_FACE, MED_EN::MED_PYRA5), MEDEXCEPTION); - } - - // 2 POLYHEDRA - const int nbPolyhedron = 2; - const int nbPolyNodes = 52 + 14 - 2; // = 64 - - int aPolyhedronIndex[nbPolyhedron + 1] = {1,33, 65}; - - int aPolyhedronNodalConnectivity[nbPolyNodes] = { - 11,15,19,20,17,13,-1, 11,13,14,-1, 14,13,17,18,-1, 18,17,20,-1, 11,14,15,-1, 15,14,18,19,-1, 19,18,20, - 11,13,17,20,19,15,-1, 11,12,13,-1, 13,12,16,17,-1, 17,16,20,-1, 11,15,12,-1, 12,15,19,16,-1, 16,19,20}; - - if (create) { - theC->setNodal(aPolyhedronNodalConnectivity, - MED_EN::MED_CELL, MED_EN::MED_POLYHEDRA, aPolyhedronIndex); - } - else { - // CELLS(3D): theC - { - // Polyhedron-specific methods - { - // invalid polyhedron Id -//#ifdef ENABLE_FAULTS - int lenPolyh3nodes; - int nbFaces3; - int *nbNodes3; - // (BUG) Segmentation fault instead of MEDEXCEPTION - CPPUNIT_ASSERT_THROW(theC->getNodesOfPolyhedron(1, lenPolyh3nodes), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNodesOfPolyhedron(3+3, lenPolyh3nodes), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNodesPerFaceOfPolyhedron - (/*polyhedronId*/1, nbFaces3, nbNodes3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theC->getNodesPerFaceOfPolyhedron - (/*polyhedronId*/3+3, nbFaces3, nbNodes3), MEDEXCEPTION); -//#endif - } // Polyhedron-specific methods - } // CELLS: theC - } - - if (create) { - // force _constituent computation - CPPUNIT_ASSERT_EQUAL_MESSAGE(msg, 2, theC->getNumberOfTypes(MED_EN::MED_FACE)); - } -} - -int main (int argc, char** argv) -{ - CONNECTIVITY * c1 = new CONNECTIVITY(/*numberOfTypes*/2, MED_EN::MED_CELL); - createOrCheck(c1, "Creation", /*create*/true); - createOrCheck(c1, "Check just created", /*create*/false); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Coordinate.cxx b/src/MEDMEMCppTest/MEDMEMTest_Coordinate.cxx deleted file mode 100644 index 7630c9818..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Coordinate.cxx +++ /dev/null @@ -1,411 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include - -#include "MEDMEM_Array.hxx" -#include "MEDMEM_Coordinate.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #8: MEDMEM_Coordinate.hxx } MEDMEMTest_Coordinate.cxx - -/*! - * Check methods (23), defined in MEDMEM_Coordinate.hxx: - * class COORDINATE { - * (+) COORDINATE(); - * (+) COORDINATE(int SpaceDimension, int NumberOfNodes, MED_EN::medModeSwitch Mode); - * (+) COORDINATE(int SpaceDimension,const string * CoordinateName, const string * CoordinateUnit); - * (+) COORDINATE(const COORDINATE & m); - * (+) virtual ~COORDINATE(); - * (+) void setCoordinates(MEDARRAY *Coordinate,bool shallowCopy=false); - * (+) void setCoordinates(const MED_EN::medModeSwitch Mode, const double *Coordinate); - * (+) void setCoordinatesNames(const string * CoordinateName); - * (+) void setCoordinateName(const string CoordinateName, const int i); - * (+) void setCoordinatesUnits(const string * CoordinateUnit); - * (+) void setCoordinateUnit(const string CoordinateUnit, const int i); - * (+) void setCoordinatesSystem(const string CoordinateSystem); - * (+) void setNodesNumbers(const int * NodeNumber); - * (+) int getSpaceDimension() const; - * (+) int getNumberOfNodes() const; - * (+) virtual const int* getNodesNumbers() const; - * (+) string getCoordinatesSystem() const; - * (+) virtual const double * getCoordinates(MED_EN::medModeSwitch Mode); - * (+) virtual double getCoordinate(int Number,int Axis); - * (+) virtual const double * getCoordinateAxis(int Axis); - * (+) const string * getCoordinatesNames() const; - * (+) string getCoordinateName(int Axis) const; - * (+) const string * getCoordinatesUnits() const; - * (+) string getCoordinateUnit(int Axis) const; - * } - * - * Use code of MEDMEM/tests/testUCoordinate.cxx - * MEDMEM/test_copie_coordinate.cxx - */ -void MEDMEMTest::testCoordinate() -{ - ////////////////////////////////////////////// - // TEST 1: MEDMEM/tests/testUCoordinate.cxx // - ////////////////////////////////////////////// - { - const double pouieme = 0.009; - - int SpaceDim = 3; - int NbOfNodes = 5; - - string * noms = new string[3]; - noms[0] = " X "; - noms[1] = " Y "; - noms[2] = " Z "; - - string units[3]; - units[0] = " m "; - units[1] = " m "; - units[2] = " m "; - - int * numbers = new int[5]; - for (int i = 0; i < 5; i++) numbers[i] = 10 + i; - - double coor[15] = {0,0,0,0,0,1,0,1,0,1,0,0,0.5,0.5,0.5}; - CPPUNIT_ASSERT(SpaceDim * NbOfNodes == 15); - - double * coor1 = new double [SpaceDim*NbOfNodes]; - for (int k = 0; k < SpaceDim*NbOfNodes; k++) - coor1[k] = coor[k]; - - MEDARRAY* CoordinateArray = - new MEDARRAY(coor1, SpaceDim, NbOfNodes, MED_EN::MED_FULL_INTERLACE); - COORDINATE mycoo; - CPPUNIT_ASSERT_NO_THROW(mycoo.setCoordinates(CoordinateArray)); - - //--------------------------------------------------------------------// - // Tests des methodes // - // // - // - setCoordinatesNames // - // - setCoordinatesUnits // - // - setCoordinatesSystem // - // - setNodesNumbers // - // // - //--------------------------------------------------------------------// - - CPPUNIT_ASSERT_NO_THROW(mycoo.setCoordinatesNames(noms)); - CPPUNIT_ASSERT_NO_THROW(mycoo.setCoordinatesUnits(units)); - CPPUNIT_ASSERT_NO_THROW(mycoo.setCoordinatesSystem("cartesien")); - CPPUNIT_ASSERT_NO_THROW(mycoo.setNodesNumbers(numbers)); - - //--------------------------------------------------------------------// - // Tests des methodes // - // // - // - getCoordinatesNames // - // - getCoordinatesUnits // - // - getCoordinatesUnit // - // - getCoordinatesSystem // - // - getNodesNumbers // - // // - //--------------------------------------------------------------------// - CPPUNIT_ASSERT_NO_THROW(CPPUNIT_ASSERT(mycoo.getCoordinatesSystem() == "cartesien")); - - const string * units2; - try - { - units2 = mycoo.getCoordinatesUnits(); - for (int axe = 0; axe < SpaceDim; axe++) { - string verif = mycoo.getCoordinateUnit(axe+1); - CPPUNIT_ASSERT(verif == units2[axe]); - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const string * noms2; - try - { - noms2 = mycoo.getCoordinatesNames(); - for (int axe = 0; axe < SpaceDim; axe++) { - string verif = mycoo.getCoordinateName(axe+1); - CPPUNIT_ASSERT(verif == noms2[axe]); - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - const double * coor2 = mycoo.getCoordinates(MED_EN::MED_FULL_INTERLACE); - - for (int axe = 0; axe < SpaceDim; axe++) { - const double * coor3 = mycoo.getCoordinateAxis(axe+1); - for (int num = 0; num < NbOfNodes; num++) { - const double d = mycoo.getCoordinate(num + 1, axe + 1); - CPPUNIT_ASSERT(fabs(d - coor3[num ]) < pouieme); - CPPUNIT_ASSERT(fabs(d - coor2[(num * SpaceDim)+axe]) < pouieme); - CPPUNIT_ASSERT(fabs(d - coor [(num * SpaceDim)+axe]) < pouieme); - } - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - delete [] noms; - delete [] numbers; - delete [] coor1; - - delete CoordinateArray; - } - - ////////////////////////////////////////////// - // TEST 2: MEDMEM/test_copie_coordinate.cxx // - ////////////////////////////////////////////// - { - const int numberofNodes = 5; - const int spaceDimension = 3; - const MED_EN::medModeSwitch mode = MED_EN::MED_FULL_INTERLACE; - - //construction tableau MEDARRAY des coordonnées - MEDARRAY * myMedArray = new MEDARRAY(spaceDimension, numberofNodes, mode); - for (int i = 1; i <= myMedArray->getLengthValue(); i++) { - for (int j = 1; j <= myMedArray->getLeadingValue(); j++) - myMedArray->setIJ(i, j, (double) i*j); - } - - //construction noms des coordonnées - string * myCoordinatesNames = new string[spaceDimension]; - if (spaceDimension >= 1) myCoordinatesNames[0] = "x"; - if (spaceDimension >= 2) myCoordinatesNames[1] = "y"; - if (spaceDimension >= 3) myCoordinatesNames[2] = "z"; - - //construction unités des coordonnées - string * myCoordinatesUnits = new string[spaceDimension]; - if (spaceDimension >= 1) myCoordinatesUnits[0] = "m"; - if (spaceDimension >= 2) myCoordinatesUnits[1] = "m"; - if (spaceDimension >= 3) myCoordinatesUnits[2] = "m"; - - //construction des indices des noeuds - int * myNodeNumber = new int[numberofNodes]; - for (int i = 0; i < numberofNodes; i++) - myNodeNumber[i] = numberofNodes - i - 1; - - //construction de l'objet COORDINATE - COORDINATE * myCoordinate = new COORDINATE(); - myCoordinate->setCoordinates(myMedArray); - myCoordinate->setCoordinatesNames(myCoordinatesNames); - myCoordinate->setCoordinatesUnits(myCoordinatesUnits); - myCoordinate->setNodesNumbers(myNodeNumber); - - delete myMedArray; - delete[] myCoordinatesNames; - delete[] myCoordinatesUnits; - delete[] myNodeNumber; - - COORDINATE * myCoordinate2 = new COORDINATE(* myCoordinate); - delete myCoordinate; - myCoordinate = NULL; - - // check copied coordinate - int _spaceDimension = myCoordinate2->getSpaceDimension(); - int _numberofNodes = myCoordinate2->getNumberOfNodes(); - CPPUNIT_ASSERT(_spaceDimension == spaceDimension); - CPPUNIT_ASSERT(_numberofNodes == numberofNodes); - - for (int i = 1; i <= _numberofNodes; i++) { - for (int j = 1; j <= _spaceDimension; j++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(i*j, myCoordinate2->getCoordinate(i, j), 0.000001); - } - } - - CPPUNIT_ASSERT(myCoordinate2->getCoordinateName(1) == "x"); - CPPUNIT_ASSERT(myCoordinate2->getCoordinateName(2) == "y"); - CPPUNIT_ASSERT(myCoordinate2->getCoordinateName(3) == "z"); - - CPPUNIT_ASSERT(myCoordinate2->getCoordinateUnit(1) == "m"); - CPPUNIT_ASSERT(myCoordinate2->getCoordinateUnit(2) == "m"); - CPPUNIT_ASSERT(myCoordinate2->getCoordinateUnit(3) == "m"); - - for (int i = 0; i < _numberofNodes; i++) - CPPUNIT_ASSERT(myCoordinate2->getNodesNumbers()[i] == _numberofNodes - i - 1); - - delete myCoordinate2; - } - - //////////// - // TEST 3 // - //////////// - { - // COORDINATE(int SpaceDimension, int NumberOfNodes, MED_EN::medModeSwitch Mode); - COORDINATE anEmptyC (2, 10, MED_EN::MED_FULL_INTERLACE); - CPPUNIT_ASSERT(anEmptyC.getSpaceDimension() == 2); - CPPUNIT_ASSERT(anEmptyC.getNumberOfNodes() == 10); - CPPUNIT_ASSERT(anEmptyC.getNodesNumbers() == NULL); - // ?: how to fill it with coordinates? - // 1. void setCoordinates(MEDARRAY *Coordinate,bool shallowCopy=false); - // but this way we can override all three constructor parameters - // 2. void setCoordinates(const MED_EN::medModeSwitch Mode, const double *Coordinate); - // in this case we can override Mode - -//#ifdef ENABLE_FAULTS - // (BUG) Incoherence between setCoordinateName() and getCoordinateName() - //anEmptyC.setCoordinateName("alpha", 1); - //anEmptyC.setCoordinateName("betta", 2); - // (BUG) Incoherence between setCoordinateUnit() and getCoordinateUnit() - //anEmptyC.setCoordinateUnit("ttt", 1); - //anEmptyC.setCoordinateUnit("sss", 2); -//#else - anEmptyC.setCoordinateName("alpha", 0); - anEmptyC.setCoordinateName("betta", 1); - - anEmptyC.setCoordinateUnit("ttt", 0); - anEmptyC.setCoordinateUnit("sss", 1); -//#endif -//#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_FAIL("Incoherence between COORDINATE::setCoordinateName() and COORDINATE::getCoordinateName()"); - //CPPUNIT_FAIL("Incoherence between COORDINATE::setCoordinateUnit() and COORDINATE::getCoordinateUnit()"); -//#endif - - int len = 10 * 2; - double * cc = new double[len]; - for (int i = 0; i < len; i++) { - cc[i] = (double)(i + 1); - } - anEmptyC.setCoordinates(MED_EN::MED_NO_INTERLACE, cc); - - CPPUNIT_ASSERT(anEmptyC.getCoordinateName(1) == "alpha"); - CPPUNIT_ASSERT(anEmptyC.getCoordinateName(2) == "betta"); - CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(1) == "ttt"); - CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(2) == "sss"); - for (int nn = 1; nn <= 10; nn++) { - for (int aa = 1; aa <= 2; aa++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(nn + (aa - 1) * 10, anEmptyC.getCoordinate(nn, aa), 0.000001); - } - } - - CPPUNIT_ASSERT_THROW(anEmptyC.getCoordinate(0, 0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyC.getCoordinate(10, 10), MEDEXCEPTION); - - MEDARRAY mcc (cc, 2, 10, MED_EN::MED_FULL_INTERLACE, false, false); - anEmptyC.setCoordinates(&mcc, false); - - // coordinates names and units are not changed - CPPUNIT_ASSERT(anEmptyC.getCoordinateName(1) == "alpha"); - CPPUNIT_ASSERT(anEmptyC.getCoordinateName(2) == "betta"); - CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(1) == "ttt"); - CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(2) == "sss"); - for (int nn = 1; nn <= 10; nn++) { - for (int aa = 1; aa <= 2; aa++) { - // coordinates changed - CPPUNIT_ASSERT_DOUBLES_EQUAL((nn - 1) * 2 + aa, anEmptyC.getCoordinate(nn, aa), 0.000001); - } - } - - delete [] cc; - -//#ifdef ENABLE_FAULTS - // (BUG) Segmentation Fault or Hang up after anEmptyC and mcc destruction, - // because array will be owned by two pointers (in mcc and in anEmptyC) after this call - //???skl anEmptyC.setCoordinates(&mcc, true); - // In other case (if we dynamically allocate mcc and do not free it) we will have memory leak. -//#endif -//#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_FAIL("Bug in COORDINATE::setCoordinates() in shallow copy mode"); -//#endif - } - - //////////// - // TEST 4 // - //////////// - { - // COORDINATE(int SpaceDimension,const string * CoordinateName, const string * CoordinateUnit); - string cnames [3] = {"al", "be", "ga"}; - string cunits [3] = {"kg", "mm", "s2"}; - COORDINATE anEmptyA (3, cnames, cunits); - - CPPUNIT_ASSERT(anEmptyA.getCoordinateName(1) == "al"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateName(2) == "be"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateName(3) == "ga"); - - CPPUNIT_ASSERT(anEmptyA.getCoordinateUnit(1) == "kg"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateUnit(2) == "mm"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateUnit(3) == "s2"); - - CPPUNIT_ASSERT_EQUAL(anEmptyA.getSpaceDimension(), 0); - CPPUNIT_ASSERT_EQUAL(anEmptyA.getNumberOfNodes(), 0); - - MEDARRAY mcc (3, 7, MED_EN::MED_NO_INTERLACE); - { vector val(3*7,0); // avoid usage of not initialized memory - mcc.set(MED_EN::MED_NO_INTERLACE, &val[0]); } - anEmptyA.setCoordinates(&mcc, false); - - CPPUNIT_ASSERT_EQUAL(anEmptyA.getSpaceDimension(), 3); - CPPUNIT_ASSERT_EQUAL(anEmptyA.getNumberOfNodes(), 7); - - CPPUNIT_ASSERT(anEmptyA.getCoordinateName(1) == "al"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateName(2) == "be"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateName(3) == "ga"); - - CPPUNIT_ASSERT(anEmptyA.getCoordinateUnit(1) == "kg"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateUnit(2) == "mm"); - CPPUNIT_ASSERT(anEmptyA.getCoordinateUnit(3) == "s2"); - - CPPUNIT_ASSERT_THROW(anEmptyA.getCoordinate(-1, 0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(anEmptyA.getCoordinate(10, 10), MEDEXCEPTION); - - // No COORDINATE::operator=, but this is compilable - // good - //COORDINATE anEmptyB; - //COORDINATE anEmptyD (3, cnames, cunits); - //anEmptyB = anEmptyD; - //CPPUNIT_ASSERT(anEmptyB.getCoordinateName(1) == "al"); - - // bad (assert fails) - //COORDINATE anEmptyB; - // Object, created in this line, is destructed right after it. - //anEmptyB = COORDINATE(3, cnames, cunits); - // Now a pointer _coordinateName inside anEmptyB points to a desallocated memory zone - //CPPUNIT_ASSERT(anEmptyB.getCoordinateName(1) == "al"); - } -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Coordinate_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_Coordinate_fault.cxx deleted file mode 100644 index a75d4996c..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Coordinate_fault.cxx +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_Array.hxx" -#include "MEDMEM_Coordinate.hxx" - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char** argv) -{ - COORDINATE anEmptyC (2, 10, MED_EN::MED_FULL_INTERLACE); - - // (BUG) Incoherence between setCoordinateName() and getCoordinateName() - // C++ index notation is used in "set" methods, while in "get" methods indices start from 1. - anEmptyC.setCoordinateName("alpha", 1); - anEmptyC.setCoordinateName("betta", 2); - // (BUG) Incoherence between setCoordinateUnit() and getCoordinateUnit() - // C++ index notation is used in "set" methods, while in "get" methods indices start from 1. - anEmptyC.setCoordinateUnit("ttt", 1); - anEmptyC.setCoordinateUnit("sss", 2); - - //CPPUNIT_ASSERT(anEmptyC.getCoordinateName(1) == "alpha"); - //CPPUNIT_ASSERT(anEmptyC.getCoordinateName(2) == "betta"); - //CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(1) == "ttt"); - //CPPUNIT_ASSERT(anEmptyC.getCoordinateUnit(2) == "sss"); - - int len = 10 * 2; - double * cc = new double[len]; - for (int i = 0; i < len; i++) { - cc[i] = (double)(i + 1); - } - - MEDARRAY mcc (cc, 2, 10, MED_EN::MED_FULL_INTERLACE, false, false); - delete [] cc; - - // (BUG) Bug in COORDINATE::setCoordinates() in shallow copy mode: - // Segmentation Fault or Hang up after anEmptyC and mcc destruction, - // because array will be owned by two pointers (in mcc and in anEmptyC) after this call - anEmptyC.setCoordinates(&mcc, true); - // In other case (if we dynamically allocate mcc and do not free it) we will have memory leak. -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_DesactivateFacesComputation.cxx b/src/MEDMEMCppTest/MEDMEMTest_DesactivateFacesComputation.cxx deleted file mode 100644 index 582e72d6d..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_DesactivateFacesComputation.cxx +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_GibiMeshDriver.hxx" - -#include -#include - -#ifdef WIN32 -#include -#endif - -using namespace std; -using namespace MEDMEM; - -static void addMedFacesGroup2( MESHING& meshing, int nFaces, const int *groupValue, - string groupName, const MED_EN::medGeometryElement *mytypes, const int *index, const int *myNumberOfElements, int nbOfGeomTypes) - { - GROUP *faces=new GROUP; - faces->setName(groupName) ; - faces->setMesh(&meshing) ; - faces->setEntity(MED_EN::MED_FACE) ; - faces->setNumberOfGeometricType(nbOfGeomTypes) ; - faces->setGeometricType(mytypes); - faces->setNumberOfElements(myNumberOfElements) ; - faces->setNumber(index, groupValue) ; - meshing.addGroup(*faces) ; - faces->removeReference(); - } - -void MEDMEMTest::testDesactivateFacesComputation() -{ - double coords[108]= - {0, 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, 0, - 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, 0, - 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, 0, - 0.21504, 0.21504, 0, 0.43008, - 0.43008, 0.21504, 0, 0.43008, - //coordY - 0, 0, 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, 0, 0, - 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, 0, 0, - 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, 0, 0, - 0.21504, 0.21504, 0, 0.21504, - 0.43008, 0.43008, 0.43008, - //coordZ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.15677, 0.15677, - 0.15677, 0.15677, 0.15677, - 0.15677, 0.15677, 0.15677, - 0.15677, 0.1934, 0.1934, - 0.1934, 0.1934, 0.1934, - 0.1934, 0.1934, 0.1934, - 0.1934, 0.3485, 0.3485, - 0.3485, 0.3485, 0.3485, - 0.3485, 0.3485, 0.3485, - 0.3485}; - - int connNodalCellClassical[48]= - { 1, 2, 3, 4, 10, 11, 12, 13, - 4, 3, 7, 8, 13, 12, 16, 17, - 10, 11, 12, 13, 19, 20, 21, 22, - 13, 12, 16, 17, 22, 21, 25, 26, - 19, 20, 21, 22, 28, 29, 30, 31, - 22, 21, 25, 26, 31, 30, 34, 35 }; - - int connNodalFaceClassical[116]= - { 1, 2, 3, 4, - 10, 13, 12, 11, - 1, 2, 11, 10, - 2, 3, 12, 11, - 3, 4, 13, 12, - 4, 1, 10, 13, - 4, 3, 7, 8, - 13, 17, 16, 12, - 3, 7, 16, 12, - 7, 8, 17, 16, - 8, 4, 13, 17, - 19, 22, 21, 20, - 10, 11, 20, 19, - 11, 12, 21, 20, - 12, 13, 22, 21, - 13, 10, 19, 22, - 22, 26, 25, 21, - 12, 16, 25, 21, - 16, 17, 26, 25, - 17, 13, 22, 26, - 28, 31, 30, 29, - 19, 20, 29, 28, - 20, 21, 30, 29, - 21, 22, 31, 30, - 22, 19, 28, 31, - 31, 35, 34, 30, - 21, 25, 34, 30, - 25, 26, 35, 34, - 26, 22, 31, 35}; - - int bottom[2]={1,7}; - MED_EN::medGeometryElement bottomTypes[1]={MED_EN::MED_QUAD4}; - int bottomIndex[2]={1,3}; - int bottomNbOfElts[1]={2}; - int top[4]={8,9,10,11}; - MED_EN::medGeometryElement topTypes[1]={MED_EN::MED_QUAD4}; - int topIndex[3]={1,5}; - int topNbOfElts[1]={4}; - int side[5]={ 3, 6, 10, 11, 13}; - MED_EN::medGeometryElement sideTypes[1]={MED_EN::MED_QUAD4}; - int sideIndex[2]={1,6}; - int sideNbOfElts[1]={5}; - // - string tmp_dir=getTmpDirectory(); - string tmpfile=tmp_dir+"/toto3434535.med"; - string tmpGibiFile=tmp_dir+"/TET4.sauv"; - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(tmpfile); - aRemover.Register(tmpGibiFile); - // - - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=36; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN", - MED_EN::MED_NO_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = { "m", "m", "m" }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]={MED_EN::MED_HEXA8}; - const int nbOfCellElts[1]={6}; - meshing->setNumberOfTypes(1,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //Face connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesFace[1]={MED_EN::MED_QUAD4}; - const int nbOfFaceElts[1]={14}; - meshing->setNumberOfTypes(1,MED_EN::MED_FACE); - meshing->setTypes(classicalTypesFace,MED_EN::MED_FACE); - meshing->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_HEXA8,connNodalCellClassical); - //All face conn - meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_QUAD4,connNodalFaceClassical); - int nbOfTypes=meshing->getNumberOfTypes(MED_EN::MED_EDGE); - addMedFacesGroup2( *meshing, 2, bottom, "Bottom",bottomTypes,bottomIndex,bottomNbOfElts,1) ; - addMedFacesGroup2( *meshing, 4, top, "TopFace",topTypes,topIndex,topNbOfElts,1) ; - addMedFacesGroup2( *meshing, 5, side, "SideFace",sideTypes,sideIndex,sideNbOfElts,1) ; - // - int id=meshing->addDriver(MED_DRIVER,tmpfile,meshing->getName()); - meshing->write(id); - // - MESH *mesh=new MESH; - mesh->setName(meshing->getName()); - MEDMEM::MED_MESH_RDONLY_DRIVER *driver=new MEDMEM::MED_MESH_RDONLY_DRIVER(tmpfile,mesh); - driver->desactivateFacesComputation(); - id=mesh->addDriver(*driver); - mesh->read(id); - CPPUNIT_ASSERT_NO_THROW(nbOfTypes=mesh->getNumberOfTypes(MED_EN::MED_EDGE)); - CPPUNIT_ASSERT_EQUAL(0,nbOfTypes); - MEDMEM::GIBI_MESH_WRONLY_DRIVER *gibidriver=new MEDMEM::GIBI_MESH_WRONLY_DRIVER(tmpGibiFile,mesh ); - id=mesh->addDriver(*gibidriver); - mesh->write(id); -#ifdef WIN32 - CPPUNIT_ASSERT( GetFileAttributes(tmpGibiFile.c_str()) != INVALID_FILE_ATTRIBUTES ); -#else - CPPUNIT_ASSERT( access(tmpGibiFile.c_str(), F_OK) == 0 ); -#endif - - delete gibidriver; - delete driver; - // - meshing->removeReference(); - mesh->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_DriverFactory.cxx b/src/MEDMEMCppTest/MEDMEMTest_DriverFactory.cxx deleted file mode 100644 index 9f16cd092..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_DriverFactory.cxx +++ /dev/null @@ -1,670 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include - -#include "MEDMEM_DriverFactory.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_GibiMeshDriver.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_PorflowMeshDriver.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_VtkFieldDriver.hxx" -#include "MEDMEM_VtkMedDriver.hxx" -#include "MEDMEM_VtkMeshDriver.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #9: MEDMEM_DriverFactory.hxx } MEDMEMTest_DriverFactory.cxx - -/*! - * Check methods (7), defined in MEDMEM_DriverFactory.hxx: - * namespace DRIVERFACTORY { - * (+) driverTypes deduceDriverTypeFromFileName(const std::string & fileName); - * - * (+) GENDRIVER * buildDriverForMesh (driverTypes driverType, const std::string & fileName, - * MESH *mesh, const string & driverName, - * MED_EN::med_mode_acces access); - * (+) template - * GENDRIVER * buildDriverForField(driverTypes driverType, const std::string & fileName, - * FIELD *fielde, - * MED_EN::med_mode_acces access); - * - * (+) GENDRIVER * buildMeshDriverFromFile (const string & fileName, MESH * ptrMesh, - * MED_EN::med_mode_acces access); - * (+) template - * GENDRIVER * buildFieldDriverFromFile(const string & fileName, - * FIELD * ptrField, - * MED_EN::med_mode_acces access); - * - * (+) GENDRIVER * buildConcreteMedDriverForMesh(const std::string & fileName, MESH *mesh, - * const string & driverName, - * MED_EN::med_mode_acces access, - * MED_EN::medFileVersion version); - * (+) template - * GENDRIVER * buildConcreteMedDriverForField(const std::string & fileName, - * FIELD *fielde, - * MED_EN::med_mode_acces access, - * MED_EN::medFileVersion version); - * } - */ -void MEDMEMTest::testDriverFactory() -{ - /////////////////////////////////////////////////////////////////////// - // Test 1: getMedFileVersionForWriting & setMedFileVersionForWriting // - /////////////////////////////////////////////////////////////////////// - - // Obsolete, removed - - ////////////////////////////////////////////////////////////////////////// - // Test 1b: getVtkBinaryFormatForWriting & setVtkBinaryFormatForWriting // - ////////////////////////////////////////////////////////////////////////// - - // save current format - bool wasBinary = DRIVERFACTORY::getVtkBinaryFormatForWriting(); - - // check changing format - DRIVERFACTORY::setVtkBinaryFormatForWriting( !wasBinary ); - CPPUNIT_ASSERT(DRIVERFACTORY::getVtkBinaryFormatForWriting() == !wasBinary); - - // restore default version preference - DRIVERFACTORY::setVtkBinaryFormatForWriting(wasBinary); - - ////////////////////////////////////////// - // Test 2: deduceDriverTypeFromFileName // - ////////////////////////////////////////// - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("test.med") == MED_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t.st.sauve") == GIBI_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t.st.sauv") == GIBI_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t.st.cnc") == PORFLOW_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t.st.inp") == PORFLOW_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t.st.xyz") == PORFLOW_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t.st.vtk") == VTK_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t_st_med") == NO_DRIVER); - CPPUNIT_ASSERT(DRIVERFACTORY::deduceDriverTypeFromFileName("t.st.med1") == NO_DRIVER); - - //////////////////////////////////////////////////////// - // Test building drivers for different types of files // - //////////////////////////////////////////////////////// - GENDRIVER * aDriver = NULL; - - /////////////////////////////// - // Test 3: buildDriverForMed // - /////////////////////////////// - - // Obsolete, removed - - //////////////////////////////// - // Test 4: buildDriverForMesh // - //////////////////////////////// - MESH *mesh=new MESH; - - // 4.1: MED_DRIVER - - // rdonly - aDriver = DRIVERFACTORY::buildDriverForMesh - (MED_DRIVER, "anyfile", mesh, "my driver name", MED_EN::RDONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - - MED_MESH_RDONLY_DRIVER * aMedRDriverForMesh = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMedRDriverForMesh); - CPPUNIT_ASSERT(aMedRDriverForMesh->getMeshName() == "my driver name"); - - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildDriverForMesh - (MED_DRIVER, "anyfile", mesh, "my driver name", MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - MED_MESH_WRONLY_DRIVER * aMedWDriverForMesh = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMedWDriverForMesh); - CPPUNIT_ASSERT(aMedWDriverForMesh->getMeshName() == "my driver name"); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildDriverForMesh - (MED_DRIVER, "anyfile", mesh, "my driver name", MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); - - MED_MESH_RDWR_DRIVER * aMedRWDriverForMesh = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMedRWDriverForMesh); - CPPUNIT_ASSERT(aMedRWDriverForMesh->getMeshName() == "my driver name"); - - delete aDriver; aDriver=0; - - // 4.2: GIBI_DRIVER - - // rdonly - aDriver = DRIVERFACTORY::buildDriverForMesh - (GIBI_DRIVER, "anyfile", mesh, "my driver name", MED_EN::RDONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - GIBI_MESH_RDONLY_DRIVER * aGibiDriverForMesh = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aGibiDriverForMesh); - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildDriverForMesh - (GIBI_DRIVER, "anyfile", mesh, "my driver name", MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - GIBI_MESH_WRONLY_DRIVER * aGibiWRDriverForMesh = dynamic_cast(aDriver); - CPPUNIT_ASSERT(aGibiWRDriverForMesh); - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildDriverForMesh - (GIBI_DRIVER, "anyfile", mesh, "my driver name", MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); - - GIBI_MESH_RDWR_DRIVER * aGibiRWDriverForMesh = dynamic_cast(aDriver); - CPPUNIT_ASSERT(aGibiRWDriverForMesh); - delete aDriver; aDriver=0; - - // 4.3: PORFLOW_DRIVER - - // rdonly - aDriver = DRIVERFACTORY::buildDriverForMesh - (PORFLOW_DRIVER, "anyfile", mesh, "my driver name", MED_EN::RDONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - PORFLOW_MESH_RDONLY_DRIVER * aPorflowDriverForMesh = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aPorflowDriverForMesh); - - delete aDriver; aDriver=0; - - // wronly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForMesh(PORFLOW_DRIVER, "anyfile", mesh, - "my driver name", MED_EN::WRONLY), - MED_EXCEPTION); - // rdwr - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForMesh(PORFLOW_DRIVER, "anyfile", mesh, - "my driver name", MED_EN::RDWR), - MED_EXCEPTION); - - // 4.4: VTK_DRIVER - - // rdonly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForMesh(VTK_DRIVER, "anyfile", mesh, - "my driver name", MED_EN::RDONLY), - MED_EXCEPTION); - - // wronly - aDriver = DRIVERFACTORY::buildDriverForMesh - (VTK_DRIVER, "anyfile", mesh, "my driver name", MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - VTK_MESH_DRIVER * aVtkDriverForMesh = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aVtkDriverForMesh); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildDriverForMesh - (VTK_DRIVER, "anyfile", mesh, "my driver name", MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - // next string is commented by skl since VTK driver is - // created without mode - //CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); - - aVtkDriverForMesh = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aVtkDriverForMesh); - - delete aDriver; aDriver=0; - - // 4.5: ASCII_DRIVER - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForMesh(ASCII_DRIVER, "anyfile", mesh, - "my driver name", MED_EN::RDONLY), - MED_EXCEPTION); - - // 4.6: NO_DRIVER - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForMesh(NO_DRIVER, "anyfile", mesh, - "my driver name", MED_EN::RDONLY), - MED_EXCEPTION); - - ///////////////////////////////// - // Test 5: buildDriverForField // - ///////////////////////////////// - FIELD *field=new FIELD(); - - // 5.1: MED_DRIVER - - // rdonly - aDriver = DRIVERFACTORY::buildDriverForField(MED_DRIVER, "anyfile", field, MED_EN::RDONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - MED_FIELD_RDONLY_DRIVER * aMedRDriverForField = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aMedRDriverForField); - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildDriverForField(MED_DRIVER, "anyfile", field, MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - MED_FIELD_WRONLY_DRIVER * aMedWDriverForField = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aMedWDriverForField); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildDriverForField(MED_DRIVER, "anyfile", field, MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT_EQUAL(MED_EN::RDWR,aDriver->getAccessMode()); - - MED_FIELD_RDWR_DRIVER * aMedRWDriverForField = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aMedRWDriverForField); - - delete aDriver; aDriver=0; - - // 5.2: GIBI_DRIVER - - // rdonly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(GIBI_DRIVER, "anyfile", field, MED_EN::RDONLY), - MED_EXCEPTION); - // wronly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(GIBI_DRIVER, "anyfile", field, MED_EN::WRONLY), - MED_EXCEPTION); - // rdwr - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(GIBI_DRIVER, "anyfile", field, MED_EN::RDWR), - MED_EXCEPTION); - - // 5.3: PORFLOW_DRIVER - - // rdonly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(PORFLOW_DRIVER, "anyfile", - field, MED_EN::RDONLY), - MED_EXCEPTION); - // wronly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(PORFLOW_DRIVER, "anyfile", - field, MED_EN::WRONLY), - MED_EXCEPTION); - // rdwr - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(PORFLOW_DRIVER, "anyfile", - field, MED_EN::RDWR), - MED_EXCEPTION); - - // 5.4: VTK_DRIVER - - // rdonly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(VTK_DRIVER, "anyfile", field, MED_EN::RDONLY), - MED_EXCEPTION); - - // wronly - aDriver = DRIVERFACTORY::buildDriverForField(VTK_DRIVER, "anyfile", field, MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - VTK_FIELD_DRIVER * aVtkDriverForField = dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aVtkDriverForField); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildDriverForField(VTK_DRIVER, "anyfile", field, MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - // next string is commented by skl since VTK driver is - // created without mode - //CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); - - aVtkDriverForField = dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aVtkDriverForField); - - delete aDriver; aDriver=0; - - // 5.5: ASCII_DRIVER - - // rdonly - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(ASCII_DRIVER, "anyfile", field, MED_EN::RDONLY), - MED_EXCEPTION); - // rdwr - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(ASCII_DRIVER, "anyfile", field, MED_EN::RDWR), - MED_EXCEPTION); - - // wronly - // it throws on empty field - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(ASCII_DRIVER, "anyfile", field, MED_EN::WRONLY), - MED_EXCEPTION); - - // now try with valid field - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - string fieldname = "fieldcelldoublescalar"; - FIELD * aField1 = new FIELD(MED_DRIVER, filename, fieldname); - const SUPPORT * aSupport = aField1->getSupport(); - MESH * aMesh = new MESH (MED_DRIVER, filename, aSupport->getMeshName()); - aSupport->setMesh(aMesh); - - aDriver = DRIVERFACTORY::buildDriverForField(ASCII_DRIVER, "anyfile", aField1, MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - // it works! - //aDriver->open(); - //aDriver->write(); - //aDriver->close(); - - ASCII_FIELD_DRIVER * anAsciiDriverForField = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(anAsciiDriverForField); - - delete aDriver; aDriver=0; - - aField1->removeReference(); - aMesh->removeReference(); - - // 5.6: NO_DRIVER - CPPUNIT_ASSERT_THROW(DRIVERFACTORY::buildDriverForField(NO_DRIVER, "anyfile", field, MED_EN::RDONLY), - MED_EXCEPTION); - - //////////////////////////////////// - // Test 6: buildMedDriverFromFile // - //////////////////////////////////// - string aFileName1 = getResourceFile("pointe.med"); - string aFileName2 = getResourceFile("polyedres.med"); - medFileVersion version1, version2; - - try { - version1 = getMedFileVersion(aFileName1); - } catch (MEDEXCEPTION & ex) { - version1 = MED_EN::V22; - } - - try { - version2 = getMedFileVersion(aFileName2); - } catch (MEDEXCEPTION & ex) { - version2 = MED_EN::V22; - } - - // 6.1. Med file V2.1 - string aFileName21 = aFileName1; - if (version1 == MED_EN::V21 || version2 == MED_EN::V21) { - if (version1 == MED_EN::V22) - aFileName21 = aFileName2; - - } - -// // 6.2. Med file V2.2 - string aFileName22 = aFileName2; - if (version2 == MED_EN::V22 || version1 == MED_EN::V22) { - if (version2 == MED_EN::V21) - aFileName22 = aFileName1; - - } - - ///////////////////////////////////// - // Test 7: buildMeshDriverFromFile // - ///////////////////////////////////// - - // 7.1. Med file V2.1 - if (version1 == MED_EN::V21 || version2 == MED_EN::V21) { - // Obsolete, removed - } - - // 7.2. Med file V2.2 - if (version2 == MED_EN::V22 || version1 == MED_EN::V22) { - // rdonly - aDriver = DRIVERFACTORY::buildMeshDriverFromFile(aFileName22, mesh, MED_EN::RDONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName22); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - MED_MESH_RDONLY_DRIVER * aMeshRDriverForMed22 = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMeshRDriverForMed22); - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildMeshDriverFromFile(aFileName22, mesh, MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName22); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - MED_MESH_WRONLY_DRIVER * aMeshWDriverForMed22 = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMeshWDriverForMed22); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildMeshDriverFromFile(aFileName22, mesh, MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName22); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); - - MED_MESH_RDWR_DRIVER * aMeshRWDriverForMed22 = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMeshRWDriverForMed22); - - delete aDriver; aDriver=0; - } - - ////////////////////////////////////// - // Test 8: buildFieldDriverFromFile // - ////////////////////////////////////// - - // 8.1. Med file V2.1 - if (version1 == MED_EN::V21 || version2 == MED_EN::V21) { - // rdonly - aDriver = DRIVERFACTORY::buildFieldDriverFromFile(aFileName21, field, MED_EN::RDONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName21); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildFieldDriverFromFile(aFileName21, field, MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName21); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildFieldDriverFromFile(aFileName21, field, MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName21); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); // see MEDMEM_define.hxx - - delete aDriver; aDriver=0; - } - - // 8.2. Med file V2.2 - if (version2 == MED_EN::V22 || version1 == MED_EN::V22) { - // rdonly - aDriver = DRIVERFACTORY::buildFieldDriverFromFile(aFileName22, field, MED_EN::RDONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName22); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - MED_FIELD_RDONLY_DRIVER * aFieldRDriverForMed22 = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aFieldRDriverForMed22); - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildFieldDriverFromFile(aFileName22, field, MED_EN::WRONLY); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName22); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - MED_FIELD_WRONLY_DRIVER * aFieldWDriverForMed22 = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aFieldWDriverForMed22); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildFieldDriverFromFile(aFileName22, field, MED_EN::RDWR); - CPPUNIT_ASSERT(aDriver->getFileName() == aFileName22); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); // see MEDMEM_define.hxx - - MED_FIELD_RDWR_DRIVER * aFieldRWDriverForMed22 = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aFieldRWDriverForMed22); - - delete aDriver; aDriver=0; - } - - /////////////////////////////////////////// - // Test 9: buildConcreteMedDriverForMesh // - /////////////////////////////////////////// - - // 9.1. V2.1 - - // rdonly - CPPUNIT_ASSERT_THROW(aDriver = DRIVERFACTORY::buildConcreteMedDriverForMesh("anyfile", mesh, "my driver name", - MED_EN::RDONLY, MED_EN::V21), - MED_EXCEPTION); - delete aDriver; aDriver=0; - - // wronly - CPPUNIT_ASSERT_THROW(aDriver = DRIVERFACTORY::buildConcreteMedDriverForMesh("anyfile", mesh, "my driver name", - MED_EN::WRONLY, MED_EN::V21), - MED_EXCEPTION); - - delete aDriver; aDriver=0; - - // rdwr - CPPUNIT_ASSERT_THROW(aDriver = DRIVERFACTORY::buildConcreteMedDriverForMesh("anyfile", mesh, "my driver name", - MED_EN::RDWR, MED_EN::V21), - MED_EXCEPTION); - - delete aDriver; aDriver=0; - - // 9.2. V2.2 - - // rdonly - aDriver = DRIVERFACTORY::buildConcreteMedDriverForMesh("anyfile", mesh, "my driver name", - MED_EN::RDONLY, MED_EN::V22); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - MED_MESH_RDONLY_DRIVER * aMeshRDriverForMed22 = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMeshRDriverForMed22); - CPPUNIT_ASSERT(aMeshRDriverForMed22->getMeshName() == "my driver name"); - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildConcreteMedDriverForMesh("anyfile", mesh, "my driver name", - MED_EN::WRONLY, MED_EN::V22); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - MED_MESH_WRONLY_DRIVER * aMeshWDriverForMed22 = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMeshWDriverForMed22); - CPPUNIT_ASSERT(aMeshWDriverForMed22->getMeshName() == "my driver name"); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildConcreteMedDriverForMesh("anyfile", mesh, "my driver name", - MED_EN::RDWR, MED_EN::V22); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); - - MED_MESH_RDWR_DRIVER * aMeshRWDriverForMed22 = dynamic_cast (aDriver); - CPPUNIT_ASSERT(aMeshRWDriverForMed22); - CPPUNIT_ASSERT(aMeshRWDriverForMed22->getMeshName() == "my driver name"); - mesh->removeReference(); - delete aDriver; aDriver=0; - - ///////////////////////////////////////////// - // Test 10: buildConcreteMedDriverForField // - ///////////////////////////////////////////// - - // 10.1. V2.1 - - // rdonly - CPPUNIT_ASSERT_THROW(aDriver = DRIVERFACTORY::buildConcreteMedDriverForField("anyfile", field, MED_EN::RDONLY, MED_EN::V21), - MED_EXCEPTION); - delete aDriver; aDriver=0; - - // wronly - CPPUNIT_ASSERT_THROW(aDriver = DRIVERFACTORY::buildConcreteMedDriverForField("anyfile", field, MED_EN::WRONLY, MED_EN::V21), - MED_EXCEPTION); - delete aDriver; aDriver=0; - - // rdwr - CPPUNIT_ASSERT_THROW(aDriver = DRIVERFACTORY::buildConcreteMedDriverForField("anyfile", field, MED_EN::RDWR, MED_EN::V21), MED_EXCEPTION); - delete aDriver; aDriver=0; - - // 10.2. V2.2 - - // rdonly - aDriver = DRIVERFACTORY::buildConcreteMedDriverForField("anyfile", field, MED_EN::RDONLY, MED_EN::V22); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDONLY); - - MED_FIELD_RDONLY_DRIVER * aFieldRDriverForMed22 = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aFieldRDriverForMed22); - - delete aDriver; aDriver=0; - - // wronly - aDriver = DRIVERFACTORY::buildConcreteMedDriverForField("anyfile", field, MED_EN::WRONLY, MED_EN::V22); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::WRONLY); - - MED_FIELD_WRONLY_DRIVER * aFieldWDriverForMed22 = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aFieldWDriverForMed22); - - delete aDriver; aDriver=0; - - // rdwr - aDriver = DRIVERFACTORY::buildConcreteMedDriverForField("anyfile", field, MED_EN::RDWR, MED_EN::V22); - field->removeReference(); - CPPUNIT_ASSERT(aDriver->getFileName() == "anyfile"); - CPPUNIT_ASSERT(aDriver->getAccessMode() == MED_EN::RDWR); // see MEDMEM_define.hxx - - MED_FIELD_RDWR_DRIVER * aFieldRWDriverForMed22 = - dynamic_cast *> (aDriver); - CPPUNIT_ASSERT(aFieldRWDriverForMed22); - - delete aDriver; aDriver=0; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Exception.cxx b/src/MEDMEMCppTest/MEDMEMTest_Exception.cxx deleted file mode 100644 index af0f70d39..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Exception.cxx +++ /dev/null @@ -1,138 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_STRING.hxx" - -#include -#include -#include - -using namespace std; -using namespace MEDMEM; - -// #12: MEDMEM_Exception.hxx } MEDMEMTest_Exception.cxx - -/*! - * Check methods (not in spec), defined in MEDMEM_Exception.hxx: - * (+) #define LOCALIZED(message) static_cast (message) , __FILE__ , __LINE__ - * class MEDEXCEPTION : public std::exception { - * (+) MEDEXCEPTION(const char *text, const char *fileName=0, const unsigned int lineNumber=0); - * (+) MEDEXCEPTION(const MEDEXCEPTION &ex); - * (+) ~MEDEXCEPTION() throw (); - * (+) friend ostream & operator<< (ostream &os, const MEDEXCEPTION &ex); - * (+) virtual const char *what(void) const throw (); - * } - * class MED_DRIVER_NOT_FOUND_EXCEPTION : public MEDEXCEPTION { - * (+) MED_DRIVER_NOT_FOUND_EXCEPTION(const char *text, const char *fileName=0, - * const unsigned int lineNumber=0); - * (+) MED_DRIVER_NOT_FOUND_EXCEPTION(const MED_DRIVER_NOT_FOUND_EXCEPTION &ex); - * (+) ~MED_DRIVER_NOT_FOUND_EXCEPTION() throw(); - * } - * - * Use code of MEDMEM/tests/testUMedException.cxx - */ -void MEDMEMTest::testException() -{ - { - // test simple constructor - MEDEXCEPTION a = MEDEXCEPTION("test med exception"); - CPPUNIT_ASSERT(a.what()); - CPPUNIT_ASSERT(strcmp(a.what(), "MED Exception : test med exception") == 0); - - // test copy constructor - MEDEXCEPTION b (a); - CPPUNIT_ASSERT(b.what()); - CPPUNIT_ASSERT(strcmp(b.what(), "MED Exception : test med exception") == 0); - - // test dumping of exception in stream - ostringstream ostr; - ostr << b; - CPPUNIT_ASSERT(ostr.str() == "MED Exception : test med exception"); - } - - { - // test constructor from three arguments - MEDEXCEPTION c ("test med exception", ".cxx", 14); - CPPUNIT_ASSERT(c.what()); - CPPUNIT_ASSERT(strcmp(c.what(), "MED Exception in .cxx [14] : test med exception") == 0); - } - - { - // Test macro LOCALIZED - STRING msgErr; - msgErr << "ESSAI::ESSAI()! "<< 4 << "ieme essai "; - - const char* prefix = "MED Exception"; - const char* exctxt = static_cast(msgErr); - const char* filen = __FILE__; - unsigned int linen = __LINE__ + 5; - const size_t len = strlen(prefix) + strlen(exctxt) + strlen(filen) + - (1 + int(log10(float(linen)))) + 10 + 1; - char* excmsg = new char [len]; - sprintf(excmsg, "%s in %s [%u] : %s", prefix, filen, linen, exctxt); - CPPUNIT_ASSERT(strcmp(MEDEXCEPTION(LOCALIZED(msgErr)).what(), excmsg) == 0); - - delete [] excmsg; - } - - { - // Test function STRING<< - const char * LOC = "toto"; - CPPUNIT_ASSERT(MEDEXCEPTION(LOCALIZED(STRING(LOC) << " et titi")).what()); - - // Test throw - MEDEXCEPTION d (LOCALIZED(STRING(LOC) << " et titi")); - const char* dtxt = d.what(); - try { - throw d; - } - catch (MEDEXCEPTION dc) { - CPPUNIT_ASSERT(strcmp(dc.what(), dtxt) == 0); - } - catch (...) { - CPPUNIT_FAIL("Unknown exception"); - } - } - - { - // Test MED_DRIVER_NOT_FOUND_EXCEPTION - MED_DRIVER_NOT_FOUND_EXCEPTION g ("mdnfe"); - try { - throw g; - } - catch (MED_DRIVER_NOT_FOUND_EXCEPTION mdnfe) { - CPPUNIT_ASSERT(strcmp(mdnfe.what(), g.what()) == 0); - } - catch (MEDEXCEPTION me) { - CPPUNIT_FAIL(me.what()); - } - catch (...) { - CPPUNIT_FAIL("Unknown exception"); - } - - // Copy constructor - MED_DRIVER_NOT_FOUND_EXCEPTION gcopy (g); - CPPUNIT_ASSERT(gcopy.what()); - CPPUNIT_ASSERT(strcmp(gcopy.what(), g.what()) == 0); - } -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Extractor.cxx b/src/MEDMEMCppTest/MEDMEMTest_Extractor.cxx deleted file mode 100644 index a1e944361..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Extractor.cxx +++ /dev/null @@ -1,557 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEMTest_Extractor.cxx -// Created : Mon Dec 22 11:12:57 2008 -// Author : Edward AGAPOV (eap) -// -#include "MEDMEMTest.hxx" - -#include "MEDMEM_Extractor.hxx" -#include "MEDMEM_Meshing.hxx" - -#include - -using namespace std; -using namespace MEDMEM; - -//================================================================================ -/*! - * \brief test extractLine() - */ -//================================================================================ - -static void test_extractLine( Extractor* extractor, - const double* coords, const double* direction, - int nbSegments, - const char* name, - const string& result_file) -{ - FIELD* resField =0; - CPPUNIT_ASSERT_NO_THROW( resField = extractor->extractLine(coords,direction)); - CPPUNIT_ASSERT( bool( resField ) == bool( nbSegments > 0 )); - - // store extracted field - if ( resField ) - { - const GMESH* mesh = resField->getSupport()->getMesh(); - mesh->write( MED_DRIVER, result_file, name ); - resField->write(MED_DRIVER, result_file ); - - CPPUNIT_ASSERT_EQUAL( nbSegments, resField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL( nbSegments+1, resField->getSupport()->getMesh()->getNumberOfNodes()); - resField->removeReference(); - } -} - -void MEDMEMTest::testExtractor() -{ - // ======================= - // TEST 3D->2D extraction - // ======================= - - // read a mesh from a MED file - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - string fieldname = "fieldcelldoublescalar"; - - string result_file = makeTmpFile("extracted_2D.med", filename); - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(result_file); - - // field with no mesh - FIELD * aField1 = new FIELD (MED_DRIVER, filename, fieldname); - CPPUNIT_ASSERT_THROW( new Extractor(*aField1), MEDEXCEPTION); - - const SUPPORT * aSupport = aField1->getSupport(); - MESH * aMesh = new MESH(MED_DRIVER, filename, aSupport->getMeshName()); - aSupport->setMesh(aMesh); - - Extractor* extractor = 0; - CPPUNIT_ASSERT_NO_THROW( extractor = new Extractor(*aField1)); - - FIELD* resField = 0; - double coords [3] = - { - 0,0,0 - }; - { - // bad normal - double normal [3] = - { - 0,0,0 - }; - CPPUNIT_ASSERT_THROW( extractor->extractPlane(coords,normal), MEDEXCEPTION); - } - double normal [3] = - { - 10,0,0 - }; - { - // no intersection - double coords [3] = - { - 10,0,0 - }; - CPPUNIT_ASSERT_NO_THROW( resField = extractor->extractPlane(coords,normal)); - CPPUNIT_ASSERT( !bool( resField )); - } - CPPUNIT_ASSERT_NO_THROW( resField = extractor->extractPlane(coords,normal )); - - // store extracted mesh - const GMESH* mesh = resField->getSupport()->getMesh(); - mesh->write( MED_DRIVER, result_file ); - CPPUNIT_ASSERT_EQUAL( 2, mesh->getNumberOfTypes(MED_CELL)); - CPPUNIT_ASSERT_EQUAL( 6, mesh->getNumberOfElements(MED_CELL, MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL( 2, mesh->getNumberOfElements(MED_CELL, MED_QUAD4)); - - // store extracted field - resField->write(MED_DRIVER, result_file); - - delete extractor; extractor=0; - aMesh->removeReference(); aMesh=0; - resField->removeReference(); resField=0; - aField1->removeReference(); aField1=0; - - // =================================================================================== - // TEST 2D->1D extraction in 3d space - // =================================== - - // create 3d shell - int SpaceDimension = 3 ; - int NumberOfNodes = 8 ; - double Coordinates[24] = - { - 0.0, 0.0, 200, - 0.0, 0.0, 0.0, - 0.0, 200, 200, - 0.0, 200, 0.0, - 200, 0.0, 200, - 200, 0.0, 0.0, - 200, 200, 200, - 200, 200, 0.0 - }; - MESHING* myMeshing = new MESHING(); - myMeshing->setName("shell") ; - - myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates, - "CARTESIAN",MED_FULL_INTERLACE); - string Names[3] = - { - "X","Y","Z" - } ; - myMeshing->setCoordinatesNames(Names); - string Units[3] = - { - "cm","cm","cm" - } ; - myMeshing->setCoordinatesUnits(Units) ; - - // define conectivities - - const int NumberOfTypes = 1; - medGeometryElement Types[NumberOfTypes] = - { - MED_TRIA3 - }; - const int NumberOfElements[NumberOfTypes] = - { - 12 - }; - - myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL); - myMeshing->setTypes(Types,MED_CELL); - myMeshing->setNumberOfElements(NumberOfElements,MED_CELL); - - const int sizeTria = 12*3 ; - int ConnectivityTria[sizeTria]= - { - 2, 5, 1, - 4, 1, 3, - 3, 1, 7, - 4, 8, 2, - 1, 5, 7, - 6, 5, 2, - 2, 8, 6, - 8, 7, 5, - 6, 8, 5, - 2, 1, 4, - 8, 4, 7, - 4, 3, 7 - }; - myMeshing->setConnectivity(MED_CELL,MED_TRIA3,ConnectivityTria); - - // store input mesh - - fieldname = "doubleOnTria"; - result_file = makeTmpFile("extracted_1D.med"); - - // To remove tmp files from disk - aRemover.Register(result_file); - - CPPUNIT_ASSERT_NO_THROW( myMeshing->write( MED_DRIVER, result_file )); - - // Make input field - - aSupport = myMeshing->getSupportOnAll( MED_CELL ); - FIELD* inField = new FIELD( aSupport, 1 ); - inField->setName(fieldname); - string str = ""; - inField->setComponentsNames( &str ); - inField->setDescription( str ); - inField->setComponentsDescriptions( &str ); - inField->setMEDComponentsUnits( &str ); - - vector value( NumberOfElements[0] ); - for ( unsigned i = 0; i < value.size(); ++i ) - value[i] = double ( i % 10 ); - inField->setValue( &value[0] ); - - // store input field - int drv = inField->addDriver(MED_DRIVER, result_file, fieldname); - inField->write(drv); - - // Extraction - { - double coords [3] = - { - 0,0,0 - }; - double normal [3] = - { - -2, -2, 1 - }; - CPPUNIT_ASSERT_NO_THROW( extractor = new Extractor(*inField)); - CPPUNIT_ASSERT_NO_THROW( resField = extractor->extractPlane(coords,normal)); - CPPUNIT_ASSERT( bool( resField )); - } - - // store extracted mesh - mesh = resField->getSupport()->getMesh(); - mesh->write( MED_DRIVER, result_file ); - // CPPUNIT_ASSERT_EQUAL( 2, mesh->getNumberOfTypes(MED_CELL)); - // CPPUNIT_ASSERT_EQUAL( 6, mesh->getNumberOfElements(MED_CELL, MED_TRIA3)); - // CPPUNIT_ASSERT_EQUAL( 2, mesh->getNumberOfElements(MED_CELL, MED_QUAD4)); - - // store extracted field - drv = resField->addDriver(MED_DRIVER, result_file, resField->getName()); - resField->write( drv ); - - aSupport=0; - myMeshing->removeReference(); myMeshing=0; - inField->removeReference(); inField=0; - delete extractor; extractor=0; - resField->removeReference(); resField=0; - - // ====================================================================================== - // TEST 3D->1D extraction - // ======================= - - // create 3d 2x2x2 hexa box - myMeshing = new MESHING(); - { - SpaceDimension = 3 ; - NumberOfNodes = 27 ; - double Coordinates[27*3] = - { - 0.0, 0.0, 200, - 0.0, 0.0, 0.0, - 0.0, 200, 200, - 0.0, 200, 0.0, - 200, 0.0, 200, - 200, 0.0, 0.0, - 200, 200, 200, - 200, 200, 0.0, - 0.0, 0.0, 100, - 0.0, 100, 200, - 0.0, 200, 100, - 0.0, 100, 0.0, - 200, 0.0, 100, - 200, 100, 200, - 200, 200, 100, - 200, 100, 0.0, - 100, 0.0, 0.0, - 100, 0.0, 200, - 100, 200, 0.0, - 100, 200, 200, - 0.0, 100, 100, - 200, 100, 100, - 100, 0.0, 100, - 100, 200, 100, - 100, 100, 0.0, - 100, 100, 200, - 100, 100, 100, - }; - myMeshing->setName("box") ; - - myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates, - "CARTESIAN",MED_FULL_INTERLACE); - string Names[3] = - { - "X","Y","Z" - } ; - myMeshing->setCoordinatesNames(Names); - string Units[3] = - { - "cm","cm","cm" - } ; - myMeshing->setCoordinatesUnits(Units) ; - - // define conectivities - - const int NumberOfTypes = 1; - medGeometryElement Types[NumberOfTypes] = - { - MED_HEXA8 - }; - const int NumberOfElements[NumberOfTypes] = - { - 8 - }; - - myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL); - myMeshing->setTypes(Types,MED_CELL); - myMeshing->setNumberOfElements(NumberOfElements,MED_CELL); - - int ConnectivityHex[8*8]= - { - 9, 23, 18, 1, 21, 27, 26, 10, - 25, 16, 22, 27, 19, 8, 15, 24, - 27, 22, 14, 26, 24, 15, 7, 20, - 17, 6, 13, 23, 25, 16, 22, 27, - 21, 27, 26, 10, 11, 24, 20, 3, - 2, 17, 23, 9, 12, 25, 27, 21, - 23, 13, 5, 18, 27, 22, 14, 26, - 12, 25, 27, 21, 4, 19, 24, 11 - }; - myMeshing->setConnectivity(MED_CELL,MED_HEXA8,ConnectivityHex); - } - // store input mesh - - fieldname = "doubleOnHex"; - result_file = makeTmpFile("extracted3D_1D.med"); - - // To remove tmp files from disk - aRemover.Register(result_file); - - drv = myMeshing->addDriver( MED_DRIVER, result_file, myMeshing->getName() ); - CPPUNIT_ASSERT_NO_THROW( myMeshing->write(drv) ); - - // Make input field - - aSupport = myMeshing->getSupportOnAll( MED_CELL ); - inField = new FIELD( aSupport, 1 ); - inField->setName(fieldname); - inField->setComponentsNames( &str ); - inField->setDescription( str ); - inField->setComponentsDescriptions( &str ); - inField->setMEDComponentsUnits( &str ); - - value.resize( NumberOfElements[0] ); - for ( unsigned i = 0; i < value.size(); ++i ) - value[i] = double (i+1); - inField->setValue( &value[0] ); - // store input field - drv = inField->addDriver(MED_DRIVER, result_file, fieldname); - inField->write(drv); - - // Extraction - CPPUNIT_ASSERT_NO_THROW( extractor = new Extractor(*inField)); - { - // Test corner-corner intersection - double coords [3] = - { - 1, 1, 1 - }; - double direct [3] = - { - 2, 2, 2 - }; - test_extractLine( extractor, coords, direct, 2, "corner-corner", result_file ); - } - { - // Test corner-face intersection - double coords [3] = - { - 0,0,0 - }; - double direct [3] = - { - 2, 1, 1 - }; - test_extractLine( extractor, coords, direct, 2, "corner-face", result_file ); - } - { - // Test on-face intersection - double coords [3] = - { - -2, 0,-1 - }; - double direct [3] = - { - 2, 0, 1 - }; - test_extractLine( extractor, coords, direct, 2, "on-face", result_file ); - } - { - // Test between-cells intersection - double coords [3] = - { - 100,0,0 - }; - double direct [3] = - { - 0, 2, 2 - }; - test_extractLine( extractor, coords, direct, 2, "between-cells", result_file ); - } - { - // Test between-cells-entrance intersection - double coords [3] = - { - 100,0,0 - }; - double direct [3] = - { - 1, 2, 2 - }; - test_extractLine( extractor, coords, direct, 2, "between-cells-entrance", result_file ); - } - { - // Test edge-entrance intersection - double coords [3] = - { - 100,0,50 - }; - double direct [3] = - { - 1, 2, 2 - }; - test_extractLine( extractor, coords, direct, 3, "edge-entrance", result_file ); - } - { - // Test touch intersection - expect no result - double coords [3] = - { - 0,0,0 - }; - double direct [3] = - { - 0, 2, -2 - }; - test_extractLine( extractor, coords, direct, 0, "touch", result_file ); - } - { - // Test face-face intersection - double coords [3] = - { - 50,50,0 - }; - double direct [3] = - { - 2, 2, 0 - }; - test_extractLine( extractor, coords, direct, 2, "corner-corner-on", result_file ); - } - { - // Test face-face intersection - double coords [3] = - { - 50,50,0 - }; - double direct [3] = - { - 2, 2, 2 - }; - test_extractLine( extractor, coords, direct, 3, "face-face", result_file ); - } - { - // Test external edge intersection - double coords [3] = - { - 0, 0,200 - }; - double direct [3] = - { - -1, 0, 0 - }; - test_extractLine( extractor, coords, direct, 2, "external edge", result_file ); - } - { - // Test internal edge intersection - double coords [3] = - { - 100,0,100 - }; - double direct [3] = - { - 0, -2, 0 - }; - test_extractLine( extractor, coords, direct, 2, "internal edge", result_file ); - } - - inField->setSupport(0); - aSupport=0; - delete extractor; extractor=0; - myMeshing->removeReference(); myMeshing=0; - - // ====================================================================================== - // TEST 3D->1D extraction on a large model - // ======================================= - - // read a mesh - filename = getResourceFile("geomMesh22.med"); - meshname = "GeomMesh"; - aMesh = new MESH(MED_DRIVER, filename, meshname); - aSupport = aMesh->getSupportOnAll( MED_CELL ); - - // make a field - int nbValues = aSupport->getNumberOfElements(MED_ALL_ELEMENTS); - inField->setSupport( aSupport ); - inField->allocValue( 1, nbValues ); - { - double* value = const_cast( inField->getValue() ); - for ( int i = 0; i < nbValues; ++i ) - value[i] = double ( i % 7 ); - } - // extract a field - CPPUNIT_ASSERT_NO_THROW( extractor = new Extractor(*inField)); - { - double coords [3] = - { - 20,0,10 - }; - double direct [3] = - { - 1, 1,1.5 - }; - CPPUNIT_ASSERT_NO_THROW( resField = extractor->extractLine(coords,direct)); - } - CPPUNIT_ASSERT( resField ); - CPPUNIT_ASSERT_EQUAL( 31, resField->getSupport()->getNumberOfElements(MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL( 33, resField->getSupport()->getMesh()->getNumberOfNodes()); - delete extractor; - resField->removeReference(); resField=0; - aMesh->removeReference(); aMesh=0; - aSupport=0; - inField->removeReference(); inField=0; -} - diff --git a/src/MEDMEMCppTest/MEDMEMTest_Family.cxx b/src/MEDMEMCppTest/MEDMEMTest_Family.cxx deleted file mode 100644 index 6da66db2b..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Family.cxx +++ /dev/null @@ -1,410 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Support.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #13: MEDMEM_Family.hxx } MEDMEMTest_Family.cxx - -/*! - * Check methods (24), defined in MEDMEM_Family.hxx: - * class FAMILY : virtual public SUPPORT { - * (+) FAMILY(); - * (+) FAMILY(MESH* Mesh, int Identifier, string Name, - * int NumberOfAttribute, int *AttributeIdentifier, - * int *AttributeValue, string AttributeDescription, - * int NumberOfGroup, string GroupName, - * int * MEDArrayNodeFamily, int ** MEDArrayCellFamily, - * int ** MEDArrayFaceFamily, int ** MEDArrayEdgeFamily); - * (+) FAMILY(const FAMILY & m); - * (+) FAMILY(const SUPPORT & s); - * (+) virtual ~FAMILY(); - * - * // Does not work (Segmentation Fault of Hang up) - * (!) FAMILY & operator=(const FAMILY &fam); - * - * (+) friend ostream & operator<<(ostream &os, FAMILY &my); - * (+) friend ostream & operator<<(ostream &os, const FAMILY &my); - * - * (+) bool build(MED_EN::medEntityMesh Entity,int **FamilyNumber); - * - * (+) inline void setIdentifier (int Identifier); - * (+) inline void setNumberOfAttributes (int NumberOfAttribute); - * (+) inline void setAttributesIdentifiers (int * AttributeIdentifier); - * (+) inline void setAttributesValues (int * AttributeValue); - * (+) inline void setAttributesDescriptions (string * AttributeDescription); - * (+) inline void setNumberOfGroups (int NumberOfGroups); - * (+) inline void setGroupsNames (string * GroupName); - * - * (+) inline int getIdentifier() const; - * (+) inline int getNumberOfAttributes() const; - * (+) inline const int * getAttributesIdentifiers() const; - * (+) inline const int * getAttributesValues() const; - * (+) inline const string * getAttributesDescriptions() const; - * (+) inline int getNumberOfGroups() const; - * (+) inline const string * getGroupsNames() const; - * - * (+) inline int getAttributeIdentifier(int i) const; - * (+) inline int getAttributeValue(int i) const; - * (+) inline string getAttributeDescription(int i) const; - * (+) inline string getGroupName(int i) const; - * } - * - * Use code of MEDMEM/test_copie_family.cxx - */ -static void check_support(const SUPPORT * theSupport, - string theName, string theDescr, MED_EN::medEntityMesh theEntity, int theNbTypes) -{ - string aName = theSupport->getName(); - string aDescr = theSupport->getDescription(); - MED_EN::medEntityMesh anEntity = theSupport->getEntity(); - int aNbGeomTypes = theSupport->getNumberOfTypes(); - - CPPUNIT_ASSERT_EQUAL(theName, aName); - CPPUNIT_ASSERT_EQUAL(theDescr, aDescr); - CPPUNIT_ASSERT_EQUAL(theEntity, anEntity); - CPPUNIT_ASSERT_EQUAL(theNbTypes, aNbGeomTypes); -} - -static void check_famille(const FAMILY * theFamily, - string theName, string theDescr, MED_EN::medEntityMesh theEntity, int theNbTypes, - int theID, int theNbAttributes, int theNbGroups) -{ - check_support(theFamily, theName, theDescr, theEntity, theNbTypes); - - // identifier - int id = theFamily->getIdentifier(); - int nbAttributes = theFamily->getNumberOfAttributes(); - int nbGroups = theFamily->getNumberOfGroups(); - - CPPUNIT_ASSERT_EQUAL(theID, id); - CPPUNIT_ASSERT_EQUAL(theNbAttributes, nbAttributes); - CPPUNIT_ASSERT_EQUAL(theNbGroups, nbGroups); -} - -void MEDMEMTest::testFamily() -{ - /////////////////////////////////// - // TEST 1: test_copie_family.cxx // - /////////////////////////////////// - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - - MESH * aMesh = new MESH; - aMesh->setName(meshname); - MED_MESH_RDONLY_DRIVER aMeshDriver (filename, aMesh); - aMeshDriver.setMeshName(meshname); - aMeshDriver.open(); - aMeshDriver.read(); - aMeshDriver.close(); - - const FAMILY * aFamily1 = aMesh->getFamily(MED_EN::MED_NODE, 1); - - // SUPPORT attributes - string aName = aFamily1->getName(); - string aDescr = aFamily1->getDescription(); - MED_EN::medEntityMesh anEntity = aFamily1->getEntity(); - int aNbGeomTypes = aFamily1->getNumberOfTypes(); - - // FAMILY attributes - int id = aFamily1->getIdentifier(); - int nbAttributes = aFamily1->getNumberOfAttributes(); - int nbGroups = aFamily1->getNumberOfGroups(); - - // Dump - ostringstream ostr1; - ostr1 << *aFamily1; - CPPUNIT_ASSERT(ostr1.str() != ""); - - check_famille(aFamily1, - aName, aDescr, anEntity, aNbGeomTypes, - id, nbAttributes, nbGroups); - - // Copy constructor - FAMILY * aFamily2 = new FAMILY (* aFamily1); - - // Dump - ostringstream ostr2; - ostr2 << *aFamily2; - CPPUNIT_ASSERT(ostr1.str() == ostr2.str()); - - // Compare supports - CPPUNIT_ASSERT(aFamily2->deepCompare(*aFamily1)); - - check_famille(aFamily2, - aName, aDescr, anEntity, aNbGeomTypes, - id, nbAttributes, nbGroups); - - // One more copy - FAMILY * aFamily3 = new FAMILY (* aFamily2); - aFamily2->removeReference(); - - // Dump - ostringstream ostr3; - ostr3 << *aFamily3; - CPPUNIT_ASSERT(ostr1.str() == ostr3.str()); - - check_famille(aFamily3, - aName, aDescr, anEntity, aNbGeomTypes, - id, nbAttributes, nbGroups); - - - //////////// - // TEST 2 // - //////////// - { - // Prepare data - - // attributes - int newNumberOfAttribute = 3; - int * newAttributeIdentifier = new int[newNumberOfAttribute]; - int * newAttributeValue = new int[newNumberOfAttribute]; - string * newAttributeDescription = new string[newNumberOfAttribute]; - - char tmp [32]; - for (int i = 0; i < newNumberOfAttribute; i++) { - newAttributeIdentifier[i] = i+1; - newAttributeValue[i] = (i+1)*10; - sprintf(tmp, "Attribut N° %d", i+1); - newAttributeDescription[i] = tmp; - } - - // groups - int newNumberOfGroups = 4; - string * newGroups = new string[newNumberOfGroups]; - for (int i = 0; i < newNumberOfGroups; i++) { - sprintf(tmp, "Group N° %d", i+1); - newGroups[i] = tmp; - } - - // Change aFamily3 - - // attributes - aFamily3->setNumberOfAttributes(newNumberOfAttribute); - aFamily3->setAttributesIdentifiers(newAttributeIdentifier); - aFamily3->setAttributesValues(newAttributeValue); - aFamily3->setAttributesDescriptions(newAttributeDescription); - - // groups - aFamily3->setNumberOfGroups(newNumberOfGroups); - aFamily3->setGroupsNames(newGroups, /*giveOwnership = */true); - - // identifier - aFamily3->setIdentifier(77); - - // check new parameters of aFamily3 - - // attributes - CPPUNIT_ASSERT_EQUAL(newNumberOfAttribute, aFamily3->getNumberOfAttributes()); - const int * newAttributeIdentifierBack = aFamily3->getAttributesIdentifiers(); - const int * newAttributeValueBack = aFamily3->getAttributesValues(); - const string * newAttributeDescriptionBack = aFamily3->getAttributesDescriptions(); - for (int i = 1; i <= newNumberOfAttribute; i++) { - sprintf(tmp, "Attribut N° %d", i); - string descr (tmp); - - CPPUNIT_ASSERT_EQUAL(i , aFamily3->getAttributeIdentifier(i)); - CPPUNIT_ASSERT_EQUAL(i*10 , aFamily3->getAttributeValue(i)); - CPPUNIT_ASSERT_EQUAL(descr, aFamily3->getAttributeDescription(i)); - - CPPUNIT_ASSERT_EQUAL(i , newAttributeIdentifierBack[i - 1]); - CPPUNIT_ASSERT_EQUAL(i*10 , newAttributeValueBack[i - 1]); - CPPUNIT_ASSERT_EQUAL(descr, newAttributeDescriptionBack[i - 1]); - } - - // next string is commented since this pointer is shared - // by Family3 and in future during deleting of Family3 - // we recieve error - delete [] newAttributeDescription; - - // groups - CPPUNIT_ASSERT_EQUAL(newNumberOfGroups, aFamily3->getNumberOfGroups()); - const string * newGroupsBack = aFamily3->getGroupsNames(); - for (int i = 1; i <= newNumberOfGroups; i++) { - sprintf(tmp, "Group N° %d", i); - string grp (tmp); - - CPPUNIT_ASSERT_EQUAL(grp, aFamily3->getGroupName(i)); - CPPUNIT_ASSERT_EQUAL(grp, newGroupsBack[i - 1]); - } - - // identifier - CPPUNIT_ASSERT_EQUAL(77, aFamily3->getIdentifier()); - } - - ///////////////////////////////////////////////////// - // TEST 3: check default constructor and operator= // - ///////////////////////////////////////////////////// - { - FAMILY *aFamily4=new FAMILY; - *aFamily4 = (const FAMILY &)*aFamily3; - aFamily4->removeReference(); - } - - /////////////////////////////////////////////////// - // TEST 4: check construction from given support // - /////////////////////////////////////////////////// - { - SUPPORT *s1=new SUPPORT(*aFamily3); - FAMILY *f1=new FAMILY(*s1); - CPPUNIT_ASSERT_EQUAL(0, f1->getIdentifier()); - CPPUNIT_ASSERT_EQUAL(0, f1->getNumberOfAttributes()); - CPPUNIT_ASSERT_EQUAL(0, f1->getNumberOfGroups()); - CPPUNIT_ASSERT(s1->deepCompare(*f1)); - s1->removeReference(); - f1->removeReference(); - } - - aFamily3->removeReference(); - aMesh->removeReference(); - - ///////////////////////////////////////////////////////////////// - // TEST 5: check constructor, designed to use with med driver. // - ///////////////////////////////////////////////////////////////// - { - MESH * aTestMesh = MEDMEMTest_createTestMesh(); - - // TestMesh families. Let's imagine that we would like to have - // the following nodes and elements distribution by families: - - // NumberOfNodes = 19; - int aNodeFamily[19] = {1, 1, 1, 1, 1, 1, 1, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 3, 3, 3}; - - // NumberOfCellTypes = 3; - // NumberOfCells[NumberOfCellTypes] = {12, 2, 2}; - int aCellType1Family[12] = {4,4,4,4,4,5,5,5,5,5,5,5}; - int aCellType2Family[ 2] = {5,6}; - int aCellType3Family[ 2] = {6,6}; - int * aCellFamily[3] = {aCellType1Family, aCellType2Family, aCellType3Family}; - - // NumberOfFaceTypes = 2; - // NumberOfFaces[NumberOfFaceTypes] = {4, 4}; - int aFaceType1Family[4] = {7,7,7,7}; - int aFaceType2Family[4] = {7,7,7,7}; - int * aFaceFamily[3] = {aFaceType1Family, aFaceType2Family}; - - // No edges in aTestMesh - int ** anEdgeFamily = NULL; - - // new families data - int attrId[2] = {1,2}; - int attrVa[2] = {7,8}; - - string attrDescr1 ("Attribute 1 description"); - string attrDescr2 ("Attribute 2 description"); - string attrDescrEmpty (MED_COMMENT_SIZE - 23, ' '); - attrDescr1 += attrDescrEmpty; - attrDescr2 += attrDescrEmpty; - CPPUNIT_ASSERT(MED_COMMENT_SIZE == attrDescr1.length()); - CPPUNIT_ASSERT(MED_COMMENT_SIZE == attrDescr2.length()); - string attrDescr = attrDescr1 + attrDescr2; - - string groupName1 ("Group_1"); - string groupName2 ("Group_2"); - string groupName3 ("Group_3"); - string groupNameEmpty (MED_LNAME_SIZE - 7, ' '); - groupName1 += groupNameEmpty; - groupName2 += groupNameEmpty; - groupName3 += groupNameEmpty; - CPPUNIT_ASSERT(MED_LNAME_SIZE == groupName1.length()); - CPPUNIT_ASSERT(MED_LNAME_SIZE == groupName2.length()); - CPPUNIT_ASSERT(MED_LNAME_SIZE == groupName3.length()); - string groupNames = groupName1 + groupName2 + groupName3; - - // nodes family 1 - FAMILY *aNodesF1=new FAMILY(aTestMesh, /*Identifier*/1, "Nodes 1", - /*NumberOfAttribute*/2, attrId, attrVa, attrDescr, - /*NumberOfGroup*/3, groupNames, - aNodeFamily, aCellFamily, aFaceFamily, anEdgeFamily); - - - CPPUNIT_ASSERT_EQUAL(1, aNodesF1->getIdentifier()); - CPPUNIT_ASSERT(strcmp("Nodes 1", aNodesF1->getName().c_str()) == 0); - CPPUNIT_ASSERT(MED_EN::MED_NODE == aNodesF1->getEntity()); - CPPUNIT_ASSERT(!aNodesF1->isOnAllElements()); - CPPUNIT_ASSERT_EQUAL(7, aNodesF1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - CPPUNIT_ASSERT_EQUAL(2, aNodesF1->getNumberOfAttributes()); - CPPUNIT_ASSERT_EQUAL(1, aNodesF1->getAttributeIdentifier(1)); - CPPUNIT_ASSERT_EQUAL(2, aNodesF1->getAttributeIdentifier(2)); - CPPUNIT_ASSERT_EQUAL(7, aNodesF1->getAttributeValue(1)); - CPPUNIT_ASSERT_EQUAL(8, aNodesF1->getAttributeValue(2)); - CPPUNIT_ASSERT_EQUAL(attrDescr1, aNodesF1->getAttributeDescription(1)); - CPPUNIT_ASSERT_EQUAL(attrDescr2, aNodesF1->getAttributeDescription(2)); - - CPPUNIT_ASSERT_EQUAL(3, aNodesF1->getNumberOfGroups()); - CPPUNIT_ASSERT_EQUAL(groupName1, aNodesF1->getGroupName(1)); - CPPUNIT_ASSERT_EQUAL(groupName2, aNodesF1->getGroupName(2)); - CPPUNIT_ASSERT_EQUAL(groupName3, aNodesF1->getGroupName(3)); - aNodesF1->removeReference(); - - // faces family 7 - FAMILY *aFacesF7=new FAMILY(aTestMesh, /*Identifier*/7, "Faces All", - /*NumberOfAttribute*/2, attrId, attrVa, attrDescr, - /*NumberOfGroup*/3, groupNames, - aNodeFamily, aCellFamily, aFaceFamily, anEdgeFamily); - - - CPPUNIT_ASSERT_EQUAL(7, aFacesF7->getIdentifier()); - CPPUNIT_ASSERT(strcmp("Faces All", aFacesF7->getName().c_str()) == 0); - CPPUNIT_ASSERT(MED_EN::MED_FACE == aFacesF7->getEntity()); - - CPPUNIT_ASSERT_EQUAL(8, aTestMesh->getNumberOfElements(MED_EN::MED_FACE, - MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(8, aFacesF7->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - CPPUNIT_ASSERT(!aFacesF7->isOnAllElements()); - - CPPUNIT_ASSERT_EQUAL(2, aFacesF7->getNumberOfAttributes()); - CPPUNIT_ASSERT_EQUAL(1, aFacesF7->getAttributeIdentifier(1)); - CPPUNIT_ASSERT_EQUAL(2, aFacesF7->getAttributeIdentifier(2)); - CPPUNIT_ASSERT_EQUAL(7, aFacesF7->getAttributeValue(1)); - CPPUNIT_ASSERT_EQUAL(8, aFacesF7->getAttributeValue(2)); - CPPUNIT_ASSERT_EQUAL(attrDescr1, aFacesF7->getAttributeDescription(1)); - CPPUNIT_ASSERT_EQUAL(attrDescr2, aFacesF7->getAttributeDescription(2)); - - CPPUNIT_ASSERT_EQUAL(3, aFacesF7->getNumberOfGroups()); - CPPUNIT_ASSERT_EQUAL(groupName1, aFacesF7->getGroupName(1)); - CPPUNIT_ASSERT_EQUAL(groupName2, aFacesF7->getGroupName(2)); - CPPUNIT_ASSERT_EQUAL(groupName3, aFacesF7->getGroupName(3)); - aFacesF7->removeReference(); - aTestMesh->removeReference(); - - // Method build() is not tested directly, but it is called from constructor, tested here - } -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Family_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_Family_fault.cxx deleted file mode 100644 index d911a4355..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Family_fault.cxx +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEMTest_Utils.hxx" - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char** argv) -{ - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - - MESH * aMesh = new MESH; - aMesh->setName(meshname); - MED_MESH_RDONLY_DRIVER aMeshDriver (filename, aMesh); - aMeshDriver.setMeshName(meshname); - aMeshDriver.open(); - aMeshDriver.read(); - aMeshDriver.close(); - - const FAMILY * aFamily1 = aMesh->getFamily(MED_EN::MED_NODE, 1); - - // check default constructor and operator= - FAMILY *aFamily4=new FAMILY; - - // (BUG) Wrong implementation or usage of PointerOf. - // Do not use memcpy() with array of std::string! - // Impossible to use FAMILY::operator=! - *aFamily4 = *aFamily1; - aFamily4->removeReference(); - - /*{ - int nb = 3; - string * str = new string[nb]; - - char tmp_str [32]; - for (int i = 0; i < nb; i++) { - sprintf(tmp_str, "My String N° %d", i+1); - str[i] = tmp; - } - - // bad - string* _pointer; - _pointer = new string[3]; - // This is wrong, because class string is not simple type - // and can have pointers to some data, deallocated in it's destructor, - // which (data) will not be copied by this operation. - memcpy(_pointer, str, 3*sizeof(string)); - delete [] _pointer; - - // good - //PointerOf p1 (1); - //PointerOf p2 (20); - //p2 = newAttributeValue; - //p1.set(3, p2); - - // bad - //PointerOf p1 (1); - //PointerOf p2 (20); - //p2 = str; - //p1.set(3, p2); - - delete [] str; - } - */ - - aMesh->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Field.cxx b/src/MEDMEMCppTest/MEDMEMTest_Field.cxx deleted file mode 100644 index 419971176..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Field.cxx +++ /dev/null @@ -1,2817 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" - -#include "MEDMEM_FieldConvert.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_VtkMeshDriver.hxx" - - -#include -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #14,15: MEDMEMTest_Field.cxx -// Check methods from MEDMEM_Field.hxx, MEDMEM_FieldConvert.hxx - -/*! - * Check methods (48), defined in MEDMEM_Field.hxx: - * class FIELD_ -{ - * (+) FIELD_(); - * (+) FIELD_(const SUPPORT * Support, const int NumberOfComponents); - * (+) FIELD_(const FIELD_ &m); - * (+) virtual ~FIELD_(); - * (+) FIELD_& operator=(const FIELD_ &m); - * - * (-) virtual void rmDriver(int index=0); - * (-) virtual int addDriver(driverTypes driverType, - * const string & fileName="Default File Name.med", - * const string & driverFieldName="Default Field Nam", - * MED_EN::med_mode_acces access=MED_EN::MED_REMP); - * (-) virtual int addDriver(GENDRIVER & driver); - * - * (-) virtual void read (const GENDRIVER &); - * (-) virtual void read(int index=0); - * (-) virtual void openAppend(void); - * (-) virtual void write(const GENDRIVER &); - * (-) virtual void write(int index=0, const string & driverName=""); - * (-) virtual void writeAppend(const GENDRIVER &); - * (-) virtual void writeAppend(int index=0, const string & driverName=""); - * - * (+) inline void setName(const string Name); - * (+) inline string getName() const; - * (+) inline void setDescription(const string Description); - * (+) inline string getDescription() const; - * (+) inline const SUPPORT * getSupport() const; - * (+) inline void setSupport(const SUPPORT * support); - * (+) inline void setNumberOfComponents(const int NumberOfComponents); - * (+) inline int getNumberOfComponents() const; - * (+) inline void setNumberOfValues(const int NumberOfValues); - * (+) inline int getNumberOfValues() const; - * (+) inline void setComponentsNames(const string * ComponentsNames); - * (+) inline void setComponentName(int i, const string ComponentName); - * (+) inline const string * getComponentsNames() const; - * (+) inline string getComponentName(int i) const; - * (+) inline void setComponentsDescriptions(const string * ComponentsDescriptions); - * (+) inline void setComponentDescription(int i, const string ComponentDescription); - * (+) inline const string * getComponentsDescriptions() const; - * (+) inline string getComponentDescription(int i) const; - * (+) inline void setComponentsUnits(const UNIT * ComponentsUnits); - * (+) inline const UNIT * getComponentsUnits() const; - * (+) inline const UNIT * getComponentUnit(int i) const; - * (+) inline void setMEDComponentsUnits(const string * MEDComponentsUnits); - * (+) inline void setMEDComponentUnit(int i, const string MEDComponentUnit); - * (+) inline const string * getMEDComponentsUnits() const; - * (+) inline string getMEDComponentUnit(int i) const; - * - * (+) inline void setIterationNumber(int IterationNumber); - * (+) inline int getIterationNumber() const; - * (+) inline void setTime(double Time); - * (+) inline double getTime() const; - * (+) inline void setOrderNumber(int OrderNumber); - * (+) inline int getOrderNumber() const; - * - * (+) inline MED_EN::med_type_champ getValueType () const; - * (+) inline MED_EN::medModeSwitch getInterlacingType() const; - * (-) virtual inline bool getGaussPresence() const throw (MEDEXCEPTION); - * -} - * - * template class FIELD : public FIELD_ -{ - * (+) FIELD(); - * (+) FIELD(const FIELD &m); - * (+) FIELD(const SUPPORT * Support, const int NumberOfComponents) throw (MEDEXCEPTION); - * (+) FIELD(driverTypes driverType, - * const string & fileName, const string & fieldDriverName, - * const int iterationNumber=-1, const int orderNumber=-1) throw (MEDEXCEPTION); - * (+) FIELD(const SUPPORT * Support, driverTypes driverType, - * const string & fileName="", const string & fieldName="", - * const int iterationNumber = -1, const int orderNumber = -1) throw (MEDEXCEPTION); - * (+) ~FIELD(); - * (+) FIELD & operator=(const FIELD &m); - * - * (+) const FIELD operator+(const FIELD& m) const; - * (+) const FIELD operator-(const FIELD& m) const; - * (+) const FIELD operator*(const FIELD& m) const; - * (+) const FIELD operator/(const FIELD& m) const; - * (+) const FIELD operator-() const; - * (+) FIELD& operator+=(const FIELD& m); - * (+) FIELD& operator-=(const FIELD& m); - * (+) FIELD& operator*=(const FIELD& m); - * (+) FIELD& operator/=(const FIELD& m); - * - * (+) static FIELD* add(const FIELD& m, const FIELD& n); - * (+) static FIELD* addDeep(const FIELD& m, const FIELD& n); - * (+) static FIELD* sub(const FIELD& m, const FIELD& n); - * (+) static FIELD* subDeep(const FIELD& m, const FIELD& n); - * (+) static FIELD* mul(const FIELD& m, const FIELD& n); - * (+) static FIELD* mulDeep(const FIELD& m, const FIELD& n); - * (+) static FIELD* div(const FIELD& m, const FIELD& n); - * (+) static FIELD* divDeep(const FIELD& m, const FIELD& n); - * - * (+) double normMax() const throw (MEDEXCEPTION); - * (+) double norm2() const throw (MEDEXCEPTION); - * - * (+) void applyLin(T a, T b); - * (+) template void applyFunc(); - * (+) void applyPow(T scalar); - * - * (+) static FIELD* scalarProduct(const FIELD& m, const FIELD& n, bool deepCheck=false); - * - * (+) double normL2(int component, const FIELD * p_field_volume=NULL) const; - * (+) double normL2(const FIELD * p_field_volume=NULL) const; - * (+) double normL1(int component, const FIELD * p_field_volume=NULL) const; - * (+) double normL1(const FIELD * p_field_volume=NULL) const; - * - * (+) FIELD* extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION); - * - * (EMPTY COMMENT, EMPTY IMPLEMENTATION!!!) void init (); - * - * (+) void rmDriver(int index=0); - * (+) int addDriver(driverTypes driverType, - * const string & fileName="Default File Name.med", - * const string & driverFieldName="Default Field Name", - * MED_EN::med_mode_acces access=MED_EN::MED_REMP); - * (+) int addDriver(GENDRIVER & driver); - * - * (+) void allocValue(const int NumberOfComponents); - * (+) void allocValue(const int NumberOfComponents, const int LengthValue); - * (+) void deallocValue(); - * - * (+) inline void read(int index=0); - * (+) inline void read(const GENDRIVER & genDriver); - * (+) inline void read(driverTypes driverType, const std::string& filename); - * (+) inline void write(int index=0); - * (+) inline void write(const GENDRIVER &, - * MED_EN::med_mode_acces medMode=MED_EN::RDWR); - * (+) inline void write(driverTypes driverType, const std::string& filename, - * MED_EN::med_mode_acces medMode=MED_EN::RDWR); - * (+) inline void writeAppend(int index=0, const string & driverName = ""); - * (+) inline void writeAppend(const GENDRIVER &); - * - * (+) inline MEDMEM_Array_ * getArray() const throw (MEDEXCEPTION); - * (+) inline ArrayGauss * getArrayGauss() const throw (MEDEXCEPTION); - * (+) inline ArrayNoGauss * getArrayNoGauss() const throw (MEDEXCEPTION); - * (+) inline bool getGaussPresence() const throw (MEDEXCEPTION); - * - * (+) inline int getValueLength() const throw (MEDEXCEPTION); - * (+) inline const T* getValue() const throw (MEDEXCEPTION); - * (+) inline const T* getRow(int i) const throw (MEDEXCEPTION); - * (+) inline const T* getColumn(int j) const throw (MEDEXCEPTION); - * (+) inline T getValueIJ(int i,int j) const throw (MEDEXCEPTION); - * (+) inline T getValueIJK(int i,int j,int k) const throw (MEDEXCEPTION); - * (+) bool getValueOnElement(int eltIdInSup,T* retValues) const throw (MEDEXCEPTION); - * - * (+) const int getNumberOfGeometricTypes() const throw (MEDEXCEPTION); - * - * (+) const GAUSS_LOCALIZATION & getGaussLocalization - * (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - * (+) const GAUSS_LOCALIZATION * getGaussLocalizationPtr - * (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - * (+) void setGaussLocalization(MED_EN::medGeometryElement geomElement, - * const GAUSS_LOCALIZATION & gaussloc); - * (+) const int * getNumberOfGaussPoints() const throw (MEDEXCEPTION); - * (+) const int getNumberOfGaussPoints - * (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - * (+) const int getNbGaussI(int i) const throw (MEDEXCEPTION); - * - * (+) const int * getNumberOfElements() const throw (MEDEXCEPTION); - * (+) const MED_EN::medGeometryElement * getGeometricTypes() const throw (MEDEXCEPTION); - * (+) bool isOnAllElements() const throw (MEDEXCEPTION); - * - * (+) inline void setArray(MEDMEM_Array_ *value) throw (MEDEXCEPTION); - * (+) FIELD* getGaussPointsCoordinates() const throw (MEDEXCEPTION); - * (+) inline void setValue(T* value) throw (MEDEXCEPTION); - * (+) inline void setRow(int i, T* value) throw (MEDEXCEPTION); - * (+) inline void setColumn(int i, T* value) throw (MEDEXCEPTION); - * (+) inline void setValueIJ(int i, int j, T value) throw (MEDEXCEPTION); - * - * (NOT IMPLEMENTED!!!) void getVolume() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getArea() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getLength() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getNormal() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getBarycenter() const throw (MEDEXCEPTION); - * - * (+) void fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION); - * -} - * - * Use code of test_operation_fieldint.cxx - * test_operation_fielddouble.cxx - * test_copie_field_.cxx - * test_copie_fieldT.cxx - */ - static void compareField_(const FIELD_ * theField_1, const FIELD_ * theField_2, bool isFIELD, bool isValue) -{ - // name, description, support - CPPUNIT_ASSERT_EQUAL(theField_1->getName(), theField_2->getName()); - CPPUNIT_ASSERT_EQUAL(theField_1->getDescription(), theField_2->getDescription()); - CPPUNIT_ASSERT_EQUAL(theField_1->getSupport(), theField_2->getSupport()); - - // components information - int aNbComps = theField_1->getNumberOfComponents(); - CPPUNIT_ASSERT_EQUAL(aNbComps, theField_2->getNumberOfComponents()); - - for (int i = 1; i <= aNbComps; i++) - { - CPPUNIT_ASSERT_EQUAL(theField_1->getComponentName(i), theField_2->getComponentName(i)); - CPPUNIT_ASSERT_EQUAL(theField_1->getComponentDescription(i), theField_2->getComponentDescription(i)); - CPPUNIT_ASSERT_EQUAL(theField_1->getMEDComponentUnit(i), theField_2->getMEDComponentUnit(i)); - } - - // iteration information - CPPUNIT_ASSERT_EQUAL(theField_1->getIterationNumber(), theField_2->getIterationNumber()); - CPPUNIT_ASSERT_EQUAL(theField_1->getOrderNumber(), theField_2->getOrderNumber()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(theField_1->getTime(), theField_2->getTime(), 0.0000001); - - // Value - int nbOfValues = theField_1->getNumberOfValues(); - CPPUNIT_ASSERT_EQUAL(nbOfValues, theField_2->getNumberOfValues()); - - if (isFIELD) - { - // Value type and Interlacing type - CPPUNIT_ASSERT_EQUAL(theField_1->getValueType(), theField_2->getValueType()); - CPPUNIT_ASSERT_EQUAL(theField_1->getInterlacingType(), theField_2->getInterlacingType()); - - // Gauss Presence - if (isValue) - { - CPPUNIT_ASSERT_EQUAL(theField_1->getGaussPresence(), theField_2->getGaussPresence()); - } - else - { - CPPUNIT_ASSERT_THROW(theField_1->getGaussPresence(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_2->getGaussPresence(), MEDEXCEPTION); - } - } - else - { - CPPUNIT_ASSERT_THROW(theField_1->getGaussPresence(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_2->getGaussPresence(), MEDEXCEPTION); - } -} - -static void checkField_(FIELD_ * theField_, const SUPPORT * theSupport, - MED_EN::med_type_champ theValueType, - MED_EN::medModeSwitch theInterlace) -{ - // name - const string aFieldName = "a_name_of_a_field"; - theField_->setName(aFieldName); - CPPUNIT_ASSERT_EQUAL(aFieldName, theField_->getName()); - - // description - const string aFieldDescr = "a_description_of_a_field"; - theField_->setDescription(aFieldDescr); - CPPUNIT_ASSERT_EQUAL(aFieldDescr, theField_->getDescription()); - - // support - theField_->setSupport(theSupport); - CPPUNIT_ASSERT(theField_->getSupport() == theSupport); - - // components information - int aNbComps = 3; - - string aCompsNames[3] = - { - "Vx", "Vy", "Vz" - }; - string aCompsDescs[3] = - { - "vitesse selon x", "vitesse selon y", "vitesse selon z" - }; - string aCompsUnits[3] = - { - "m.s-1", "m.s-1", "m.s-1" - }; - - theField_->setNumberOfComponents(aNbComps); - CPPUNIT_ASSERT_EQUAL(aNbComps, theField_->getNumberOfComponents()); - - theField_->setComponentsNames(aCompsNames); - - //#ifdef ENABLE_FAULTS - try - { - theField_->setNumberOfComponents(7); - // Segmentation fault here because array of components names is not resized - for (int i = 1; i <= 7; i++) - { - theField_->setComponentName(i, "AnyComponent"); - } - } - catch (MEDEXCEPTION& ex) - { - // Ok, it is good to have MEDEXCEPTION here - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception cought"); - } - // restore components names - theField_->setNumberOfComponents(aNbComps); - theField_->setComponentsNames(aCompsNames); - - theField_->setComponentsDescriptions(aCompsDescs); - theField_->setMEDComponentsUnits(aCompsUnits); - - const string * aCompsNamesBack = theField_->getComponentsNames(); - const string * aCompsDescsBack = theField_->getComponentsDescriptions(); - const string * aCompsUnitsBack = theField_->getMEDComponentsUnits(); - for (int i = 1; i <= aNbComps; i++) - { - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack[i-1], theField_->getComponentName(i)); - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack[i-1], aCompsNames[i-1]); - - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack[i-1], theField_->getComponentDescription(i)); - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack[i-1], aCompsDescs[i-1]); - - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack[i-1], theField_->getMEDComponentUnit(i)); - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack[i-1], aCompsUnits[i-1]); - } - - const string aCompName2 ("Name of second component"); - const string aCompDesc2 ("Description of second component"); - const string aCompUnit2 ("Unit of second MED component"); - - theField_->setComponentName(2, aCompName2); - theField_->setComponentDescription(2, aCompDesc2); - theField_->setMEDComponentUnit(2, aCompUnit2); - - const string * aCompsNamesBack2 = theField_->getComponentsNames(); - const string * aCompsDescsBack2 = theField_->getComponentsDescriptions(); - const string * aCompsUnitsBack2 = theField_->getMEDComponentsUnits(); - - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack2[1], theField_->getComponentName(2)); - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack2[1], aCompName2); - - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack2[1], theField_->getComponentDescription(2)); - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack2[1], aCompDesc2); - - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack2[1], theField_->getMEDComponentUnit(2)); - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack2[1], aCompUnit2); - - CPPUNIT_ASSERT_THROW(theField_->setComponentName(0, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setComponentName(aNbComps + 1, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setComponentDescription(0, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setComponentDescription(aNbComps + 1, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setMEDComponentUnit(0, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setMEDComponentUnit(aNbComps + 1, "str"), MEDEXCEPTION); - - // iteration information - int anIterNumber = 10; // set value to MED_NOPDT if undefined (default) - theField_->setIterationNumber(anIterNumber); - CPPUNIT_ASSERT_EQUAL(anIterNumber, theField_->getIterationNumber()); - - int anOrderNumber = 1; // set value to MED_NONOR if undefined (default) - theField_->setOrderNumber(anOrderNumber); - CPPUNIT_ASSERT_EQUAL(anOrderNumber, theField_->getOrderNumber()); - - double aTime = 3.435678; // in second - theField_->setTime(aTime); - CPPUNIT_ASSERT_DOUBLES_EQUAL(aTime, theField_->getTime(), 0.0000001); - - // Value - int nbOfValues = 10; - // dangerous method, because it does not reallocate values array - theField_->setNumberOfValues(nbOfValues); - CPPUNIT_ASSERT_EQUAL(nbOfValues, theField_->getNumberOfValues()); - - // Value type and Interlacing type - CPPUNIT_ASSERT_EQUAL(theValueType, theField_->getValueType()); - CPPUNIT_ASSERT_EQUAL(theInterlace, theField_->getInterlacingType()); -} - -template -void compareField(const FIELD * theField_1, - const FIELD * theField_2, bool isValue) -{ - // compare FIELD_ part - compareField_(theField_1, theField_2, /*isFIELD = */true, isValue); - - // compare FIELD part - // TO DO -} - -template -void checkField (FIELD * theField, const SUPPORT * theSupport) -{ - // check FIELD_ part - MED_EN::med_type_champ aValueType = SET_VALUE_TYPE::_valueType; - MED_EN::medModeSwitch anInterlace = SET_INTERLACING_TYPE::_interlacingType; - checkField_(theField, theSupport, aValueType, anInterlace); - - // check FIELD part - - // filling by support charackteristics (NOT IMPLEMENTED METHODS!!!): - // value type must be MED_REEL64 (i.e. a FIELD) for these methods, - // nb. of components must be equal 1 (for Volume, Area, Length) or - // space dimension (for Normal, Barycenter, ) - { - const GMESH* aMesh = theSupport->getMesh(); - int spaceDim = 3; - if (aMesh) spaceDim = aMesh->getSpaceDimension(); - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */spaceDim + 1); - - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */1); - - if (aMesh) - { - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */spaceDim); - } - - if (aMesh) - { - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */spaceDim); - // 0020142: [CEA 315] Unused function in MEDMEM::FIELD - // getVolume() etc. does nothing - // if (aValueType == MED_EN::MED_REEL64) - { - // CPPUNIT_ASSERT_NO_THROW(theField->getNormal()); - // CPPUNIT_ASSERT_NO_THROW(theField->getBarycenter()); - // - } - // else - { - // CPPUNIT_ASSERT_THROW(theField->getNormal(), MEDEXCEPTION); - // CPPUNIT_ASSERT_THROW(theField->getBarycenter(), MEDEXCEPTION); - // - } - } - } - - // values - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */2); - int nbElemSupport = theSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - CPPUNIT_ASSERT_EQUAL(nbElemSupport, theField->getNumberOfValues()); - - theField->deallocValue(); - CPPUNIT_ASSERT_THROW(theField->getGaussPresence(), MEDEXCEPTION); - - // copy constructor - FIELD *aField_copy1= new FIELD(*theField); - compareField(theField, aField_copy1, /*isValue = */false); - aField_copy1->removeReference(); - - // operator= - FIELD *aField_copy2=new FIELD(); - *aField_copy2 = *theField; - compareField(theField, aField_copy2, /*isValue = */false); - aField_copy2->removeReference(); -} - -template -FIELD * createFieldOnGroup(MESH* theMesh, const GROUP* theGroup, - const string theName, const string theDescr) -{ - FIELD * aFieldOnGroup = new FIELD(theGroup, /*NumberOfComponents = */2); - - aFieldOnGroup->setName(theName); - aFieldOnGroup->setDescription(theDescr); - - string aCompsNames[2] = - { - "Pos", "Neg" - }; - string aCompsDescs[2] = - { - "+", "-" - }; - string aCompsUnits[2] = - { - "unit1", "unit2" - }; - - aFieldOnGroup->setComponentsNames(aCompsNames); - aFieldOnGroup->setComponentsDescriptions(aCompsDescs); - aFieldOnGroup->setMEDComponentsUnits(aCompsUnits); - - return aFieldOnGroup; -} - -double plus13 (double val); -double plus13 (double val) -{ - return val + 13; -} - -// function to calculate field values from coordinates of an element -// typedef void (*myFuncType)(const double * temp, T* output); -// size of temp array = space dim = 3 -// size of output array = nb. comps = 2 -static void proj2d (const double * temp, double* output) -{ - // dimetric projection with coefficients: - // 1.0 along Oy and Oz, 0.5 along Ox - // - // ^ z (y_) - // | - // | - // .----> y (x_) - // / - // L x - // - // x_ = y - x * sqrt(2.) / 4. - // y_ = z - x * sqrt(2.) / 4. - - double dx = temp[0] * std::sqrt(2.) / 4.; - output[0] = temp[1] - dx; - output[1] = temp[2] - dx; -} - -static void testDrivers() -{ - string filename_rd = getResourceFile("pointe.med"); - string filename_wr = makeTmpFile("myMedFieldfile.med", filename_rd); - string filename_support_wr = makeTmpFile("myMedSupportFiledfile.med"); - string filename22_rd = getResourceFile("pointe.med"); - string filenamevtk_wr = makeTmpFile("myMedFieldfile22.vtk"); - - string fieldname_celldouble_rd = "fieldcelldoublescalar"; - string fieldname_celldouble_wr = fieldname_celldouble_rd + "_cpy"; - string fieldname_nodeint_rd = "fieldnodeint"; - string fieldname_nodeint_wr = fieldname_nodeint_rd + "_cpy"; - string fieldname_nodeint_wr1 = fieldname_nodeint_rd + "_cpy1"; - string meshname = "maa1"; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - aRemover.Register(filenamevtk_wr); - aRemover.Register(filename_support_wr); - - FIELD *aInvalidField=new FIELD(); - //must throw becase only VTK_DRIVER or MED_DRIVER may be specified as driverType for FIELD - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(NO_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(GIBI_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(PORFLOW_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(ASCII_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - aInvalidField->removeReference(); - ////////////////// - //TestRead Part// - ////////////////// - FIELD *aField_1 = NULL; - CPPUNIT_ASSERT_NO_THROW(aField_1 = new FIELD(MED_DRIVER, filename_rd, - fieldname_celldouble_rd)); - - //Test read(int index) method - int IdDriver_rd = aField_1->addDriver(MED_DRIVER,filename_rd,fieldname_celldouble_rd,MED_EN::RDONLY); - // TODO: throw if read for the second time - // (BUG) Cannot open file, but file exist - // EAP: no more pb with opening the file for the second time with "weaker" mode, - // but why to re-read the field? - //CPPUNIT_ASSERT_THROW(aField_1->read(IdDriver_rd),MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aField_1->read(IdDriver_rd)); - - //Test read(GENDRIVER & genDriver) method - FIELD *aField_2 = new FIELD(); - aField_2->setName(fieldname_nodeint_rd); - { - MED_FIELD_RDONLY_DRIVER aMedRdFieldDriver; - aMedRdFieldDriver.setFileName(filename_rd); - aField_2->read( aMedRdFieldDriver ); - } - //Test read(driverTypes driverType, const std::string & fileName); - FIELD * aField_3 = new FIELD(); - aField_3->setName(fieldname_celldouble_rd); - aField_3->read( MED_DRIVER, filename_rd); - - /////////////////// - //Test Write Part// - /////////////////// - //int IdDriver; - MESH *aMesh = new MESH(MED_DRIVER,filename_rd,meshname); - const SUPPORT *aSupport = aMesh->getSupportOnAll(MED_CELL); - FIELD *aFieldSupport; - CPPUNIT_ASSERT_THROW(aFieldSupport = - new FIELD(aSupport, MED_DRIVER,filename_rd, - fieldname_nodeint_rd), MEDMEM::MEDEXCEPTION); - aSupport = aMesh->getSupportOnAll(MED_NODE); - CPPUNIT_ASSERT_NO_THROW(aFieldSupport = - new FIELD(aSupport, MED_DRIVER, filename_rd, - fieldname_nodeint_rd)); - aFieldSupport->removeReference(); - - //Test write(int index) method - // Add drivers to FIELDs - int IdDriver1 = aField_3->addDriver(MED_DRIVER,filename_wr,fieldname_celldouble_wr); - - //Trying call write(int index) method with incorrect index - CPPUNIT_ASSERT_THROW(aField_3->write(IdDriver1+1),MEDEXCEPTION); - - //Write field to file - aField_3->write(IdDriver1); - - CPPUNIT_ASSERT_NO_THROW(aField_3->rmDriver(IdDriver1)); - - //Test write(const GENDRIVER &, MED_EN::med_mode_acces medMode=MED_EN::RDWR); - { - MED_FIELD_WRONLY_DRIVER aMedWrFieldDriver; - aMedWrFieldDriver.setFileName(filename_wr); - - aField_3->setName(fieldname_nodeint_wr); - aField_3->write(aMedWrFieldDriver); - FIELD aField_3_RD; - aField_3_RD.setName(fieldname_nodeint_wr); - aField_3_RD.read(MED_DRIVER,filename_wr); - } - - // Test write(driverTypes driverType, const std::string& filename - // MED_EN::med_mode_acces medMode=MED_EN::RDWR) - aField_3->setName(fieldname_nodeint_wr1); - // wrong mode - CPPUNIT_ASSERT_THROW(aField_3->write(MED_DRIVER,filename_wr,MED_EN::RDONLY), MEDEXCEPTION); - aField_3->write(MED_DRIVER,filename_wr); - { - FIELD aField_3_RD; - aField_3_RD.setName(fieldname_nodeint_wr1); - aField_3_RD.read(MED_DRIVER,filename_wr); - } - aField_3->setName("fieldname_nodeint_wr1"); - aField_3->write(MED_DRIVER,filename_wr, MED_EN::WRONLY);// overwrite filename_wr - { - FIELD aField_3_RD; - aField_3_RD.setName(fieldname_nodeint_wr1); - CPPUNIT_ASSERT_THROW(aField_3_RD.read(MED_DRIVER,filename_wr),MEDEXCEPTION); - } - //Test writeAppend(int index) method - //Create a vtk file - MESH * aMesh_1 = new MESH(MED_DRIVER,filename22_rd, meshname); - aMesh_1->write(VTK_DRIVER, filenamevtk_wr); - //Create a field - FIELD * aField_4 = - new FIELD(MED_DRIVER,filename22_rd,fieldname_nodeint_rd,-1,-1,aMesh_1); - //Add Driver to a field - int IdDriver2 = aField_4->addDriver(VTK_DRIVER, filenamevtk_wr ,fieldname_nodeint_wr); - //Trying call writeAppend() method with incorrect index - CPPUNIT_ASSERT_THROW(aField_4->writeAppend(IdDriver2+1,fieldname_nodeint_wr),MEDEXCEPTION); - - CPPUNIT_ASSERT_NO_THROW(aField_4->writeAppend(IdDriver2, fieldname_nodeint_wr)); - - //Test writeAppend(const GENDRIVER &) method - aField_4->setName(fieldname_nodeint_wr1); - { - VTK_FIELD_DRIVER aVtkFieldDriver(filenamevtk_wr, aField_4); - CPPUNIT_ASSERT_NO_THROW(aField_4->writeAppend(aVtkFieldDriver)); - } - - //Delete objects - aField_1->removeReference(); - aField_2->removeReference(); - aField_3->removeReference(); - aField_4->removeReference(); - aMesh->removeReference(); - aMesh_1->removeReference(); -} - -void MEDMEMTest::testField() -{ - SUPPORT *anEmptySupport=new SUPPORT; - //////////////////// - // TEST 1: FIELD_ // - //////////////////// - FIELD_ *aField_=new FIELD_; - - // check set/get methods - MED_EN::med_type_champ aValueType = MED_EN::MED_UNDEFINED_TYPE; - MED_EN::medModeSwitch anInterlace = MED_EN::MED_UNDEFINED_INTERLACE; - checkField_(aField_, anEmptySupport, aValueType, anInterlace); - - // copy constructor - // This fails (Segmentation fault) if not set: - // _componentsNames or _componentsDescriptions, or _MEDComponentsUnits - FIELD_ *aField_copy1=new FIELD_(*aField_); - compareField_(aField_, aField_copy1, /*isFIELD = */false, /*isValue = */false); - aField_copy1->removeReference(); - // operator= - FIELD_ *aField_copy2=new FIELD_; - *aField_copy2 = *aField_; - compareField_(aField_, aField_copy2,/*isFIELD = */false, /*isValue = */false); - aField_copy2->removeReference(); - aField_->removeReference(); - - //////////////////////// - // TEST 2: FIELD // - //////////////////////// - FIELD *aFieldInt=new FIELD(); - checkField(aFieldInt, anEmptySupport); - aFieldInt->removeReference(); - anEmptySupport->removeReference(); - //////////////////////////////////////// - // TEST 3: FIELD // - //////////////////////////////////////// - MESH * aMesh = MEDMEMTest_createTestMesh(); - const GROUP* aGroup = aMesh->getGroup(MED_EN::MED_FACE, 1); - - FIELD *aFieldDouble=new FIELD(); - checkField(aFieldDouble, aGroup); - aFieldDouble->removeReference(); - ////////////////////////////////////////// - // TEST 4: FIELD // - ////////////////////////////////////////// - FIELD * aFieldOnGroup1 = createFieldOnGroup(aMesh, aGroup, "Linear", "N"); - FIELD * aFieldOnGroup2 = createFieldOnGroup(aMesh, aGroup, "Quadratic", "N**2"); - - int nbVals = aFieldOnGroup1->getNumberOfValues(); - CPPUNIT_ASSERT(nbVals); - - // numbers of elements in group, - // they are needed in method FIELD::setValueIJ() - const int *anElems = aGroup->getnumber()->getValue(); - double eucl1 = 0., eucl2 = 0.; - - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup1->setValueIJ(anElems[i-1], 1, (double)i); - aFieldOnGroup1->setValueIJ(anElems[i-1], 2, (double)(-i)); - - aFieldOnGroup2->setValueIJ(anElems[i-1], 1, (double)i*i); - aFieldOnGroup2->setValueIJ(anElems[i-1], 2, (double)(-i*i)); - - eucl1 += 2. * i * i; - eucl2 += 2. * i * i * i * i; - } - - // out of bound (inexisting 33-th component of last element) - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->setValueIJ(anElems[nbVals-1], 33, 10.), MEDEXCEPTION); - - // normMax - CPPUNIT_ASSERT_DOUBLES_EQUAL(nbVals, aFieldOnGroup1->normMax(), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(nbVals*nbVals, aFieldOnGroup2->normMax(), 0.000001); - - // norm2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::sqrt(eucl1), aFieldOnGroup1->norm2(), 0.000001); // 10.4881 - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::sqrt(eucl2), aFieldOnGroup2->norm2(), 0.000001); // 44.2493 - - // check getXXX methods - CPPUNIT_ASSERT(!aFieldOnGroup1->getGaussPresence()); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getArrayGauss(), MEDEXCEPTION); - MEDMEM_ArrayInterface::Array * anArrayNoGauss = - aFieldOnGroup1->getArrayNoGauss(); - - MEDMEM_Array_ * aMEDMEM_Array_ = aFieldOnGroup1->getArray(); - MEDMEM_ArrayInterface::Array * aMEDMEM_Array_conv = - static_cast::Array *>(aMEDMEM_Array_); - - const double * aValues = aFieldOnGroup1->getValue(); - - // out of range - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getColumn(3), MEDEXCEPTION); - // cannot get column in FullInterlace - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getColumn(1), MEDEXCEPTION); - - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , aFieldOnGroup1->getValueIJK(anElems[i-1], 1, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), aFieldOnGroup1->getValueIJK(anElems[i-1], 2, 1), 0.000001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , aValues[(i-1)*2 + 0], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), aValues[(i-1)*2 + 1], 0.000001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , anArrayNoGauss->getIJ(i, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), anArrayNoGauss->getIJ(i, 2), 0.000001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , aMEDMEM_Array_conv->getIJ(i, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), aMEDMEM_Array_conv->getIJ(i, 2), 0.000001); - - const double* row_i = aFieldOnGroup1->getRow(anElems[i-1]); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , row_i[0], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), row_i[1], 0.000001); - - double vals_i [2]; - aFieldOnGroup1->getValueOnElement(anElems[i-1], vals_i); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , vals_i[0], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), vals_i[1], 0.000001); - } - { - // Test getValueOnPoints() - // ----------------------- - const string file = getResourceFile("cube_hexa8.med"); - MESH mesh(MED_DRIVER, file, "CUBE_EN_HEXA8"); - double value[6]; - { - FIELD fieldcelldouble(MED_DRIVER, file, "fieldcelldouble", -1,-1, &mesh); - fieldcelldouble.getSupport()->setMesh( &mesh ); - double point[6] = - { - 0.25, 0.75, 0.25, // the 3-d cell - 1.0, 1.0, 1.0 - };// the 8-th cell - fieldcelldouble.getValueOnPoint(point, value); - const double tol = 1e-20; - CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0, value[0], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.0, value[1], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, value[2], tol ); - fieldcelldouble.getValueOnPoints(2, point, value); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0, value[0], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.0, value[1], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0, value[2], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0, value[3], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 2.0, value[4], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 3.0, value[5], tol ); - } - { - FIELD fieldnodedouble(MED_DRIVER, file, "fieldnodedouble", -1,-1, &mesh); // t=0.0 - fieldnodedouble.getSupport()->setMesh( &mesh ); - double point[6] = - { - 1.0, 1.0, 0.0, // the 9-th node - 1.0, 0.0, 1.0 - };// the 21-st node - fieldnodedouble.getValueOnPoint(point, value); - const double tol = 1e-20; - CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, value[0], tol ); - fieldnodedouble.getValueOnPoints(2, point, value); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 5.0, value[0], tol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 4.0, value[1], tol ); - - point[0] = 1.1; // point out of mesh - CPPUNIT_ASSERT_THROW(fieldnodedouble.getValueOnPoint(point, value), MEDEXCEPTION); - } - } - - // modify all values of aFieldOnGroup2 by formula a*x + b (a = 2, b = 3) - aFieldOnGroup2->applyLin(2., 3.); - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(3. + 2.*i*i, aFieldOnGroup2->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3. - 2.*i*i, aFieldOnGroup2->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // apply function plus13() to aFieldOnGroup1 - aFieldOnGroup1->applyFunc(); - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // scalarProduct - FIELD * aScalarProduct = - FIELD::scalarProduct(*aFieldOnGroup1, *aFieldOnGroup2, /*deepCheck = */true); - CPPUNIT_ASSERT_EQUAL(nbVals, aScalarProduct->getNumberOfValues()); - CPPUNIT_ASSERT_EQUAL(1, aScalarProduct->getNumberOfComponents()); - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(78. + 4.*i*i*i, //(3. + 2.*i*i)*(13 + i) + (3. - 2.*i*i)*(13 - i) - aScalarProduct->getValueIJ(anElems[i-1], 1), 0.000001); - } - - // fillFromAnalytic - aFieldOnGroup2->fillFromAnalytic(proj2d); - - double bary [3]; - double outp [2]; - const SUPPORT * aSupp = aFieldOnGroup2->getSupport(); - FIELD * barycenter = aMesh->getBarycenter(aSupp); - for (int i = 1; i <= nbVals; i++) - { - bary[0] = barycenter->getValueIJ(anElems[i-1], 1); - bary[1] = barycenter->getValueIJ(anElems[i-1], 2); - bary[2] = barycenter->getValueIJ(anElems[i-1], 3); - - proj2d(bary, outp); - - //cout << "barycenter (" << bary[0] << ", " << bary[1] << ", " << bary[2] << ")" << endl; - //cout << "proj2d (" << outp[0] << ", " << outp[1] << ")" << endl; - - //bary (-0.666667, 0.666667, 0.666667) -> outp ( 0.902369, 0.902369) - //bary ( 0.666667, -0.666667, 0.666667) -> outp (-0.902369, 0.430964) - //bary ( 0. , 0. , 2. ) -> outp ( 0. , 2. ) - //bary ( 0. , 0. , 3. ) -> outp ( 0. , 3. ) - //bary (-1. , 0. , 2.5 ) -> outp ( 0.353553, 2.85355 ) - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) in FIELD::fillFromAnalytic() in case of support, different from nodes: - // barycenterField in FullInterlace, but values extracted like from NoInterlace - // TODO: fix MEDMEM_Field:3483 - code should depend on interlace - CPPUNIT_ASSERT_DOUBLES_EQUAL(outp[0], aFieldOnGroup2->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(outp[1], aFieldOnGroup2->getValueIJ(anElems[i-1], 2), 0.000001); - //#endif - - // currently it gives values, that are wrong: - //aFieldOnGroup2 row1 ( 0.902369, 0.235702) - //aFieldOnGroup2 row2 (-0.235702, 2.7643 ) - //aFieldOnGroup2 row3 (-0.235702, -1.2357 ) - //aFieldOnGroup2 row4 ( 1.7643 , -0.235702) - //aFieldOnGroup2 row5 ( 0.235702, 2.7357 ) - } - - // info about support (Group1) - CPPUNIT_ASSERT(!aFieldOnGroup1->isOnAllElements()); // because we build Group1 so - int nbTypes = aFieldOnGroup1->getNumberOfGeometricTypes(); - //CPPUNIT_ASSERT(nbTypes); - CPPUNIT_ASSERT_EQUAL(2, nbTypes); - const int * nbElemsInEachType = aFieldOnGroup1->getNumberOfElements(); - const MED_EN::medGeometryElement * aGeomTypes = aFieldOnGroup1->getGeometricTypes(); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_TRIA3, aGeomTypes[0]); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_QUAD4, aGeomTypes[1]); - - // GAUSS - - // now we have no gauss localization in aFieldOnGroup1 - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA6), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalization(MED_EN::MED_TRIA3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalizationPtr(MED_EN::MED_TRIA3), MEDEXCEPTION); - - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNbGaussI(anElems[0])); - - // set a gauss localization into aFieldOnGroup1 - double cooRef[6] = - { - 1.,1., 2.,4., 3.,9. - }; // xy xy xy - double cooGauss[10] = - { - 7.,7., 6.,6., 5.,5., 4.,3., 2.,1. - }; // x1,y1 x2,y2 x3,y3 x4,y4 x5,y5 - double wg[5] = - { - 1., 2., 3., 4., 5. - }; - GAUSS_LOCALIZATION<> gl1 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef, cooGauss, wg); - - aFieldOnGroup1->setGaussLocalization(MED_EN::MED_TRIA3, gl1); - - // now we have a gauss localization for MED_TRIA3 type - CPPUNIT_ASSERT_EQUAL(5, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA6), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalization(MED_EN::MED_QUAD4), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalizationPtr(MED_EN::MED_QUAD4), MEDEXCEPTION); - - GAUSS_LOCALIZATION<> gl1Back = aFieldOnGroup1->getGaussLocalization(MED_EN::MED_TRIA3); - const GAUSS_LOCALIZATION<> * gl1BackPtr = aFieldOnGroup1->getGaussLocalizationPtr(MED_EN::MED_TRIA3); - - CPPUNIT_ASSERT(gl1 == gl1Back); - CPPUNIT_ASSERT(gl1 == *gl1BackPtr); - - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNbGaussI(anElems[0])); - - // sub-support of Group1 on one (first) geometric type - SUPPORT * aSubSupport1 = new SUPPORT(); - aSubSupport1->setMesh( aMesh ); - aSubSupport1->setName( "Sub-Support 1 of Group1" ); - aSubSupport1->setEntity( MED_EN::MED_FACE ); - - int nbTypes1 = 1; - int nbElemsInEachType1[1]; - nbElemsInEachType1[0] = nbElemsInEachType[0]; - int nbElems1 = nbElemsInEachType1[0]; - MED_EN::medGeometryElement aGeomTypes1[1]; - aGeomTypes1[0] = aGeomTypes[0]; - int * anElems1 = new int[nbElems1]; - for (int i = 0; i < nbElems1; i++) - { - anElems1[i] = anElems[i]; - } - - aSubSupport1->setpartial("Support for sub-field 1 on one type of elements", - nbTypes1, nbElems1, aGeomTypes1, nbElemsInEachType1, anElems1); - - // extract sub-field on aSubSupport1 - FIELD * aSubField1 = aFieldOnGroup1->extract(aSubSupport1); - CPPUNIT_ASSERT_EQUAL(nbElems1 * /*NumberOfComponents = */2, aSubField1->getValueLength()); - - // aSubField1: - // elt\comp | 1 | 2 - //-------------------- - // 1 | 14 | 12 - // 2 | 15 | 11 - - // check normL2() and normL1() - FIELD* anAreaField = aMesh->getArea(aSubSupport1); - double area1 = anAreaField->getValueIJ(anElems1[0], 1); - double area2 = anAreaField->getValueIJ(anElems1[1], 1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.44949, area1, 0.00001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.44949, area2, 0.00001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(210.5, aSubField1->normL2(1), 0.00001); // (14*14 + 15*15)/2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(132.5, aSubField1->normL2(2), 0.00001); // (12*12 + 11*11)/2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(343.0, aSubField1->normL2() , 0.00001); // 210.5 + 132.5 - - CPPUNIT_ASSERT_DOUBLES_EQUAL(14.5, aSubField1->normL1(1), 0.00001); // (14 + 15)/2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.5, aSubField1->normL1(2), 0.00001); // (12 + 11)/2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(26.0, aSubField1->normL1() , 0.00001); // 14.5 + 11.5 - - double aNewArea [2] = - { - 1., 0. - }; // only first element will be taken into account - anAreaField->setValue(aNewArea); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(196.0, aSubField1->normL2(1, anAreaField), 0.00001); // 14*14/1 - CPPUNIT_ASSERT_DOUBLES_EQUAL(144.0, aSubField1->normL2(2, anAreaField), 0.00001); // 12*12/1 - CPPUNIT_ASSERT_DOUBLES_EQUAL(340.0, aSubField1->normL2(anAreaField) , 0.00001); // 196 + 144 - - CPPUNIT_ASSERT_DOUBLES_EQUAL(14.0, aSubField1->normL1(1, anAreaField), 0.00001); // 14/1 - CPPUNIT_ASSERT_DOUBLES_EQUAL(12.0, aSubField1->normL1(2, anAreaField), 0.00001); // 12/1 - CPPUNIT_ASSERT_DOUBLES_EQUAL(26.0, aSubField1->normL1(anAreaField) , 0.00001); // 14 + 12 - - // check normL2() on nodal field (issue 0020120) - { - // read nodal field from pointe.med - string filename = getResourceFile("pointe.med"); - string fieldname = "fieldnodedouble"; - string meshname = "maa1"; - FIELD *nodalField=new FIELD( MED_DRIVER, filename, fieldname); - MESH *mesh=new MESH( MED_DRIVER, filename, meshname); - nodalField->getSupport()->setMesh( mesh ); - - // make a field on the nodes of first cell only - SUPPORT *oneCellNodesSup=new SUPPORT; - oneCellNodesSup->setMesh(mesh); - oneCellNodesSup->setName("Sub-Support of nodes of 1 cell"); - oneCellNodesSup->setEntity(MED_NODE); - int NumberOfElements[] = - { - mesh->getTypes(MED_CELL)[0]%100 - }; - medGeometryElement GeometricType[] = - { - MED_POINT1 - }; - oneCellNodesSup->setpartial("Support for sub-field of one cell nodes", - /*NumberOfGeometricType=*/1, - /*TotalNumberOfElements=*/ *NumberOfElements, - GeometricType, - NumberOfElements, - /*NumberValue=*/ mesh->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS )); - FIELD * oneCellNodesField = nodalField->extract( oneCellNodesSup ); - oneCellNodesSup->removeReference(); - // compute normL2 by avarage nodal value on the cell - - const SUPPORT *allCellsSupport=mesh->getSupportOnAll( MED_CELL ); - FIELD* volumeField = mesh->getVolume(allCellsSupport); - // mdump output: - // - Mailles de type MED_TETRA4 : - // [ 1 ] : 1 2 3 6 - // - Valeurs : - // | 1.000000 | 1.000000 | 1.000000 | 2.000000 | 2.000000 | 2.000000 | ... - const double cellVal = ( 1.000000 + 1.000000 + 1.000000 + 2.000000 ) / 4; - const double vol = abs( volumeField->getValueIJ( 1, 1 )); - const double norm = cellVal*cellVal*vol/vol; // v*v*vol/totVol; - CPPUNIT_ASSERT_DOUBLES_EQUAL(norm, oneCellNodesField->normL2(), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(norm, oneCellNodesField->normL2(1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(norm, oneCellNodesField->normL2(volumeField), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(norm, oneCellNodesField->normL2(1, volumeField), 0.000001); - - CPPUNIT_ASSERT_THROW(oneCellNodesField->normL1(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(oneCellNodesField->normL1(1), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(oneCellNodesField->normL2(nodalField), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(oneCellNodesField->normL2(anAreaField), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(oneCellNodesField->normL2(aSubField1), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(oneCellNodesField->normL2(aFieldOnGroup1), MEDEXCEPTION); - nodalField->removeReference(); - volumeField->removeReference(); - oneCellNodesField->removeReference(); - mesh->removeReference(); - } - - // double integral(SUPPORT*) - mantis issue 0020460: - // [CEA 352] Integral calculus on all field or on a field subarea (groupe or family) - { - // make 2D grid 2x2 with steps along axis 1.0, 2.0 - const int dim = 2; - double coord[3] = - { - 0.0, 1.0, 3.0 - }; - vector< vector > xyz_array( dim, vector( coord, coord + 3 )); - vector coord_name( dim, "coord_name"); - vector coord_unit( dim, "m"); - MESH *mesh= const_cast( GRID( xyz_array, coord_name, coord_unit ).convertInMESH()); - - // make supports on the grid - const SUPPORT *supOnAll=mesh->getSupportOnAll(MED_CELL); - SUPPORT *sup123=new SUPPORT; - sup123->setMesh(mesh); - sup123->setName("sup123"); - int nbEl123[] = - { - 3 - }; - int elems123[] = - { - 1,2,3 - }; - SUPPORT *sup12=new SUPPORT; - sup12->setMesh(mesh); - sup12->setName("sup12"); - int nbEl12 [] = - { - 2 - }; - int elems12 [] = - { - 1,2 - }; - SUPPORT *sup34=new SUPPORT; - sup34->setMesh(mesh); - sup34->setName("sup34"); - int nbEl34 [] = - { - 2 - }; - int elems34 [] = - { - 3,4 - }; - const int nbGeomTypes = 1; - const medGeometryElement * geomType = mesh->getTypes(MED_EN::MED_CELL); - mesh->removeReference(); - sup123->setpartial("test", nbGeomTypes, *nbEl123, geomType, nbEl123, elems123 ); - sup12->setpartial("test", nbGeomTypes, *nbEl12 , geomType, nbEl12 , elems12 ); - sup34->setpartial("test", nbGeomTypes, *nbEl34 , geomType, nbEl34 , elems34 ); - - // make vectorial fields with values of i-th elem { i, i*10, i*100 } - const int nbComp = 3, nbElems = 4; - const int mult[nbComp] = - { - 1, 10, 100 - }; - FIELD *fAllNoTy=new FIELD(supOnAll, nbComp), *f12NoTy=new FIELD(sup12, nbComp); - FIELD *fAllNo=new FIELD(supOnAll, nbComp), *f12No=new FIELD(sup12, nbComp); - FIELD *fAllFull=new FIELD(supOnAll, nbComp), *f12Full=new FIELD(sup12, nbComp); - int i, j; - for ( i = 1; i <= nbElems; ++i ) - for ( j = 1; j <= nbComp; ++j ) - { - fAllFull->setValueIJ( i, j, i * mult[j-1]); - fAllNoTy->setValueIJ( i, j, i * mult[j-1]); - fAllNo ->setValueIJ( i, j, i * mult[j-1]); - if ( i < 3 ) - { - f12Full->setValueIJ( i, j, i * mult[j-1]); - f12NoTy->setValueIJ( i, j, i * mult[j-1]); - f12No ->setValueIJ( i, j, i * mult[j-1]); - } - } - // Test - double preci = 1e-18, integral; - // Integral = SUM( area * (i*1 + i*10 + i*100)) == 111 * SUM( area * i ) - // elem area: { 1, 2, 2, 4 } - integral = 111*( 1*1 + 2*2 + 2*3 + 4*4 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllNoTy->integral(), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllNo ->integral(), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllFull->integral(), preci ); - integral = 111*( 1*1 + 2*2 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12NoTy->integral(), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12No ->integral(), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12Full->integral(), preci ); - - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllNoTy->integral(sup12), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllNo ->integral(sup12), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllFull->integral(sup12), preci ); - - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12NoTy->integral(sup12), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12No ->integral(sup12), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12Full->integral(sup12), preci ); - sup12->removeReference(); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12NoTy->integral(sup123), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12No ->integral(sup123), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12Full->integral(sup123), preci ); - integral = 111*( 1*1 + 2*2 + 2*3 ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllNoTy->integral(sup123), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllNo ->integral(sup123), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, fAllFull->integral(sup123), preci ); - fAllNoTy->removeReference(); - fAllNo->removeReference(); - sup123->removeReference(); - fAllFull->removeReference(); - integral = 0; - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12NoTy->integral(sup34), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12No ->integral(sup34), preci ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( integral, f12Full->integral(sup34), preci ); - sup34->removeReference(); - f12NoTy->removeReference(); - f12No->removeReference(); - f12Full->removeReference(); - } - - // applyPow - aSubField1->applyPow(2.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(196., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); // 14*14 - CPPUNIT_ASSERT_DOUBLES_EQUAL(144., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); // 12*12 - CPPUNIT_ASSERT_DOUBLES_EQUAL(225., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); // 15*15 - CPPUNIT_ASSERT_DOUBLES_EQUAL(121., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); // 11*11 - - // setArray (NoGauss) - MEDMEM_ArrayInterface::Array * aNewArrayNoGauss = - new MEDMEM_ArrayInterface::Array(/*dim*/2, /*nbelem*/2); - aNewArrayNoGauss->setIJ(1, 1, 4.); - aNewArrayNoGauss->setIJ(1, 2, 2.); - aNewArrayNoGauss->setIJ(2, 1, 5.); - aNewArrayNoGauss->setIJ(2, 2, 1.); - aSubField1->setArray(aNewArrayNoGauss); - // no need to delete aNewArrayNoGauss, because it will be deleted - // in destructor or in deallocValue() method of aSubField1 - - CPPUNIT_ASSERT_DOUBLES_EQUAL(4., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - - // setRow - double row[2] = - { - -1., -3. - }; - aSubField1->setRow(anElems1[0], row); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 5., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - // out of range - CPPUNIT_ASSERT_THROW(aSubField1->setRow(3, row), MEDEXCEPTION); - - // setColumn - double col[2] = - { - -7., -9. - }; - aSubField1->setColumn(1, col); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-7., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-9., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - // out of range - CPPUNIT_ASSERT_THROW(aSubField1->setColumn(3, col), MEDEXCEPTION); - - // setArray (Gauss) - { - int nbelgeoc[2] = - { - 1, 3 - }; // 3 - 1 = two elements for the first (and the only) type - int nbgaussgeo[2] = - { - 0, 1 - }; // one gauss point per each element - MEDMEM_ArrayInterface::Array * aNewArrayGauss = - new MEDMEM_ArrayInterface::Array - (/*dim*/2, /*nbelem*/2, /*nbtypegeo*/1, /*nbelgeoc*/nbelgeoc, /*nbgaussgeo*/nbgaussgeo); - - aNewArrayGauss->setIJ(1, 1, -4.); - aNewArrayGauss->setIJ(1, 2, -2.); - aNewArrayGauss->setIJ(2, 1, -5.); - aNewArrayGauss->setIJ(2, 2, -1.); - - aNewArrayGauss->setIJK(1, 1, 1, -4.); - aNewArrayGauss->setIJK(1, 2, 1, -2.); - aNewArrayGauss->setIJK(2, 1, 1, -5.); - aNewArrayGauss->setIJK(2, 2, 1, -1.); - - aSubField1->setArray(aNewArrayGauss); - // no need to delete aNewArrayGauss, because it will be deleted - // in destructor or in deallocValue() method of aSubField1 - - CPPUNIT_ASSERT_DOUBLES_EQUAL(-4., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-2., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-5., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(-4., aSubField1->getValueIJK(anElems1[0], 1, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-2., aSubField1->getValueIJK(anElems1[0], 2, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-5., aSubField1->getValueIJK(anElems1[1], 1, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1., aSubField1->getValueIJK(anElems1[1], 2, 1), 0.000001); - } - - // alloc/dealloc; compatibility of new size with support - try - { - aSubField1->deallocValue(); - aSubField1->allocValue(/*NumberOfComponents*/2, /*LengthValue*/5); - //#ifdef ENABLE_FAULTS - // (BUG) No compatibility between Support and allocated value - //aSubField1->normL1(); - CPPUNIT_ASSERT_THROW(aSubField1->normL1(),MEDEXCEPTION); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // TODO: FIX to throw an EXCEPTION - // CPPUNIT_FAIL("Error: no compatibility between Support and allocated value"); - //#endif - } - catch (MEDEXCEPTION & ex) - { - // normal behaviour - } - catch (...) - { - CPPUNIT_FAIL("Error: no compatibility between Support and allocated value"); - } - - // check that aFieldOnGroup1 is not changed after aSubField1 modifications - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // reset aFieldOnGroup2 values for simple control of operators results - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup2->setValueIJ(anElems[i-1], 1, i*i); - aFieldOnGroup2->setValueIJ(anElems[i-1], 2, -i*i); - } - - int len = aFieldOnGroup1->getValueLength(); - const double * val1 = aFieldOnGroup1->getValue(); - const double * val2 = aFieldOnGroup2->getValue(); - const double * val_res; - - // operators and add, sub, mul, div - - // + - FIELD *aSum = *aFieldOnGroup1 + *aFieldOnGroup2; - aSum->setName(aFieldOnGroup1->getName()); - aSum->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aSum, true, true); - val_res = aSum->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val2[i], val_res[i], 0.000001); - } - aSum->removeReference(); - // - - FIELD *aDifference = *aFieldOnGroup1 - *aFieldOnGroup2; - aDifference->setName(aFieldOnGroup1->getName()); - aDifference->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aDifference, true, true); - val_res = aDifference->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] - val2[i], val_res[i], 0.000001); - } - aDifference->removeReference(); - // - (unary) - FIELD *aNegative = - *aFieldOnGroup1; - aNegative->setName(aFieldOnGroup1->getName()); - aNegative->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aNegative, true, true); - val_res = aNegative->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(- val1[i], val_res[i], 0.000001); - } - aNegative->removeReference(); - // * - FIELD *aProduct = (*aFieldOnGroup1) * (*aFieldOnGroup2); - aProduct->setName(aFieldOnGroup1->getName()); - aProduct->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aProduct, true, true); - val_res = aProduct->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] * val2[i], val_res[i], 0.000001); - } - aProduct->removeReference(); - // / - FIELD *aQuotient = *aFieldOnGroup1 / *aFieldOnGroup2; - aQuotient->setName(aFieldOnGroup1->getName()); - aQuotient->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aQuotient, true, true); - val_res = aQuotient->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] / val2[i], val_res[i], 0.000001); - } - aQuotient->removeReference(); - double val22 = aFieldOnGroup2->getValueIJ(anElems[2], 2); - aFieldOnGroup2->setValueIJ(anElems[2], 2, 0.); - - CPPUNIT_ASSERT_THROW((*aFieldOnGroup1 / *aFieldOnGroup2), MEDEXCEPTION); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) is it up to user to control validity of data to avoid division on zero? - // YES: USER SHOULD CARE OF IT - //CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 /= *aFieldOnGroup2, MEDEXCEPTION); - //#endif - CPPUNIT_ASSERT_THROW(FIELD::div(*aFieldOnGroup1, *aFieldOnGroup2)->removeReference(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup2)->removeReference(), MEDEXCEPTION); - - // restore value - aFieldOnGroup2->setValueIJ(anElems[2], 2, val22); - - // restore values - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup1->setValueIJ(anElems[i-1], 1, 13 + i); - aFieldOnGroup1->setValueIJ(anElems[i-1], 2, 13 - i); - } - - // static methods - FIELD * aPtr; - - // add - aPtr = FIELD::add(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // sub - aPtr = FIELD::sub(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] - val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // mul - aPtr = FIELD::mul(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] * val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // div - aPtr = FIELD::div(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] / val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // addDeep - aPtr = FIELD::addDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // subDeep - aPtr = FIELD::subDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] - val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // mulDeep - aPtr = FIELD::mulDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] * val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // divDeep - aPtr = FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] / val2[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - // += - *aFieldOnGroup1 += *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i + i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i - i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // -= - *aFieldOnGroup1 -= *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // *= - *aFieldOnGroup1 *= *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL( (13 + i)*i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-(13 - i)*i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // /= - *aFieldOnGroup1 /= *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // check case of different operands: support - MESH * aMeshOneMore = MEDMEMTest_createTestMesh(); - const GROUP* aGroupOneMore = aMeshOneMore->getGroup(MED_EN::MED_FACE, 1); - FIELD * aFieldOnGroup3 = - createFieldOnGroup(aMeshOneMore, aGroupOneMore, "Test_Diff_Mesh", "test"); - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup3->setValueIJ(anElems[i-1], 1, 2*i); - aFieldOnGroup3->setValueIJ(anElems[i-1], 2, 3*i); - } - const double * val3 = aFieldOnGroup3->getValue(); - - //CPPUNIT_ASSERT_NO_THROW(); - try - { - aPtr = FIELD::addDeep(*aFieldOnGroup1, *aFieldOnGroup3); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val3[i], val_res[i], 0.000001); - } - aPtr->removeReference(); - - aPtr = FIELD::subDeep(*aFieldOnGroup1, *aFieldOnGroup3); - aPtr->removeReference(); - aPtr = FIELD::mulDeep(*aFieldOnGroup1, *aFieldOnGroup3); - aPtr->removeReference(); - aPtr = FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup3); - aPtr->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - CPPUNIT_FAIL(ex.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception in FIELD::xxxDeep()"); - } - - CPPUNIT_ASSERT_THROW(FIELD::add(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::sub(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::mul(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::div(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 + *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 - *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 * *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 / *aFieldOnGroup3, MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 += *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 -= *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 *= *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 /= *aFieldOnGroup3, MEDEXCEPTION); - - // check case of different operands: MEDComponentsUnits - aFieldOnGroup1->setMEDComponentUnit(1, "unit3"); - - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 + *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 - *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 += *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 -= *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::add(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::sub(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::addDeep(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::subDeep(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - - //CPPUNIT_ASSERT_NO_THROW(); - try - { - aPtr = FIELD::mul(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->removeReference(); - aPtr = FIELD::div(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->removeReference(); - aPtr = FIELD::mulDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->removeReference(); - aPtr = FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->removeReference(); - - *aFieldOnGroup1 *= *aFieldOnGroup2; - *aFieldOnGroup1 /= *aFieldOnGroup2; - - FIELD *aPr = *aFieldOnGroup1 * *aFieldOnGroup2; - FIELD *aQu = *aFieldOnGroup1 / *aFieldOnGroup2; - aPr->removeReference(); - aQu->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - CPPUNIT_FAIL(ex.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // restore MED units - aFieldOnGroup1->setMEDComponentUnit(1, "unit1"); - - // check case of different operands: valueType - //FIELD * aFieldOnGroup4 = - // createFieldOnGroup(aMeshOneMore, aGroupOneMore, "Test_Diff_Mesh", "test"); - // - //CPPUNIT_ASSERT_THROW(FIELD::add(*aFieldOnGroup4, *aFieldOnGroup3), MEDEXCEPTION); - //CPPUNIT_ASSERT_THROW(*aFieldOnGroup4 - *aFieldOnGroup3, MEDEXCEPTION); - //CPPUNIT_ASSERT_THROW(*aFieldOnGroup4 *= *aFieldOnGroup3, MEDEXCEPTION); - //delete aFieldOnGroup4; - - // check case of different operands: numberOfComponents - //#ifdef ENABLE_FAULTS - // (BUG) Cannot allocate value of higher dimension because of _componentsTypes reinitialization - aFieldOnGroup1->deallocValue(); - //CPPUNIT_ASSERT_THROW(aFieldOnGroup1->allocValue(/*dim*/5), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aFieldOnGroup1->allocValue(/*dim*/5)); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // YES THERE MUST BE AN EXCEPTION - // CPPUNIT_FAIL("Segmentation fault on attempt to allocate value of higher dimension." - // " Must be MEDEXCEPTION instead. And on attempt to change nb.components" - // " must be the same behaviour."); - //#endif - aFieldOnGroup1->setNumberOfComponents(5); - - CPPUNIT_ASSERT_THROW(FIELD::sub(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 * *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 /= *aFieldOnGroup2, MEDEXCEPTION); - - // check case of different operands: numberOfValues - aFieldOnGroup1->deallocValue(); - aFieldOnGroup1->allocValue(2, nbVals + 1); - // be carefull: aFieldOnGroup1 reallocated and contains random values - - CPPUNIT_ASSERT_THROW(FIELD::mul(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 / *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 += *aFieldOnGroup2, MEDEXCEPTION); - - // restore aFieldOnGroup1 - aFieldOnGroup1->deallocValue(); - aFieldOnGroup1->allocValue(2, nbVals); - // be carefull: aFieldOnGroup1 reallocated and contains random values - - aSubSupport1->removeReference(); - delete [] anElems1; - - aScalarProduct->removeReference(); - aSubField1->removeReference(); - anAreaField->removeReference(); - barycenter->removeReference(); - aFieldOnGroup1->removeReference(); - aFieldOnGroup2->removeReference(); - aFieldOnGroup3->removeReference(); - - aMesh->removeReference(); - aMeshOneMore->removeReference(); - - ///////////////////// - // TEST 5: Drivers // - ///////////////////// - testDrivers(); -} - -/*! - * Check methods (2), defined in MEDMEM_FieldConvert.hxx: - * (+) template FIELD * FieldConvert(const FIELD & field); - * (+) template FIELD * FieldConvert(const FIELD & field); - */ -void MEDMEMTest::testFieldConvert() -{ - // create an empty integer field 2x10 - FIELD * aField_FING = new FIELD(); - - aField_FING->setName("Field_FING"); - aField_FING->setDescription("Field full interlace no gauss"); - - aField_FING->setNumberOfComponents(2); - aField_FING->setNumberOfValues(10); - - string aCompsNames[2] = - { - "Pos", "Neg" - }; - string aCompsDescs[2] = - { - "+", "-" - }; - string aMEDCompsUnits[2] = - { - "unit1", "unit2" - }; - UNIT aCompsUnits[2]; - - aCompsUnits[0] = UNIT("u1", "descr1"); - aCompsUnits[1] = UNIT("u2", "descr2"); - - aField_FING->setComponentsNames(aCompsNames); - aField_FING->setComponentsDescriptions(aCompsDescs); - aField_FING->setMEDComponentsUnits(aMEDCompsUnits); - aField_FING->setComponentsUnits(aCompsUnits); - - // check UNITs (for testField()) - const UNIT * aCompsUnitsBack = aField_FING->getComponentsUnits(); - CPPUNIT_ASSERT(aCompsUnits[0].getName() == aCompsUnitsBack[0].getName()); - CPPUNIT_ASSERT(aCompsUnits[1].getName() == aCompsUnitsBack[1].getName()); - - const UNIT * aCompUnitBack1 = aField_FING->getComponentUnit(1); - const UNIT * aCompUnitBack2 = aField_FING->getComponentUnit(2); - CPPUNIT_ASSERT(aCompsUnits[0].getName() == aCompUnitBack1->getName()); - CPPUNIT_ASSERT(aCompsUnits[1].getName() == aCompUnitBack2->getName()); - - // create one more field by copy - FIELD * aField_FIGG = new FIELD(*aField_FING); - - // values - int values_FING[20] = - { - 7,- 7, 14,-14, 21,-21, 28,-28, 35,-35, - 42,-42, 49,-49, 56,-56, 63,-63, 70,-70 - }; - - ///////////////////// - // TEST 1: NoGauss // - ///////////////////// - - MEDMEM_ArrayInterface::Array * anArray_FING = - new MEDMEM_ArrayInterface::Array - (values_FING, /*dim*/2, /*nbelem*/10, /*shallowCopy*/false, /*ownershipOfValues*/false); - aField_FING->setArray(anArray_FING); - // no need to delete anArray_FING, because it will be deleted in destructor of aField_FING - - // 1. FullInterlace -> NoInterlace - FIELD * aField_NING = FieldConvert(*aField_FING); - const int * values_NING = aField_NING->getValue(); - - for (int i = 0; i < 10; i++) - { - for (int j = 0; j < 2; j++) - { - CPPUNIT_ASSERT_EQUAL(values_FING[2*i + j], values_NING[10*j + i]); - } - } - - // 2. NoInterlace -> FullInterlace - FIELD * aField_FING_conv = FieldConvert(*aField_NING); - const int * values_FING_conv = aField_FING_conv->getValue(); - - for (int i = 0; i < 10; i++) - { - for (int j = 0; j < 2; j++) - { - CPPUNIT_ASSERT_EQUAL(values_FING_conv[2*i + j], values_FING[2*i + j]); - CPPUNIT_ASSERT_EQUAL(values_FING_conv[2*i + j], values_NING[10*j + i]); - } - } - - aField_FING->removeReference(); - aField_NING->removeReference(); - aField_FING_conv->removeReference(); - - /////////////////// - // TEST 2: Gauss // - /////////////////// - int nbelgeoc[2] = - { - 1, 11 - }; - int nbgaussgeo[2] = - { - -1, 1 - }; - MEDMEM_ArrayInterface::Array * anArray_FIGG = - new MEDMEM_ArrayInterface::Array - (values_FING, /*dim*/2, /*nbelem*/10, /*nbtypegeo*/1, /*nbelgeoc*/nbelgeoc, - /*nbgaussgeo*/nbgaussgeo, /*shallowCopy*/false, /*ownershipOfValues*/false); - aField_FIGG->setArray(anArray_FIGG); - // no need to delete anArray_FIGG, because it will be deleted in destructor of aField_FIGG - - // 1. FullInterlace -> NoInterlace - FIELD * aField_NIGG = FieldConvert(*aField_FIGG); - const int * values_NIGG = aField_NIGG->getValue(); - - for (int i = 0; i < 10; i++) - { - for (int j = 0; j < 2; j++) - { - CPPUNIT_ASSERT_EQUAL(values_FING[2*i + j], values_NIGG[10*j + i]); - } - } - - // 2. NoInterlace -> FullInterlace - FIELD * aField_FIGG_conv = FieldConvert(*aField_NIGG); - const int * values_FIGG_conv = aField_FIGG_conv->getValue(); - - for (int i = 0; i < 10; i++) - { - for (int j = 0; j < 2; j++) - { - CPPUNIT_ASSERT_EQUAL(values_FIGG_conv[2*i + j], values_FING[2*i + j]); - CPPUNIT_ASSERT_EQUAL(values_FIGG_conv[2*i + j], values_NIGG[10*j + i]); - } - } - - aField_FIGG->removeReference(); - aField_NIGG->removeReference(); - aField_FIGG_conv->removeReference(); - { - // create an empty integer field 2x10 - FIELD * aField = new FIELD(); - - aField->setName("aField"); - aField->setDescription("Field full interlace no gauss"); - - aField->setNumberOfComponents(2); - aField->setNumberOfValues(10); - - aField->setComponentsNames(aCompsNames); - aField->setComponentsDescriptions(aCompsDescs); - aField->setMEDComponentsUnits(aMEDCompsUnits); - - MEDMEM_ArrayInterface::Array * anArray = - new MEDMEM_ArrayInterface::Array - (values_FING, /*dim*/2, /*nbelem*/10, /*shallowCopy*/false, /*ownershipOfValues*/false); - aField->setArray(anArray); - // no need to delete anArray, because it will be deleted in destructor of aField - - FIELD * aField_conv = FieldConvert(*aField); - aField->removeReference(); - CPPUNIT_ASSERT(aField_conv); - aField_conv->removeReference(); - } -} - -//================================================================================ -/*! - * \brief 0020582: [CEA 368] MEDMEM don't work with a same field on NODES and CELLS - * Before fixing the issue there was the error: - * RuntimeError: MED Exception in .../MED_SRC/src/MEDMEM/MEDMEM_MedFieldDriver22.hxx [503] : MED_FIELD_DRIVER::createFieldSupportPart1(...) Field |field on NODEs and CELLs| with (ndt,or) = (-1,-1) must not be defined on different entity types - */ -//================================================================================ - -void MEDMEMTest::testReadFieldOnNodesAndCells() -{ - const string outfile = makeTmpFile("field_on_nodes_and_cells.med"); - const string fieldName = "field on NODEs and CELLs"; - - MEDMEMTest_TmpFilesRemover aTmpFilesRemover; - aTmpFilesRemover.Register( outfile ); - - // write file with a field on NODEs and CELLs - - using namespace MED_EN; - - MEDMEM::MESH *mesh=MEDMEMTest_createTestMesh(); - int drv = mesh->addDriver( MED_DRIVER, outfile, mesh->getName()); - mesh->write(drv); - - const SUPPORT *supportOnCells=mesh->getSupportOnAll( MED_CELL ); - const SUPPORT *supportOnNodes=mesh->getSupportOnAll( MED_NODE ); - supportOnCells->addReference(); - supportOnNodes->addReference(); - mesh->removeReference(); - int numberOfCells = supportOnCells->getNumberOfElements(MED_ALL_ELEMENTS); - int numberOfNodes = supportOnNodes->getNumberOfElements(MED_ALL_ELEMENTS); - - PointerOf cellValues( numberOfCells ), nodeValues( numberOfNodes ); - for ( int i = 0; i < numberOfCells; ++i ) cellValues[i] = i; - for ( int i = 0; i < numberOfNodes; ++i ) nodeValues[i] = -i; - - FIELD *wrFieldOnCells=new FIELD(supportOnCells,1); - wrFieldOnCells->setName(fieldName); - wrFieldOnCells->setComponentName(1,"Vx"); - wrFieldOnCells->setComponentDescription(1,"comp1"); - wrFieldOnCells->setMEDComponentUnit(1,"unit1"); - wrFieldOnCells->setValue( cellValues ); - drv = wrFieldOnCells->addDriver(MED_DRIVER, outfile, fieldName); - wrFieldOnCells->write( drv ); - wrFieldOnCells->removeReference(); - - FIELD *wrFieldOnNodes=new FIELD(supportOnNodes,1); - wrFieldOnNodes->setName(fieldName); - wrFieldOnNodes->setComponentName(1,"Vx"); - wrFieldOnNodes->setComponentDescription(1,"comp1"); - wrFieldOnNodes->setMEDComponentUnit(1,"unit1"); - wrFieldOnNodes->setValue( nodeValues ); - drv = wrFieldOnNodes->addDriver(MED_DRIVER, outfile, fieldName); - wrFieldOnNodes->write( drv ); - wrFieldOnNodes->removeReference(); - - // READ FIELDS BACK - - // field on CELLs - FIELD *cellField=new FIELD(supportOnCells, MED_DRIVER, outfile, fieldName, -1, -1 ); - CPPUNIT_ASSERT_EQUAL( MED_CELL, cellField->getSupport()->getEntity()); - CPPUNIT_ASSERT_DOUBLES_EQUAL( numberOfCells-1, cellField->getValueIJ( numberOfCells, 1 ),1e-20); - cellField->removeReference(); - - // field on NODEs - FIELD *nodeField=new FIELD(supportOnNodes, MED_DRIVER, outfile, fieldName, -1, -1 ); - CPPUNIT_ASSERT_EQUAL( MED_NODE, nodeField->getSupport()->getEntity()); - CPPUNIT_ASSERT_DOUBLES_EQUAL( -(numberOfNodes-1), nodeField->getValueIJ( numberOfNodes, 1 ),1e-20); - nodeField->removeReference(); - - supportOnCells->removeReference(); - supportOnNodes->removeReference(); -} - - -//================================================================================ -/*! - * \brief 0021052: [CEA 431] Computation of Gauss point location - * - * Check method GetGaussPointsCoordinates() defined in MEDMEM_Field.hxx: - */ -//================================================================================ -void MEDMEMTest::testGetGaussPointsCoordinates() -{ - const int spaceDimension = 3; - const int numberOfNodes = 56; - - string names[3] = - { - "X","Y","Z" - }; - string units[3] = - { - "cm","cm","cm" - }; - - const int numberOfCellTypes = 14; - - double coordinates [ spaceDimension*numberOfNodes ] = - { - 0.0, 0.0, 0.0, //N1 - 0.5, 0.5, 0.5, //N2 - 1.0, 1.0, 1.0, //N3 - - 1.0, 1.0, 0.0, //N4 - 2.0, 2.5, 0.0, //N5 - 6.0, 1.5, 0.0, //N6 - 1.0, 2.0, 0.0, //N7 - 4.5, 2.5, 0.0, //N8 - 4.0, 0.5, 0.0, //N9 - - 0.0, 4.0, 0.0, //N10 - 4.0, 4.0, 0.0, //N11 - 4.0, 0.0, 0.0, //N12 - 0.0, 2.0, 0.0, //N13 - 2.0, 4.0, 0.0, //N14 - 4.0, 2.0, 0.0, //N15 - 2.0, 0.0, 0.0, //N16 - - 0.0, 6.0, 0.0, //N17 - 3.0, 3.0, 0.0, //N18 - 1.3, 3.0, 3.0, //N19 - - 0.0, 3.0, 0.0, //N20 - 1.5, 4.5, 0.0, //N21 - 1.5, 1.5, 0.0, //N22 - 0.65, 1.5, 1.5, //N23 - 0.65, 4.5, 1.5, //N24 - 2.15, 3.0, 1.5, //N25 - - 2.0, 2.0, 2.0, //N26 - 3.0, 1.0, 1.0, //N27 - 3.0, 3.0, 1.0, //N28 - 1.0, 3.0, 1.0, //N29 - 1.0, 1.0, 1.0, //N30 - - 0.0, 3.0, 0.0, //N31 - 2.0, 0.0, 0.0, //N32 - 0.0, 0.0, 6.0, //N33 - 0.0, 3.0, 6.0, //N34 - 3.0, 0.0, 6.0, //N35 - - 0.0, 1.5, 0.0, //N36 - 1.5, 1.5, 0.0, //N37 - 1.5, 0.0, 0.0, //N38 - 0.0, 1.5, 6.0, //N39 - 1.5, 1.5, 6.0, //N40 - 1.5, 0.0, 6.0, //N41 - 0.0, 0.0, 3.0, //N42 - 0.0, 3.0, 3.0, //N43 - 3.0, 0.0, 3.0, //N44 - - 0.0, 0.0, 4.0, //N45 - 0.0, 4.0, 4.0, //N46 - 4.0, 4.0, 4.0, //N47 - 4.0, 0.0, 4.0, //N48 - 0.0, 2.0, 4.0, //N49 - 2.0, 4.0, 4.0, //N50 - 4.0, 2.0, 4.0, //N51 - 2.0, 0.0, 4.0, //N52 - 0.0, 0.0, 2.0, //N53 - 0.0, 4.0, 2.0, //N54 - 4.0, 4.0, 2.0, //N55 - 4.0, 0.0, 2.0, //N56 - }; - - MED_EN::medGeometryElement cellTypes[ numberOfCellTypes ] = - { - MED_EN::MED_SEG2, - MED_EN::MED_SEG3, - MED_EN::MED_TRIA3, - MED_EN::MED_TRIA6, - MED_EN::MED_QUAD4, - MED_EN::MED_QUAD8, - MED_EN::MED_TETRA4, - MED_EN::MED_TETRA10, - MED_EN::MED_PYRA5, - MED_EN::MED_PYRA13, - MED_EN::MED_PENTA6, - MED_EN::MED_PENTA15, - MED_EN::MED_HEXA8, - MED_EN::MED_HEXA20 - }; - - const int numberOfCells[numberOfCellTypes] = - { - 1, 1, //1D - 1, 1, 1, 1, //2D - 1, 1, 1, 1, 1, 1, 1, 1 //3D - }; - - //Seg2 Connectivity - int seg2C [ 2 ] = - { - 1,3 - }; - - //Seg3 Connectivity - int seg3C [ 3 ] = - { - 1,3,2 - }; - - //Tria3 Connectivity - int tria3C [ 3 ] = - { - 4,5,6 - }; - - //Tria6 Connectivity - int tria6C [ 6 ] = - { - 4,5,6,7,8,9 - }; - - //Quad4 Connectivity - int quad4C [4] = - { - 1, 10, 11, 12 - }; - - //Quad8 Connectivity - int quad8C [8] = - { - 1, 10, 11, 12, 13, 14, 15, 16 - }; - - //Tetra4 Connectivity - int tetra4C [4] = - { - 1, 17, 18, 19 - }; - - //Tetra10 Connectivity - int tetra10C [10] = - { - 1, 17, 18, 19, 20, 21, 22, 23, 24, 25 - }; - - //Pyra13 Connectivity - int pyra5C [5] = - { - 1, 12, 11, 10, 26 - }; - - //Pyra13 Connectivity - int pyra13C [13] = - { - 1, 12, 11, 10, 26, 16, 15, 14, 13, 27, 28, 29, 30 - }; - - //Penta6 Connectivity - int penta6C [6] = - { - 1, 31, 32, 33, 34, 35 - }; - - //Penta6 Connectivity - int penta15C [15] = - { - 1, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44 - }; - - //Hexa8 Connectivity - int hexa8C[8] = - { - 1, 10, 11, 12, 45, 46, 47, 48 - }; - - //Hexa20 Connectivity - int hexa20C[20] = - { - 1, 10, 11, 12, 45, 46, 47, 48, 13, 14, 15, 16, 49, 50, 51, 52, 53, 54, 55, 56 - }; - - - - MEDMEM::MESHING* mesh = new MEDMEM::MESHING; - mesh->setCoordinates(spaceDimension, numberOfNodes, coordinates, - "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - mesh->setCoordinatesNames(names); - mesh->setCoordinatesUnits(units); - - //connectivities - mesh->setNumberOfTypes(numberOfCellTypes, MED_EN::MED_CELL); - mesh->setTypes(cellTypes, MED_EN::MED_CELL); - mesh->setNumberOfElements(numberOfCells, MED_EN::MED_CELL); - - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_SEG2, seg2C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_SEG3, seg3C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_TRIA3, tria3C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_TRIA6, tria6C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_QUAD4, quad4C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_QUAD8, quad8C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_TETRA4, tetra4C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_TETRA10, tetra10C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_PYRA5, pyra5C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_PYRA13, pyra13C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_PENTA6, penta6C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_PENTA15, penta15C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_HEXA8, hexa8C ); - mesh->setConnectivity( MED_EN::MED_CELL, MED_EN::MED_HEXA20, hexa20C ); - - - //Support definition - const SUPPORT* sup = mesh->getSupportOnAll( MED_EN::MED_CELL ); - - //Create test field - FIELD* aField = new FIELD(sup,1); - - //Gauss Localization definition: - double v[1] = - { - 0.3 - }; - double v_2[2] = - { - 0.3, 0.3 - }; - double v_3[3] = - { - 0.3, 0.3, 0.3 - }; - double v_4[4] = - { - 0.3, 0.3, 0.3, 0.3 - }; - - // --------- Seg2 localization --------- - // Nb of the gauss points = 1 - double seg2CooRef[2] = - { - -1.0 , 1.0 - }; - double seg2CooGauss[1] = - { - 0.2 - }; - - GAUSS_LOCALIZATION<>* aseg2L = new GAUSS_LOCALIZATION<>("Seg2 Gauss localization", - MED_EN::MED_SEG2, - 1, - seg2CooRef, - seg2CooGauss, - v); - - // --------- Seg3 localization --------- - // Nb of the gauss points = 1 - double seg3CooRef[3] = - { - -1.0, 1.0, 0.0 - }; - double seg3CooGauss[1] = - { - 0.2 - }; - - GAUSS_LOCALIZATION<>* aseg3L = new GAUSS_LOCALIZATION<>("Seg3 Gauss localization", - MED_EN::MED_SEG3, - 1, - seg3CooRef, - seg3CooGauss, - v); - // --------- Tria3 localization --------- - // Nb of the gauss points = 2 - double tria3CooRef[6] = - { - 0.0, 0.0, 1.0 , 0.0, 0.0, 1.0 - }; - - double tria3CooGauss[4] = - { - 0.1, 0.8, 0.2, 0.7 - }; - - GAUSS_LOCALIZATION<>* atria3L = new GAUSS_LOCALIZATION<>("Tria3 Gauss localization", - MED_EN::MED_TRIA3, - 2, - tria3CooRef, - tria3CooGauss, - v_2); - - // --------- Tria6 localization --------- - // Nb of the gauss points = 3 - double tria6CooRef[12] = - { - 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.5, 0.0, 0.5, 0.5, 0.0, 0.5 - }; - - double tria6CooGauss[6] = - { - 0.3, 0.2, 0.2, 0.1, 0.2, 0.4 - }; - - GAUSS_LOCALIZATION<>* atria6L = new GAUSS_LOCALIZATION<>("Tria6 Gauss localization", - MED_EN::MED_TRIA6, - 3, - tria6CooRef, - tria6CooGauss, - v_3); - // --------- Quad4 localization --------- - // Nb of the gauss points = 4 - double quad4CooRef[8] = - { - -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0 - }; - - double quad4CooGauss[8] = - { //Size is type/10*NbGauss = (204/100)*4 = 8 - 0.3, 0.2, 0.2, 0.1, 0.2, 0.4, 0.15, 0.27 - }; - - GAUSS_LOCALIZATION<>* aquad4L = new GAUSS_LOCALIZATION<>("Quad8 Gauss localization", - MED_EN::MED_QUAD4, - 4, - quad4CooRef, - quad4CooGauss, - v_4); - // --------- Quad8 localization --------- - // Nb of the gauss points = 4 - double quad8CooRef[16] = - { - -1.0, -1.0, - 1.0, -1.0, - 1.0, 1.0, - -1.0, 1.0, - 0.0, -1.0, - 1.0, 0.0, - 0.0, 1.0, - -1.0, 0.0 - }; - - double quad8CooGauss[8] = - { - 0.34, 0.16, 0.21, 0.3, 0.23, 0.4, 0.14, 0.37 - }; - - GAUSS_LOCALIZATION<>* aquad8L = new GAUSS_LOCALIZATION<>("Quad8 Gauss localization", - MED_EN::MED_QUAD8, - 4, - quad8CooRef, - quad8CooGauss, - v_4); - - // --------- Tetra4 localization - // Nb of the gauss points = 1 - double tetra4CooRef[12] = - { - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - 0.0, 0.0, 0.0, - 1.0, 0.0, 0.0 - }; - - double tetra4CooGauss[3] = - { - 0.34, 0.16, 0.21 - }; - - GAUSS_LOCALIZATION<>* atetra4L = new GAUSS_LOCALIZATION<>("Tetra4 Gauss localization", - MED_EN::MED_TETRA4, - 1, - tetra4CooRef, - tetra4CooGauss, - v); - - // --------- Tetra10 localization - // Nb of the gauss points = 1 - double tetra10CooRef[30] = - { - 0.0, 1.0, 0.0, - 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 1.0, 0.0, 0.0, - 0.0, 0.5, 0.0, - 0.0, 0.0, 0.5, - 0.0, 0.5, 0.5, - 0.5, 0.5, 0.0, - 0.5, 0.0, 0.0, - 0.5, 0.0, 0.5, - }; - - double tetra10CooGauss[3] = - { - 0.2, 0.3, 0.1 - }; - - GAUSS_LOCALIZATION<>* atetra10L = new GAUSS_LOCALIZATION<>("Tetra10 Gauss localization", - MED_EN::MED_TETRA10, - 1, - tetra10CooRef, - tetra10CooGauss, - v); - // --------- Pyra5 localization - // Nb of the gauss points = 1 - double pyra5CooRef[15] = - { - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - -1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - 0.0, 0.0, 1.0 - }; - - double pyra5CooGauss[3] = - { - 0.2, 0.3, 0.1 - }; - - GAUSS_LOCALIZATION<>* apyra5L = new GAUSS_LOCALIZATION<>("Pyra5 Gauss localization", - MED_EN::MED_PYRA5, - 1, - pyra5CooRef, - pyra5CooGauss, - v); - - // --------- Pyra13 localization - // Nb of the gauss points = 1 - double pyra13CooRef[39] = - { - 1.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - -1.0, 0.0, 0.0, - 0.0, -1.0, 0.0, - 0.0, 0.0, 1.0, - 0.5, 0.5, 0.0, - -0.5, 0.5, 0.0, - -0.5, -0.5, 0.0, - 0.5, -0.5, 0.0, - 0.5, 0.0, 0.5, - 0.0, 0.5, 0.5, - -0.5, 0.0, 0.5, - 0.0, -0.5, 0.5 - }; - - double pyra13CooGauss[3] = - { - 0.1, 0.2, 0.7 - }; - - GAUSS_LOCALIZATION<>* apyra13L = new GAUSS_LOCALIZATION<>("Pyra13 Gauss localization", - MED_EN::MED_PYRA13, - 1, - pyra13CooRef, - pyra13CooGauss, - v); - // --------- Penta6 localization - // Nb of the gauss points = 1 - double penta6CooRef[18] = - { - -1.0, 1.0, 0.0, - -1.0, -0.0, 1.0, - -1.0, 0.0, 0.0, - 1.0, 1.0, 0.0, - 1.0, 0.0, 1.0, - 1.0, 0.0, 0.0 - }; - - double penta6CooGauss[3] = - { - 0.2, 0.3, 0.1 - }; - - GAUSS_LOCALIZATION<>* apenta6L = new GAUSS_LOCALIZATION<>("Penta6 Gauss localization", - MED_EN::MED_PENTA6, - 1, - penta6CooRef, - penta6CooGauss, - v); - - // --------- Penta15 localization - // Nb of the gauss points = 1 - double penta15CooRef[45] = - { - -1.0, 1.0, 0.0, - -1.0, 0.0, 1.0, - -1.0, 0.0, 0.0, - 1.0, 1.0, 0.0, - 1.0, 0.0, 1.0, - 1.0, 0.0, 0.0, - -1.0, 0.5, 0.5, - -1.0, 0.0, 0.5, - -1.0, 0.5, 0.0, - 0.0, 1.0, 0.0, - 0.0, 0.0, 1.0, - 0.0, 0.0, 0.0, - 1.0, 0.5, 0.5, - 1.0, 0.0, 0.5, - 1.0, 0.5, 0.0 - }; - - double penta15CooGauss[3] = - { - 0.2, 0.3, 0.15 - }; - - GAUSS_LOCALIZATION<>* apenta15L = new GAUSS_LOCALIZATION<>("Penta15 Gauss localization", - MED_EN::MED_PENTA15, - 1, - penta15CooRef, - penta15CooGauss, - v); - - // --------- Hexa8 localization - // Nb of the gauss points = 1 - double hexa8CooRef [24] = - { - -1.0, -1.0, -1.0, - 1.0, -1.0, -1.0, - 1.0, 1.0, -1.0, - -1.0, 1.0, -1.0, - -1.0, -1.0, 1.0, - 1.0, -1.0, 1.0, - 1.0, 1.0, 1.0, - -1.0, 1.0, 1.0 - }; - - double hexa8CooGauss[3] = - { - 0.2, 0.3, 0.15 - }; - - GAUSS_LOCALIZATION<>* ahexa8L = new GAUSS_LOCALIZATION<>("Hexa8 Gauss localization", - MED_EN::MED_HEXA8, - 1, - hexa8CooRef, - hexa8CooGauss, - v); - - // --------- Hexa20 localization - // Nb of the gauss points = 1 - double hexa20CooRef[60] = - { - -1.0, -1.0, -1.0, - 1.0, -1.0, -1.0, - 1.0, 1.0, -1.0, - -1.0, 1.0, -1.0, - -1.0, -1.0, 1.0, - 1.0, -1.0, 1.0, - 1.0, 1.0, 1.0, - -1.0, 1.0, 1.0, - 0.0, -1.0, -1.0, - 1.0, 0.0, -1.0, - 0.0, 1.0, -1.0, - -1.0, 0.0, -1.0, - -1.0, -1.0, 0.0, - 1.0, -1.0, 0.0, - 1.0, 1.0, 0.0, - -1.0, 1.0, 0.0, - 0.0, -1.0, 1.0, - 1.0, 0.0, 1.0, - 0.0, 1.0, 1.0, - -1.0, 0.0, 1.0 - }; - - double hexa20CooGauss[3] = - { - 0.11, 0.3, 0.55 - }; - - GAUSS_LOCALIZATION<>* ahexa20L = new GAUSS_LOCALIZATION<>("Hexa20 Gauss localization", - MED_EN::MED_HEXA20, - 1, - hexa20CooRef, - hexa20CooGauss, - v); - - - - aField->setGaussLocalization(MED_EN::MED_SEG2, aseg2L); - aField->setGaussLocalization(MED_EN::MED_SEG3, aseg3L); - aField->setGaussLocalization(MED_EN::MED_TRIA3, atria3L); - aField->setGaussLocalization(MED_EN::MED_TRIA6, atria6L); - aField->setGaussLocalization(MED_EN::MED_QUAD4, aquad4L); - aField->setGaussLocalization(MED_EN::MED_QUAD8, aquad8L); - aField->setGaussLocalization(MED_EN::MED_TETRA4, atetra4L); - aField->setGaussLocalization(MED_EN::MED_TETRA10, atetra10L); - aField->setGaussLocalization(MED_EN::MED_PYRA5, apyra5L); - aField->setGaussLocalization(MED_EN::MED_PYRA13, apyra13L); - aField->setGaussLocalization(MED_EN::MED_PENTA6, apenta6L); - aField->setGaussLocalization(MED_EN::MED_PENTA15, apenta15L); - aField->setGaussLocalization(MED_EN::MED_HEXA8, ahexa8L); - aField->setGaussLocalization(MED_EN::MED_HEXA20, ahexa20L); - - FIELD* aGaussCoords = aField->getGaussPointsCoordinates(); - - - //Coordinates to check result - double seg2Coord[3] = - { - 0.6,0.6,0.6 - }; - double seg3Coord[3] = - { - 0.6,0.6,0.6 - }; - - double tria3Coord[3*2] = - { - 5.1, 1.55, 0.0, //First GP Coordinates - 4.7, 1.65, 0.0 //Second GP Coordinates - }; - - double tria6Coord[3*3] = - { - 2.32, 1.52, 0.0, //First GP Coordinates - 1.6 , 1.32, 0.0, //Second GP Coordinates - 3.52, 1.26, 0.0 //Third GP Coordinates - }; - - double quad4Coord[4*3] = - { - 2.6, 1.6, 0.0, - 2.4, 1.8, 0.0, - 2.4, 1.2, 0.0, - 2.3, 1.46, 0.0 - }; - - double quad8Coord[4*3] = - { - 2.32, 2.68, 0.0, - 2.6, 2.42, 0.0, - 2.8, 2.46, 0.0, - 2.74, 2.28, 0.0 - }; - - double tetra4Coord[3] = - { - 1.312, 3.15, 1.02 - }; - - double tetra10Coord[3] = - { - 0.56, 3.3, 0.6 - }; - - double pyra5Coord [3]= - { - 2.18, 1.1, 0.2 - }; - - double pyra13Coord [3] = - { - 1.18, 1.54, 0.98 - }; - - double penta6Coord [3] = - { - 1.56, 0.3, 3.6 - }; - - double penta15Coord [3] = - { - 1.613, 0.801, 4.374 - }; - - double hexa8Coord [3] = - { - 2.6, 2.4, 2.3 - }; - - double hexa20Coord [3] = - { - 2.31232, 2.3934, 1.55326 - }; - - //Check result of the calculation - int ElemId = 1; - double EPS = 0.000001; - int idx = 0; - - //Seg2: - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - seg2Coord[j-1], EPS); - } - - //Seg3: - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - seg3Coord[j-1], EPS); - } - - //Tria3 - ElemId++; - for(int k = 1; k <=2 ; k++) - { - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,k), - tria3Coord[idx++], EPS); - } - } - - //Tria6 - ElemId++; - idx=0; - for(int k = 1; k <=3 ; k++) - { - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,k), - tria6Coord[idx++], EPS); - } - } - - //Quad4 - ElemId++; - idx=0; - for(int k = 1; k <=4 ; k++) - { - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,k), - quad4Coord[idx++], EPS); - } - } - - //Quad8 - ElemId++; - idx=0; - for(int k = 1; k <=4 ; k++) - { - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,k), - quad8Coord[idx++], EPS); - } - } - - //Tetra4 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - tetra4Coord[j-1], EPS); - } - - //Tetra10 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - tetra10Coord[j-1], EPS); - } - - //Pyra5 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - pyra5Coord[j-1], EPS); - } - - //Penta15 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - pyra13Coord[j-1], EPS); - } - - //Penta6 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - penta6Coord[j-1], EPS); - } - - //Penta15 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - penta15Coord[j-1], EPS); - } - - //Hexa8 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - hexa8Coord[j-1], EPS); - } - - //Hexa20 - ElemId++; - for(int j = 1; j<=3;j++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(aGaussCoords->getValueIJK(ElemId,j,1), - hexa20Coord[j-1], 0.0001); - } - - aGaussCoords->removeReference(); - aField->removeReference(); - mesh->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Field_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_Field_fault.cxx deleted file mode 100644 index c75aebb73..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Field_fault.cxx +++ /dev/null @@ -1,1644 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" - -#include "MEDMEM_FieldConvert.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_VtkMeshDriver.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #14,15: MEDMEMTest_Field.cxx -// Check methods from MEDMEM_Field.hxx, MEDMEM_FieldConvert.hxx - -/*! - * Check methods (48), defined in MEDMEM_Field.hxx: - * class FIELD_ -{ - * (+) FIELD_(); - * (+) FIELD_(const SUPPORT * Support, const int NumberOfComponents); - * (+) FIELD_(const FIELD_ &m); - * (+) virtual ~FIELD_(); - * (+) FIELD_& operator=(const FIELD_ &m); - * - * (-) virtual void rmDriver(int index=0); - * (-) virtual int addDriver(driverTypes driverType, - * const string & fileName="Default File Name.med", - * const string & driverFieldName="Default Field Nam", - * MED_EN::med_mode_acces access=MED_EN::MED_REMP); - * (-) virtual int addDriver(GENDRIVER & driver); - * - * (-) virtual void read (const GENDRIVER &); - * (-) virtual void read(int index=0); - * (-) virtual void openAppend(void); - * (-) virtual void write(const GENDRIVER &); - * (-) virtual void write(int index=0, const string & driverName=""); - * (-) virtual void writeAppend(const GENDRIVER &); - * (-) virtual void writeAppend(int index=0, const string & driverName=""); - * - * (+) inline void setName(const string Name); - * (+) inline string getName() const; - * (+) inline void setDescription(const string Description); - * (+) inline string getDescription() const; - * (+) inline const SUPPORT * getSupport() const; - * (+) inline void setSupport(const SUPPORT * support); - * (+) inline void setNumberOfComponents(const int NumberOfComponents); - * (+) inline int getNumberOfComponents() const; - * (+) inline void setNumberOfValues(const int NumberOfValues); - * (+) inline int getNumberOfValues() const; - * (+) inline void setComponentsNames(const string * ComponentsNames); - * (+) inline void setComponentName(int i, const string ComponentName); - * (+) inline const string * getComponentsNames() const; - * (+) inline string getComponentName(int i) const; - * (+) inline void setComponentsDescriptions(const string * ComponentsDescriptions); - * (+) inline void setComponentDescription(int i, const string ComponentDescription); - * (+) inline const string * getComponentsDescriptions() const; - * (+) inline string getComponentDescription(int i) const; - * (+) inline void setComponentsUnits(const UNIT * ComponentsUnits); - * (+) inline const UNIT * getComponentsUnits() const; - * (+) inline const UNIT * getComponentUnit(int i) const; - * (+) inline void setMEDComponentsUnits(const string * MEDComponentsUnits); - * (+) inline void setMEDComponentUnit(int i, const string MEDComponentUnit); - * (+) inline const string * getMEDComponentsUnits() const; - * (+) inline string getMEDComponentUnit(int i) const; - * - * (+) inline void setIterationNumber(int IterationNumber); - * (+) inline int getIterationNumber() const; - * (+) inline void setTime(double Time); - * (+) inline double getTime() const; - * (+) inline void setOrderNumber(int OrderNumber); - * (+) inline int getOrderNumber() const; - * - * (+) inline MED_EN::med_type_champ getValueType () const; - * (+) inline MED_EN::medModeSwitch getInterlacingType() const; - * (-) virtual inline bool getGaussPresence() const throw (MEDEXCEPTION); - * -} - * - * template class FIELD : public FIELD_ -{ - * (+) FIELD(); - * (+) FIELD(const FIELD &m); - * (+) FIELD(const SUPPORT * Support, const int NumberOfComponents) throw (MEDEXCEPTION); - * (+) FIELD(driverTypes driverType, - * const string & fileName, const string & fieldDriverName, - * const int iterationNumber=-1, const int orderNumber=-1) throw (MEDEXCEPTION); - * (+) FIELD(const SUPPORT * Support, driverTypes driverType, - * const string & fileName="", const string & fieldName="", - * const int iterationNumber = -1, const int orderNumber = -1) throw (MEDEXCEPTION); - * (+) ~FIELD(); - * (+) FIELD & operator=(const FIELD &m); - * - * (+) const FIELD operator+(const FIELD& m) const; - * (+) const FIELD operator-(const FIELD& m) const; - * (+) const FIELD operator*(const FIELD& m) const; - * (+) const FIELD operator/(const FIELD& m) const; - * (+) const FIELD operator-() const; - * (+) FIELD& operator+=(const FIELD& m); - * (+) FIELD& operator-=(const FIELD& m); - * (+) FIELD& operator*=(const FIELD& m); - * (+) FIELD& operator/=(const FIELD& m); - * - * (+) static FIELD* add(const FIELD& m, const FIELD& n); - * (+) static FIELD* addDeep(const FIELD& m, const FIELD& n); - * (+) static FIELD* sub(const FIELD& m, const FIELD& n); - * (+) static FIELD* subDeep(const FIELD& m, const FIELD& n); - * (+) static FIELD* mul(const FIELD& m, const FIELD& n); - * (+) static FIELD* mulDeep(const FIELD& m, const FIELD& n); - * (+) static FIELD* div(const FIELD& m, const FIELD& n); - * (+) static FIELD* divDeep(const FIELD& m, const FIELD& n); - * - * (+) double normMax() const throw (MEDEXCEPTION); - * (+) double norm2() const throw (MEDEXCEPTION); - * - * (+) void applyLin(T a, T b); - * (+) template void applyFunc(); - * (+) void applyPow(T scalar); - * - * (+) static FIELD* scalarProduct(const FIELD& m, const FIELD& n, bool deepCheck=false); - * - * (+) double normL2(int component, const FIELD * p_field_volume=NULL) const; - * (+) double normL2(const FIELD * p_field_volume=NULL) const; - * (+) double normL1(int component, const FIELD * p_field_volume=NULL) const; - * (+) double normL1(const FIELD * p_field_volume=NULL) const; - * - * (+) FIELD* extract(const SUPPORT *subSupport) const throw (MEDEXCEPTION); - * - * (EMPTY COMMENT, EMPTY IMPLEMENTATION!!!) void init (); - * - * (+) void rmDriver(int index=0); - * (+) int addDriver(driverTypes driverType, - * const string & fileName="Default File Name.med", - * const string & driverFieldName="Default Field Name", - * MED_EN::med_mode_acces access=MED_EN::MED_REMP); - * (+) int addDriver(GENDRIVER & driver); - * - * (+) void allocValue(const int NumberOfComponents); - * (+) void allocValue(const int NumberOfComponents, const int LengthValue); - * (+) void deallocValue(); - * - * (+) inline void read(int index=0); - * (+) inline void read(const GENDRIVER & genDriver); - * (+) inline void write(int index=0, const string & driverName = ""); - * (+) inline void write(const GENDRIVER &); - * (+) inline void writeAppend(int index=0, const string & driverName = ""); - * (+) inline void writeAppend(const GENDRIVER &); - * - * (+) inline MEDMEM_Array_ * getArray() const throw (MEDEXCEPTION); - * (+) inline ArrayGauss * getArrayGauss() const throw (MEDEXCEPTION); - * (+) inline ArrayNoGauss * getArrayNoGauss() const throw (MEDEXCEPTION); - * (+) inline bool getGaussPresence() const throw (MEDEXCEPTION); - * - * (+) inline int getValueLength() const throw (MEDEXCEPTION); - * (+) inline const T* getValue() const throw (MEDEXCEPTION); - * (+) inline const T* getRow(int i) const throw (MEDEXCEPTION); - * (+) inline const T* getColumn(int j) const throw (MEDEXCEPTION); - * (+) inline T getValueIJ(int i,int j) const throw (MEDEXCEPTION); - * (+) inline T getValueIJK(int i,int j,int k) const throw (MEDEXCEPTION); - * (+) bool getValueOnElement(int eltIdInSup,T* retValues) const throw (MEDEXCEPTION); - * - * (+) const int getNumberOfGeometricTypes() const throw (MEDEXCEPTION); - * - * (+) const GAUSS_LOCALIZATION & getGaussLocalization - * (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - * (+) const GAUSS_LOCALIZATION * getGaussLocalizationPtr - * (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - * (+) void setGaussLocalization(MED_EN::medGeometryElement geomElement, - * const GAUSS_LOCALIZATION & gaussloc); - * (+) const int * getNumberOfGaussPoints() const throw (MEDEXCEPTION); - * (+) const int getNumberOfGaussPoints - * (MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION); - * (+) const int getNbGaussI(int i) const throw (MEDEXCEPTION); - * - * (+) const int * getNumberOfElements() const throw (MEDEXCEPTION); - * (+) const MED_EN::medGeometryElement * getGeometricTypes() const throw (MEDEXCEPTION); - * (+) bool isOnAllElements() const throw (MEDEXCEPTION); - * - * (+) inline void setArray(MEDMEM_Array_ *value) throw (MEDEXCEPTION); - * (+) inline void setValue(T* value) throw (MEDEXCEPTION); - * (+) inline void setRow(int i, T* value) throw (MEDEXCEPTION); - * (+) inline void setColumn(int i, T* value) throw (MEDEXCEPTION); - * (+) inline void setValueIJ(int i, int j, T value) throw (MEDEXCEPTION); - * - * (NOT IMPLEMENTED!!!) void getVolume() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getArea() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getLength() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getNormal() const throw (MEDEXCEPTION); - * (NOT IMPLEMENTED!!!) void getBarycenter() const throw (MEDEXCEPTION); - * - * (+) void fillFromAnalytic(myFuncType f) throw (MEDEXCEPTION); - * -} - * - * Use code of test_operation_fieldint.cxx - * test_operation_fielddouble.cxx - * test_copie_field_.cxx - * test_copie_fieldT.cxx - */ - static void compareField_(const FIELD_ * theField_1, const FIELD_ * theField_2, bool isFIELD, bool isValue) -{ - // name, description, support - CPPUNIT_ASSERT_EQUAL(theField_1->getName(), theField_2->getName()); - CPPUNIT_ASSERT_EQUAL(theField_1->getDescription(), theField_2->getDescription()); - CPPUNIT_ASSERT_EQUAL(theField_1->getSupport(), theField_2->getSupport()); - - // components information - int aNbComps = theField_1->getNumberOfComponents(); - CPPUNIT_ASSERT_EQUAL(aNbComps, theField_2->getNumberOfComponents()); - - for (int i = 1; i <= aNbComps; i++) - { - CPPUNIT_ASSERT_EQUAL(theField_1->getComponentName(i), theField_2->getComponentName(i)); - CPPUNIT_ASSERT_EQUAL(theField_1->getComponentDescription(i), theField_2->getComponentDescription(i)); - CPPUNIT_ASSERT_EQUAL(theField_1->getMEDComponentUnit(i), theField_2->getMEDComponentUnit(i)); - } - - // iteration information - CPPUNIT_ASSERT_EQUAL(theField_1->getIterationNumber(), theField_2->getIterationNumber()); - CPPUNIT_ASSERT_EQUAL(theField_1->getOrderNumber(), theField_2->getOrderNumber()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(theField_1->getTime(), theField_2->getTime(), 0.0000001); - - // Value - int nbOfValues = theField_1->getNumberOfValues(); - CPPUNIT_ASSERT_EQUAL(nbOfValues, theField_2->getNumberOfValues()); - - if (isFIELD) - { - // Value type and Interlacing type - CPPUNIT_ASSERT_EQUAL(theField_1->getValueType(), theField_2->getValueType()); - CPPUNIT_ASSERT_EQUAL(theField_1->getInterlacingType(), theField_2->getInterlacingType()); - - // Gauss Presence - if (isValue) - { - CPPUNIT_ASSERT_EQUAL(theField_1->getGaussPresence(), theField_2->getGaussPresence()); - } - else - { - CPPUNIT_ASSERT_THROW(theField_1->getGaussPresence(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_2->getGaussPresence(), MEDEXCEPTION); - } - } - else - { - CPPUNIT_ASSERT_THROW(theField_1->getGaussPresence(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_2->getGaussPresence(), MEDEXCEPTION); - } -} - -static void checkField_(FIELD_ * theField_, const SUPPORT * theSupport, - MED_EN::med_type_champ theValueType, - MED_EN::medModeSwitch theInterlace) -{ - // name - const string aFieldName = "a_name_of_a_field"; - theField_->setName(aFieldName); - CPPUNIT_ASSERT_EQUAL(aFieldName, theField_->getName()); - - // description - const string aFieldDescr = "a_description_of_a_field"; - theField_->setDescription(aFieldDescr); - CPPUNIT_ASSERT_EQUAL(aFieldDescr, theField_->getDescription()); - - // support - theField_->setSupport(theSupport); - CPPUNIT_ASSERT(theField_->getSupport() == theSupport); - - // components information - int aNbComps = 3; - - string aCompsNames[3] = - { - "Vx", "Vy", "Vz" - }; - string aCompsDescs[3] = - { - "vitesse selon x", "vitesse selon y", "vitesse selon z" - }; - string aCompsUnits[3] = - { - "m.s-1", "m.s-1", "m.s-1" - }; - - theField_->setNumberOfComponents(aNbComps); - CPPUNIT_ASSERT_EQUAL(aNbComps, theField_->getNumberOfComponents()); - - theField_->setComponentsNames(aCompsNames); - - //#ifdef ENABLE_FAULTS - try - { - theField_->setNumberOfComponents(7); - // Segmentation fault here because array of components names is not resized - for (int i = 1; i <= 7; i++) - { - theField_->setComponentName(i, "AnyComponent"); - } - } - catch (MEDEXCEPTION& ex) - { - // Ok, it is good to have MEDEXCEPTION here - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception cought"); - } - // restore components names - theField_->setNumberOfComponents(aNbComps); - theField_->setComponentsNames(aCompsNames); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("FIELD_::_componentsNames bad management"); - //#endif - - theField_->setComponentsDescriptions(aCompsDescs); - theField_->setMEDComponentsUnits(aCompsUnits); - - const string * aCompsNamesBack = theField_->getComponentsNames(); - const string * aCompsDescsBack = theField_->getComponentsDescriptions(); - const string * aCompsUnitsBack = theField_->getMEDComponentsUnits(); - for (int i = 1; i <= aNbComps; i++) - { - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack[i-1], theField_->getComponentName(i)); - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack[i-1], aCompsNames[i-1]); - - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack[i-1], theField_->getComponentDescription(i)); - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack[i-1], aCompsDescs[i-1]); - - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack[i-1], theField_->getMEDComponentUnit(i)); - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack[i-1], aCompsUnits[i-1]); - } - - const string aCompName2 ("Name of second component"); - const string aCompDesc2 ("Description of second component"); - const string aCompUnit2 ("Unit of second MED component"); - - theField_->setComponentName(2, aCompName2); - theField_->setComponentDescription(2, aCompDesc2); - theField_->setMEDComponentUnit(2, aCompUnit2); - - const string * aCompsNamesBack2 = theField_->getComponentsNames(); - const string * aCompsDescsBack2 = theField_->getComponentsDescriptions(); - const string * aCompsUnitsBack2 = theField_->getMEDComponentsUnits(); - - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack2[1], theField_->getComponentName(2)); - CPPUNIT_ASSERT_EQUAL(aCompsNamesBack2[1], aCompName2); - - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack2[1], theField_->getComponentDescription(2)); - CPPUNIT_ASSERT_EQUAL(aCompsDescsBack2[1], aCompDesc2); - - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack2[1], theField_->getMEDComponentUnit(2)); - CPPUNIT_ASSERT_EQUAL(aCompsUnitsBack2[1], aCompUnit2); - - //#ifdef ENABLE_FAULTS - // (BUG) No index checking - CPPUNIT_ASSERT_THROW(theField_->setComponentName(0, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setComponentName(aNbComps + 1, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setComponentDescription(0, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setComponentDescription(aNbComps + 1, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setMEDComponentUnit(0, "str"), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(theField_->setMEDComponentUnit(aNbComps + 1, "str"), MEDEXCEPTION); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("FIELD::setComponentXXX() does not check component index"); - //#endif - - // iteration information - int anIterNumber = 10; // set value to MED_NOPDT if undefined (default) - theField_->setIterationNumber(anIterNumber); - CPPUNIT_ASSERT_EQUAL(anIterNumber, theField_->getIterationNumber()); - - int anOrderNumber = 1; // set value to MED_NONOR if undefined (default) - theField_->setOrderNumber(anOrderNumber); - CPPUNIT_ASSERT_EQUAL(anOrderNumber, theField_->getOrderNumber()); - - double aTime = 3.435678; // in second - theField_->setTime(aTime); - CPPUNIT_ASSERT_DOUBLES_EQUAL(aTime, theField_->getTime(), 0.0000001); - - // Value - int nbOfValues = 10; - // dangerous method, because it does not reallocate values array - theField_->setNumberOfValues(nbOfValues); - CPPUNIT_ASSERT_EQUAL(nbOfValues, theField_->getNumberOfValues()); - - // Value type and Interlacing type - CPPUNIT_ASSERT_EQUAL(theValueType, theField_->getValueType()); - CPPUNIT_ASSERT_EQUAL(theInterlace, theField_->getInterlacingType()); -} - -template -void compareField(const FIELD * theField_1, - const FIELD * theField_2, bool isValue) -{ - // compare FIELD_ part - compareField_(theField_1, theField_2, /*isFIELD = */true, isValue); - - // compare FIELD part - // TO DO -} - -template -void checkField (FIELD * theField, const SUPPORT * theSupport) -{ - // check FIELD_ part - MED_EN::med_type_champ aValueType = SET_VALUE_TYPE::_valueType; - MED_EN::medModeSwitch anInterlace = SET_INTERLACING_TYPE::_interlacingType; - checkField_(theField, theSupport, aValueType, anInterlace); - - // check FIELD part - - // filling by support charackteristics (NOT IMPLEMENTED METHODS!!!): - // value type must be MED_REEL64 (i.e. a FIELD) for these methods, - // nb. of components must be equal 1 (for Volume, Area, Length) or - // space dimension (for Normal, Barycenter, ) - { - const GMESH* aMesh = theSupport->getMesh(); - int spaceDim = 3; - if (aMesh) spaceDim = aMesh->getSpaceDimension(); - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */spaceDim + 1); - - // 0020142: [CEA 315] Unused function in MEDMEM::FIELD - // getVolume() etc. does nothing - // CPPUNIT_ASSERT_THROW(theField->getVolume(), MEDEXCEPTION); - // CPPUNIT_ASSERT_THROW(theField->getArea(), MEDEXCEPTION); - // CPPUNIT_ASSERT_THROW(theField->getLength(), MEDEXCEPTION); - // if (aMesh) { - // CPPUNIT_ASSERT_THROW(theField->getNormal(), MEDEXCEPTION); - // CPPUNIT_ASSERT_THROW(theField->getBarycenter(), MEDEXCEPTION); - // } - - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */1); - // 0020142: [CEA 315] Unused function in MEDMEM::FIELD - // getVolume() etc. does nothing - // if (aValueType == MED_EN::MED_REEL64) { - // CPPUNIT_ASSERT_NO_THROW(theField->getVolume()); - // CPPUNIT_ASSERT_NO_THROW(theField->getArea()); - // CPPUNIT_ASSERT_NO_THROW(theField->getLength()); - // } - // else { - // CPPUNIT_ASSERT_THROW(theField->getVolume(), MEDEXCEPTION); - // CPPUNIT_ASSERT_THROW(theField->getArea(), MEDEXCEPTION); - // CPPUNIT_ASSERT_THROW(theField->getLength(), MEDEXCEPTION); - // } - - if (aMesh) - { - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */spaceDim); - // 0020142: [CEA 315] Unused function in MEDMEM::FIELD - // getVolume() etc. does nothing - // if (aValueType == MED_EN::MED_REEL64) { - // CPPUNIT_ASSERT_NO_THROW(theField->getNormal()); - // CPPUNIT_ASSERT_NO_THROW(theField->getBarycenter()); - // } - // else { - // CPPUNIT_ASSERT_THROW(theField->getNormal(), MEDEXCEPTION); - // CPPUNIT_ASSERT_THROW(theField->getBarycenter(), MEDEXCEPTION); - // } - } - } - - // values - theField->deallocValue(); - theField->allocValue(/*NumberOfComponents = */2); - int nbElemSupport = theSupport->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - CPPUNIT_ASSERT_EQUAL(nbElemSupport, theField->getNumberOfValues()); - - //#ifdef ENABLE_FAULTS - // (BUG) FIELD::deallocValue() does not nullify _value pointer, - // that is why there can be failures in other methods - // (even if simply call deallocValue() two times) - theField->deallocValue(); - theField->getGaussPresence(); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("FIELD::deallocValue() does not nullify _value pointer"); - //#endif - - // copy constructor - FIELD aField_copy1 (*theField); - //compareField(theField, &aField_copy1, /*isValue = */false); - compareField(theField, &aField_copy1, /*isValue = */true); - - // operator= - //#ifdef ENABLE_FAULTS - // (BUG) This fails (Segmentation fault) if not set: - // _componentsNames or _componentsDescriptions, or _componentsUnits, or _MEDComponentsUnits - FIELD aField_copy2; - aField_copy2 = *theField; - //compareField(theField, &aField_copy2, /*isValue = */false); - compareField(theField, &aField_copy2, /*isValue = */true); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("FIELD_::operator=() fails if _componentsUnits is not set"); - //#endif -} - -template -FIELD * createFieldOnGroup(MESH* theMesh, const GROUP* theGroup, - const string theName, const string theDescr) -{ - FIELD * aFieldOnGroup = new FIELD (theGroup, /*NumberOfComponents = */2); - - aFieldOnGroup->setName(theName); - aFieldOnGroup->setDescription(theDescr); - - string aCompsNames[2] = - { - "Pos", "Neg" - }; - string aCompsDescs[2] = - { - "+", "-" - }; - string aCompsUnits[2] = - { - "unit1", "unit2" - }; - - aFieldOnGroup->setComponentsNames(aCompsNames); - aFieldOnGroup->setComponentsDescriptions(aCompsDescs); - aFieldOnGroup->setMEDComponentsUnits(aCompsUnits); - - return aFieldOnGroup; -} - -double plus13 (double val); -double plus13 (double val) -{ - return val + 13; -} - -// function to calculate field values from coordinates of an element -// typedef void (*myFuncType)(const double * temp, T* output); -// size of temp array = space dim = 3 -// size of output array = nb. comps = 2 -static void proj2d (const double * temp, double* output) -{ - // dimetric projection with coefficients: - // 1.0 along Oy and Oz, 0.5 along Ox - // - // ^ z (y_) - // | - // | - // .----> y (x_) - // / - // L x - // - // x_ = y - x * sqrt(2.) / 4. - // y_ = z - x * sqrt(2.) / 4. - - double dx = temp[0] * std::sqrt(2.) / 4.; - output[0] = temp[1] - dx; - output[1] = temp[2] - dx; -} - -static void testDrivers() -{ - string filename_rd = getResourceFile("pointe.med"); - string filename_wr = makeTmpFile("myMedFieldfile.med", filename_rd); - string filename_support_wr = makeTmpFile("myMedSupportFiledfile.med"); - string filename22_rd = getResourceFile("pointe.med"); - string filenamevtk_wr = makeTmpFile("myMedFieldfile22.vtk"); - - string fieldname_celldouble_rd = "fieldcelldoublescalar"; - string fieldname_celldouble_wr = fieldname_celldouble_rd + "_cpy"; - string fieldname_nodeint_rd = "fieldnodeint"; - string fieldname_nodeint_wr = fieldname_nodeint_rd + "_cpy"; - string fieldname_nodeint_wr1 = fieldname_nodeint_rd + "_cpy1"; - string meshname = "maa1"; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - aRemover.Register(filenamevtk_wr); - aRemover.Register(filename_support_wr); - - FIELD *aInvalidField=new FIELD(); - //must throw becase only VTK_DRIVER or MED_DRIVER may be specified as driverType for FIELD - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(NO_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(GIBI_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(PORFLOW_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aInvalidField = *(new FIELD(ASCII_DRIVER, filename_rd, fieldname_nodeint_rd)), - MEDEXCEPTION); - - ////////////////// - //TestRead Part// - ////////////////// - FIELD *aField_1 = NULL; - CPPUNIT_ASSERT_NO_THROW(aField_1 = new FIELD(MED_DRIVER, filename_rd, fieldname_celldouble_rd)); - - //Test read(int index) method - int IdDriver_rd = aField_1->addDriver(MED_DRIVER,filename_rd,fieldname_celldouble_rd); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Cannot open file, but file exist - CPPUNIT_ASSERT_NO_THROW(aField_1->read(IdDriver_rd)); - //#endif - - //Test read(GENDRIVER & genDriver) method - //Creation a Driver - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver_1 = new MED_FIELD_RDONLY_DRIVER(); - //Creation a Field - FIELD *aField_2 = new FIELD(); - aField_2->setName(fieldname_nodeint_rd); - aField_2->addDriver(*aMedRdFieldDriver_1); - aField_2->read(*aMedRdFieldDriver_1); - - /////////////////// - //Test Write Part// - /////////////////// - int IdDriver; - MESH *aMesh = new MESH(MED_DRIVER,filename_rd,meshname); - const SUPPORT *aSupport = aMesh->getSupportOnAll( MED_CELL ); - FIELD *aFieldSupport; - //#ifdef ENABLE_FORCED_FAILURES - CPPUNIT_ASSERT_NO_THROW(aFieldSupport = - new FIELD(aSupport, MED_DRIVER,filename_support_wr,fieldname_nodeint_rd)); - //(BUG) Can not open file - MED_FIELD_WRONLY_DRIVER * aFieldWrDriver = - new MED_FIELD_WRONLY_DRIVER(filename_support_wr,aFieldSupport); - aFieldWrDriver->setFieldName(aFieldSupport->getName() + "_copy"); - CPPUNIT_ASSERT_NO_THROW(IdDriver= aFieldSupport->addDriver(*aFieldWrDriver)); - CPPUNIT_ASSERT_NO_THROW(aFieldSupport->write(IdDriver)); - aFieldSupport->removeReference(); - delete aFieldWrDriver; - //#endif - - //Create fileds - FIELD * aField_3 = new FIELD(); - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver_2 = - new MED_FIELD_RDONLY_DRIVER(filename_rd, aField_3); - aMedRdFieldDriver_2->open(); - aMedRdFieldDriver_2->setFieldName(fieldname_celldouble_rd); - aMedRdFieldDriver_2->read(); - aMedRdFieldDriver_2->close(); - - //Test write(int index) method - //Add drivers to FIELDs - int IdDriver1 = -1; - try - { - IdDriver1 = aField_3->addDriver(MED_DRIVER,filename_wr,fieldname_celldouble_wr); - } - catch(MEDEXCEPTION &e) - { - e.what(); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - //Trying call write(int index) method with incorrect index - //#ifdef ENABLE_FAULTS - CPPUNIT_ASSERT_THROW(aField_3->write(IdDriver1+1),MEDEXCEPTION); - // => Segmentation fault - //#endif - - //Write field to file - //#ifdef ENABLE_FAULTS - try - { - aField_3->write(IdDriver1); - // => Segmentation fault - } - catch(MEDEXCEPTION &e) - { - e.what(); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - //#endif - - CPPUNIT_ASSERT_NO_THROW(aField_3->rmDriver(IdDriver1)); - - //Test write(const GENDRIVER &); - //Create a driver - MED_FIELD_WRONLY_DRIVER *aMedWrFieldDriver = new MED_FIELD_WRONLY_DRIVER(); - aMedWrFieldDriver->setFileName(filename_wr); - aField_2->setName(fieldname_nodeint_wr1); - //Add driver to a field - aField_2->addDriver(*aMedWrFieldDriver); - - try - { - aField_2->write(*aMedWrFieldDriver); - } - catch(MEDEXCEPTION &e) - { - e.what(); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test writeAppend(int index) method - //Create a vtk file - MESH * aMesh_1 = new MESH; - MED_MESH_RDONLY_DRIVER *aMedMeshRdDriver22 = new MED_MESH_RDONLY_DRIVER(filename22_rd, aMesh_1); - aMedMeshRdDriver22->open(); - aMedMeshRdDriver22->setMeshName(meshname); - aMedMeshRdDriver22->read(); - aMedMeshRdDriver22->close(); - VTK_MESH_DRIVER *aVtkDriver = new VTK_MESH_DRIVER(filenamevtk_wr, aMesh_1); - aVtkDriver->open(); - aVtkDriver->write(); - aVtkDriver->close(); - - //Create a field - FIELD * aField_4 = new FIELD(); - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver22 = - new MED_FIELD_RDONLY_DRIVER(filename22_rd, aField_2); - aMedRdFieldDriver22->open(); - aMedRdFieldDriver22->setFieldName(fieldname_nodeint_rd); - aMedRdFieldDriver22->read(); - aMedRdFieldDriver22->close(); - - //Add Driver to a field - int IdDriver2; - try - { - IdDriver2 = aField_4->addDriver(VTK_DRIVER, filenamevtk_wr ,fieldname_nodeint_wr); - } - catch(MEDEXCEPTION &e) - { - e.what(); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - //#ifdef ENABLE_FAULTS - //Trying call writeAppend() method with incorrect index - CPPUNIT_ASSERT_THROW(aField_4->writeAppend(IdDriver2+1,fieldname_nodeint_wr),MEDEXCEPTION); - // => Segmentation fault - //#endif - - //#ifdef ENABLE_FAULTS - // (BUG) => Segmentation fault - CPPUNIT_ASSERT_NO_THROW(aField_4->writeAppend(IdDriver2, fieldname_nodeint_wr)); - //#endif - - //Test writeAppend(const GENDRIVER &) method - aField_4->setName(fieldname_nodeint_wr1); - - //Add driver to a field - //#ifdef ENABLE_FAULTS - //Create a driver - VTK_FIELD_DRIVER *aVtkFieldDriver = new VTK_FIELD_DRIVER(filenamevtk_wr, aField_4); - CPPUNIT_ASSERT_NO_THROW(aField_4->addDriver(*aVtkFieldDriver)); - //(BUG) => Segmentation fault after addDriver(const GENDRIVER &) - CPPUNIT_ASSERT_NO_THROW(aField_4->writeAppend(*aVtkFieldDriver)); - //#endif - - - //Delete objects - aField_1->removeReference(); - delete aMedRdFieldDriver_1; - aField_2->removeReference(); - aField_3->removeReference(); - delete aMedRdFieldDriver_2; - aField_4->removeReference(); - delete aMedMeshRdDriver22; - delete aMedWrFieldDriver; - delete aVtkDriver; - aMesh->removeReference(); - aMesh_1->removeReference(); - delete aMedRdFieldDriver22; -} - -static void MEDMEMTest_testField() -{ - SUPPORT *anEmptySupport=new SUPPORT; - //////////////////// - // TEST 1: FIELD_ // - //////////////////// - FIELD_ *aField_=new FIELD_ ; - - // check set/get methods - MED_EN::med_type_champ aValueType = MED_EN::MED_UNDEFINED_TYPE; - MED_EN::medModeSwitch anInterlace = MED_EN::MED_UNDEFINED_INTERLACE; - checkField_(aField_, anEmptySupport, aValueType, anInterlace); - - // copy constructor - // This fails (Segmentation fault) if not set: - // _componentsNames or _componentsDescriptions, or _MEDComponentsUnits - FIELD_ *aField_copy1=new FIELD_(*aField_); - compareField_(aField_, aField_copy1, /*isFIELD = */false, /*isValue = */false); - - // operator= - //#ifdef ENABLE_FAULTS - // (BUG) This fails (Segmentation fault) if not set: - // _componentsNames or _componentsDescriptions, or _componentsUnits, or _MEDComponentsUnits - // (BUG) Code duplication with copyGlobalInfo(), called from copy constructor - FIELD_ *aField_copy2=new FIELD_; - *aField_copy2 = *aField_; - compareField_(aField_, aField_copy2, /*isFIELD = */false, /*isValue = */false); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("FIELD_::operator=() fails if _componentsUnits is not set"); - //#endif - - // following test is commented since method - // setTotalNumberOfElements() is removed. - /* - // construction on a given support - { - anEmptySupport.setTotalNumberOfElements(11); - // CASE1: - FIELD_ aField_case1 (&anEmptySupport, 10); - // CASE2: - FIELD_ aField_case2; - aField_case2.setSupport(&anEmptySupport); - aField_case2.setNumberOfComponents(10); - - #ifdef ENABLE_FORCED_FAILURES - CPPUNIT_ASSERT_EQUAL_MESSAGE("No correspondance between CASE1 and CASE2", - aField_case1.getNumberOfValues(), - aField_case2.getNumberOfValues()); - #endif - } - */ - - //////////////////////// - // TEST 2: FIELD // - //////////////////////// - FIELD *aFieldInt=new FIELD(); - checkField(aFieldInt, anEmptySupport); - - //////////////////////////////////////// - // TEST 3: FIELD // - //////////////////////////////////////// - MESH * aMesh = MEDMEMTest_createTestMesh(); - const GROUP* aGroup = aMesh->getGroup(MED_EN::MED_FACE, 1); - - FIELD aFieldDouble; - checkField(&aFieldDouble, aGroup); - - ////////////////////////////////////////// - // TEST 4: FIELD // - ////////////////////////////////////////// - FIELD * aFieldOnGroup1 = createFieldOnGroup(aMesh, aGroup, "Linear", "N"); - FIELD * aFieldOnGroup2 = createFieldOnGroup(aMesh, aGroup, "Quadratic", "N**2"); - - int nbVals = aFieldOnGroup1->getNumberOfValues(); - CPPUNIT_ASSERT(nbVals); - - // numbers of elements in group, - // they are needed in method FIELD::setValueIJ() - const int *anElems = aGroup->getnumber()->getValue(); - double eucl1 = 0., eucl2 = 0.; - - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup1->setValueIJ(anElems[i-1], 1, (double)i); - aFieldOnGroup1->setValueIJ(anElems[i-1], 2, (double)(-i)); - - aFieldOnGroup2->setValueIJ(anElems[i-1], 1, (double)i*i); - aFieldOnGroup2->setValueIJ(anElems[i-1], 2, (double)(-i*i)); - - eucl1 += 2. * i * i; - eucl2 += 2. * i * i * i * i; - } - - // out of bound (inexisting 33-th component of last element) - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->setValueIJ(anElems[nbVals-1], 33, 10.), MEDEXCEPTION); - - // normMax - CPPUNIT_ASSERT_DOUBLES_EQUAL(nbVals, aFieldOnGroup1->normMax(), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(nbVals*nbVals, aFieldOnGroup2->normMax(), 0.000001); - - // norm2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::sqrt(eucl1), aFieldOnGroup1->norm2(), 0.000001); // 10.4881 - CPPUNIT_ASSERT_DOUBLES_EQUAL(std::sqrt(eucl2), aFieldOnGroup2->norm2(), 0.000001); // 44.2493 - - // check getXXX methods - CPPUNIT_ASSERT(!aFieldOnGroup1->getGaussPresence()); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getArrayGauss(), MEDEXCEPTION); - MEDMEM_ArrayInterface::Array * anArrayNoGauss = - aFieldOnGroup1->getArrayNoGauss(); - - MEDMEM_Array_ * aMEDMEM_Array_ = aFieldOnGroup1->getArray(); - MEDMEM_ArrayInterface::Array * aMEDMEM_Array_conv = - static_cast::Array *>(aMEDMEM_Array_); - - const double * aValues = aFieldOnGroup1->getValue(); - - // out of range - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getColumn(3), MEDEXCEPTION); - // cannot get column in FullInterlace - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getColumn(1), MEDEXCEPTION); - - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , aFieldOnGroup1->getValueIJK(anElems[i-1], 1, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), aFieldOnGroup1->getValueIJK(anElems[i-1], 2, 1), 0.000001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , aValues[(i-1)*2 + 0], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), aValues[(i-1)*2 + 1], 0.000001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , anArrayNoGauss->getIJ(i, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), anArrayNoGauss->getIJ(i, 2), 0.000001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , aMEDMEM_Array_conv->getIJ(i, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), aMEDMEM_Array_conv->getIJ(i, 2), 0.000001); - - const double* row_i = aFieldOnGroup1->getRow(anElems[i-1]); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , row_i[0], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), row_i[1], 0.000001); - - double vals_i [2]; - aFieldOnGroup1->getValueOnElement(anElems[i-1], vals_i); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)i , vals_i[0], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL((double)(-i), vals_i[1], 0.000001); - } - - // modify all values of aFieldOnGroup2 by formula a*x + b (a = 2, b = 3) - aFieldOnGroup2->applyLin(2., 3.); - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(3. + 2.*i*i, aFieldOnGroup2->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3. - 2.*i*i, aFieldOnGroup2->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // apply function plus13() to aFieldOnGroup1 - aFieldOnGroup1->applyFunc(); - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // scalarProduct - FIELD * aScalarProduct = - FIELD::scalarProduct(*aFieldOnGroup1, *aFieldOnGroup2, /*deepCheck = */true); - CPPUNIT_ASSERT_EQUAL(nbVals, aScalarProduct->getNumberOfValues()); - CPPUNIT_ASSERT_EQUAL(1, aScalarProduct->getNumberOfComponents()); - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(78. + 4.*i*i*i, //(3. + 2.*i*i)*(13 + i) + (3. - 2.*i*i)*(13 - i) - aScalarProduct->getValueIJ(anElems[i-1], 1), 0.000001); - } - - // fillFromAnalytic - aFieldOnGroup2->fillFromAnalytic(proj2d); - - double bary [3]; - double outp [2]; - const SUPPORT * aSupp = aFieldOnGroup2->getSupport(); - FIELD * barycenter = aMesh->getBarycenter(aSupp); - for (int i = 1; i <= nbVals; i++) - { - bary[0] = barycenter->getValueIJ(anElems[i-1], 1); - bary[1] = barycenter->getValueIJ(anElems[i-1], 2); - bary[2] = barycenter->getValueIJ(anElems[i-1], 3); - - proj2d(bary, outp); - - //cout << "barycenter (" << bary[0] << ", " << bary[1] << ", " << bary[2] << ")" << endl; - //cout << "proj2d (" << outp[0] << ", " << outp[1] << ")" << endl; - - //bary (-0.666667, 0.666667, 0.666667) -> outp ( 0.902369, 0.902369) - //bary ( 0.666667, -0.666667, 0.666667) -> outp (-0.902369, 0.430964) - //bary ( 0. , 0. , 2. ) -> outp ( 0. , 2. ) - //bary ( 0. , 0. , 3. ) -> outp ( 0. , 3. ) - //bary (-1. , 0. , 2.5 ) -> outp ( 0.353553, 2.85355 ) - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) in FIELD::fillFromAnalytic() in case of support, different from nodes: - // barycenterField in FullInterlace, but values extracted like from NoInterlace - CPPUNIT_ASSERT_DOUBLES_EQUAL(outp[0], aFieldOnGroup2->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(outp[1], aFieldOnGroup2->getValueIJ(anElems[i-1], 2), 0.000001); - //#endif - - // currently it gives values, that are wrong: - //aFieldOnGroup2 row1 ( 0.902369, 0.235702) - //aFieldOnGroup2 row2 (-0.235702, 2.7643 ) - //aFieldOnGroup2 row3 (-0.235702, -1.2357 ) - //aFieldOnGroup2 row4 ( 1.7643 , -0.235702) - //aFieldOnGroup2 row5 ( 0.235702, 2.7357 ) - } - - // info about support (Group1) - CPPUNIT_ASSERT(!aFieldOnGroup1->isOnAllElements()); // because we build Group1 so - int nbTypes = aFieldOnGroup1->getNumberOfGeometricTypes(); - //CPPUNIT_ASSERT(nbTypes); - CPPUNIT_ASSERT_EQUAL(2, nbTypes); - const int * nbElemsInEachType = aFieldOnGroup1->getNumberOfElements(); - const MED_EN::medGeometryElement * aGeomTypes = aFieldOnGroup1->getGeometricTypes(); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_TRIA3, aGeomTypes[0]); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_QUAD4, aGeomTypes[1]); - - // GAUSS - - // now we have no gauss localization in aFieldOnGroup1 - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA6), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalization(MED_EN::MED_TRIA3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalizationPtr(MED_EN::MED_TRIA3), MEDEXCEPTION); - - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNbGaussI(anElems[0])); - - // set a gauss localization into aFieldOnGroup1 - double cooRef[6] = - { - 1.,1., 2.,4., 3.,9. - }; // xy xy xy - double cooGauss[10] = - { - 7.,7., 6.,6., 5.,5., 4.,3., 2.,1. - }; // x1,y1 x2,y2 x3,y3 x4,y4 x5,y5 - double wg[5] = - { - 1., 2., 3., 4., 5. - }; - GAUSS_LOCALIZATION<> gl1 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef, cooGauss, wg); - - aFieldOnGroup1->setGaussLocalization(MED_EN::MED_TRIA3, gl1); - - // now we have a gauss localization for MED_TRIA3 type - CPPUNIT_ASSERT_EQUAL(5, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(MED_EN::MED_TRIA6), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getNumberOfGaussPoints(), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalization(MED_EN::MED_QUAD4), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->getGaussLocalizationPtr(MED_EN::MED_QUAD4), MEDEXCEPTION); - - GAUSS_LOCALIZATION<> gl1Back = aFieldOnGroup1->getGaussLocalization(MED_EN::MED_TRIA3); - const GAUSS_LOCALIZATION<> * gl1BackPtr = aFieldOnGroup1->getGaussLocalizationPtr(MED_EN::MED_TRIA3); - - CPPUNIT_ASSERT(gl1 == gl1Back); - CPPUNIT_ASSERT(gl1 == *gl1BackPtr); - - CPPUNIT_ASSERT_EQUAL(1, aFieldOnGroup1->getNbGaussI(anElems[0])); - - // sub-support of Group1 on one (first) geometric type - SUPPORT * aSubSupport1 = new SUPPORT; - aSubSupport1->setMesh( aMesh ); - aSubSupport1->setName( "Sub-Support 1 of Group1" ); - aSubSupport1->setEntity( MED_EN::MED_FACE ); - - int nbTypes1 = 1; - int nbElemsInEachType1[1]; - nbElemsInEachType1[0] = nbElemsInEachType[0]; - int nbElems1 = nbElemsInEachType1[0]; - MED_EN::medGeometryElement aGeomTypes1[1]; - aGeomTypes1[0] = aGeomTypes[0]; - int * anElems1 = new int[nbElems1]; - for (int i = 0; i < nbElems1; i++) - { - anElems1[i] = anElems[i]; - } - - aSubSupport1->setpartial("Support for sub-field 1 on one type of elements", - nbTypes1, nbElems1, aGeomTypes1, nbElemsInEachType1, anElems1); - - //cout << "aSubSupport1:" << endl; - //cout << *aSubSupport1 << endl; - - // extract sub-field on aSubSupport1 - FIELD * aSubField1 = aFieldOnGroup1->extract(aSubSupport1); - CPPUNIT_ASSERT_EQUAL(nbElems1 * /*NumberOfComponents = */2, aSubField1->getValueLength()); - - // aSubField1: - // elt\comp | 1 | 2 - //-------------------- - // 1 | 14 | 12 - // 2 | 15 | 11 - - // check normL2() and normL1() - FIELD* anAreaField = aMesh->getArea(aSubSupport1); - double area1 = anAreaField->getValueIJ(anElems1[0], 1); - double area2 = anAreaField->getValueIJ(anElems1[1], 1); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.44949, area1, 0.00001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.44949, area2, 0.00001); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(210.5, aSubField1->normL2(1), 0.00001); // (14*14 + 15*15)/2 - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) FIELD::normL2(int component, const FIELD * p_field_volume): - // component is not taken into account - CPPUNIT_ASSERT_DOUBLES_EQUAL(132.5, aSubField1->normL2(2), 0.00001); // (12*12 + 11*11)/2 - //#endif - CPPUNIT_ASSERT_DOUBLES_EQUAL(343.0, aSubField1->normL2() , 0.00001); // 210.5 + 132.5 - - CPPUNIT_ASSERT_DOUBLES_EQUAL(14.5, aSubField1->normL1(1), 0.00001); // (14 + 15)/2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.5, aSubField1->normL1(2), 0.00001); // (12 + 11)/2 - CPPUNIT_ASSERT_DOUBLES_EQUAL(26.0, aSubField1->normL1() , 0.00001); // 14.5 + 11.5 - - double aNewArea [2] = - { - 1., 0. - }; // only first element will be taken into account - anAreaField->setValue(aNewArea); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(196.0, aSubField1->normL2(1, anAreaField), 0.00001); // 14*14/1 - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) FIELD::normL2(int component, const FIELD * p_field_volume): - // component is not taken into account - CPPUNIT_ASSERT_DOUBLES_EQUAL(144.0, aSubField1->normL2(2, anAreaField), 0.00001); // 12*12/1 - //#endif - CPPUNIT_ASSERT_DOUBLES_EQUAL(340.0, aSubField1->normL2(anAreaField) , 0.00001); // 196 + 144 - - CPPUNIT_ASSERT_DOUBLES_EQUAL(14.0, aSubField1->normL1(1, anAreaField), 0.00001); // 14/1 - CPPUNIT_ASSERT_DOUBLES_EQUAL(12.0, aSubField1->normL1(2, anAreaField), 0.00001); // 12/1 - CPPUNIT_ASSERT_DOUBLES_EQUAL(26.0, aSubField1->normL1(anAreaField) , 0.00001); // 14 + 12 - - // applyPow - aSubField1->applyPow(2.); - CPPUNIT_ASSERT_DOUBLES_EQUAL(196., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); // 14*14 - CPPUNIT_ASSERT_DOUBLES_EQUAL(144., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); // 12*12 - CPPUNIT_ASSERT_DOUBLES_EQUAL(225., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); // 15*15 - CPPUNIT_ASSERT_DOUBLES_EQUAL(121., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); // 11*11 - - // setArray (NoGauss) - MEDMEM_ArrayInterface::Array * aNewArrayNoGauss = - new MEDMEM_ArrayInterface::Array(/*dim*/2, /*nbelem*/2); - aNewArrayNoGauss->setIJ(1, 1, 4.); - aNewArrayNoGauss->setIJ(1, 2, 2.); - aNewArrayNoGauss->setIJ(2, 1, 5.); - aNewArrayNoGauss->setIJ(2, 2, 1.); - aSubField1->setArray(aNewArrayNoGauss); - // no need to delete aNewArrayNoGauss, because it will be deleted - // in destructor or in deallocValue() method of aSubField1 - - CPPUNIT_ASSERT_DOUBLES_EQUAL(4., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - - // setRow - double row[2] = - { - -1., -3. - }; - aSubField1->setRow(anElems1[0], row); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 5., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - // out of range - CPPUNIT_ASSERT_THROW(aSubField1->setRow(3, row), MEDEXCEPTION); - - // setColumn - double col[2] = - { - -7., -9. - }; - aSubField1->setColumn(1, col); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-7., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) in MEDMEM_Array::setColumn() - CPPUNIT_ASSERT_DOUBLES_EQUAL(-9., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - //#endif - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - // out of range - CPPUNIT_ASSERT_THROW(aSubField1->setColumn(3, col), MEDEXCEPTION); - - // setArray (Gauss) - { - int nbelgeoc[2] = - { - 1, 3 - }; // 3 - 1 = two elements for the first (and the only) type - int nbgaussgeo[2] = - { - -1, 1 - }; // one gauss point per each element - MEDMEM_ArrayInterface::Array * aNewArrayGauss = - new MEDMEM_ArrayInterface::Array - (/*dim*/2, /*nbelem*/2, /*nbtypegeo*/1, /*nbelgeoc*/nbelgeoc, /*nbgaussgeo*/nbgaussgeo); - - //#ifdef ENABLE_FAULTS - aNewArrayGauss->setIJ(1, 1, -4.); - aNewArrayGauss->setIJ(1, 2, -2.); - aNewArrayGauss->setIJ(2, 1, -5.); - aNewArrayGauss->setIJ(2, 2, -1.); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // ? (BUG) in FullInterlaceGaussPolicy::getIndex(int i,int j) - // FullInterlaceGaussPolicy::getIndex(2,2) returns 4!!! - // CPPUNIT_FAIL("? Bug in FullInterlaceGaussPolicy::getIndex(int i,int j) ?"); - //#endif - - aNewArrayGauss->setIJK(1, 1, 1, -4.); - aNewArrayGauss->setIJK(1, 2, 1, -2.); - aNewArrayGauss->setIJK(2, 1, 1, -5.); - aNewArrayGauss->setIJK(2, 2, 1, -1.); - - aSubField1->setArray(aNewArrayGauss); - // no need to delete aNewArrayGauss, because it will be deleted - // in destructor or in deallocValue() method of aSubField1 - - //#ifdef ENABLE_FAULTS - CPPUNIT_ASSERT_DOUBLES_EQUAL(-4., aSubField1->getValueIJ(anElems1[0], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-2., aSubField1->getValueIJ(anElems1[0], 2), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-5., aSubField1->getValueIJ(anElems1[1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1., aSubField1->getValueIJ(anElems1[1], 2), 0.000001); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // ? (BUG) in FullInterlaceGaussPolicy::getIndex(int i,int j) - // Must be : return _G[i-1]-1 + (j-1); - // Instead of: return _G[i-1]-1 + (j-1)*_dim; - // CPPUNIT_FAIL("? Bug in FullInterlaceGaussPolicy::getIndex(int i,int j) ?"); - //#endif - - CPPUNIT_ASSERT_DOUBLES_EQUAL(-4., aSubField1->getValueIJK(anElems1[0], 1, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-2., aSubField1->getValueIJK(anElems1[0], 2, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-5., aSubField1->getValueIJK(anElems1[1], 1, 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-1., aSubField1->getValueIJK(anElems1[1], 2, 1), 0.000001); - } - - // alloc/dealloc; compatibility of new size with support - try - { - aSubField1->deallocValue(); - aSubField1->allocValue(/*NumberOfComponents*/2, /*LengthValue*/5); - //#ifdef ENABLE_FAULTS - // (BUG) No compatibility between Support and allocated value - aSubField1->normL1(); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("Error: no compatibility between Support and allocated value"); - //#endif - } - catch (MEDEXCEPTION & ex) - { - // normal behaviour - } - catch (...) - { - CPPUNIT_FAIL("Error: no compatibility between Support and allocated value"); - } - - // check that aFieldOnGroup1 is not changed after aSubField1 modifications - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // reset aFieldOnGroup2 values for simple control of operators results - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup2->setValueIJ(anElems[i-1], 1, i*i); - aFieldOnGroup2->setValueIJ(anElems[i-1], 2, -i*i); - } - - int len = aFieldOnGroup1->getValueLength(); - const double * val1 = aFieldOnGroup1->getValue(); - const double * val2 = aFieldOnGroup2->getValue(); - const double * val_res; - - // operators and add, sub, mul, div - - // + - FIELD *aSum = *aFieldOnGroup1 + *aFieldOnGroup2; - aSum->setName(aFieldOnGroup1->getName()); - aSum->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aSum, true, true); - val_res = aSum->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val2[i], val_res[i], 0.000001); - } - aSum->removeReference(); - - // - - FIELD *aDifference = *aFieldOnGroup1 - *aFieldOnGroup2; - aDifference->setName(aFieldOnGroup1->getName()); - aDifference->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aDifference, true, true); - val_res = aDifference->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] - val2[i], val_res[i], 0.000001); - } - aDifference->removeReference(); - - // - (unary) - FIELD *aNegative = - *aFieldOnGroup1; - aNegative->setName(aFieldOnGroup1->getName()); - aNegative->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aNegative, true, true); - val_res = aNegative->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(- val1[i], val_res[i], 0.000001); - } - aNegative->removeReference(); - - // * - FIELD *aProduct = (*aFieldOnGroup1) * (*aFieldOnGroup2); - aProduct->setName(aFieldOnGroup1->getName()); - aProduct->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aProduct, true, true); - val_res = aProduct->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] * val2[i], val_res[i], 0.000001); - } - aProduct->removeReference(); - // / - FIELD *aQuotient = *aFieldOnGroup1 / *aFieldOnGroup2; - aQuotient->setName(aFieldOnGroup1->getName()); - aQuotient->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aQuotient, true, true); - val_res = aQuotient->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] / val2[i], val_res[i], 0.000001); - } - aQuotient->removeReference(); - - double val22 = aFieldOnGroup2->getValueIJ(anElems[2], 2); - aFieldOnGroup2->setValueIJ(anElems[2], 2, 0.); - - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 / *aFieldOnGroup2, MEDEXCEPTION); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) is it up to user to control validity of data to avoid division on zero? - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 /= *aFieldOnGroup2, MEDEXCEPTION); - //#endif - CPPUNIT_ASSERT_THROW(FIELD::div(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - - // restore value - aFieldOnGroup2->setValueIJ(anElems[2], 2, val22); - - // restore values - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup1->setValueIJ(anElems[i-1], 1, 13 + i); - aFieldOnGroup1->setValueIJ(anElems[i-1], 2, 13 - i); - } - - // static methods - FIELD * aPtr; - - // add - aPtr = FIELD::add(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // sub - aPtr = FIELD::sub(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] - val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // mul - aPtr = FIELD::mul(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] * val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // div - aPtr = FIELD::div(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] / val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // addDeep - aPtr = FIELD::addDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // subDeep - aPtr = FIELD::subDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] - val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // mulDeep - aPtr = FIELD::mulDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] * val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // divDeep - aPtr = FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup2); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] / val2[i], val_res[i], 0.000001); - } - delete aPtr; - - // += - *aFieldOnGroup1 += *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i + i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i - i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // -= - *aFieldOnGroup1 -= *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // *= - *aFieldOnGroup1 *= *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL( (13 + i)*i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-(13 - i)*i*i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // /= - *aFieldOnGroup1 /= *aFieldOnGroup2; - for (int i = 1; i <= nbVals; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 + i, aFieldOnGroup1->getValueIJ(anElems[i-1], 1), 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13 - i, aFieldOnGroup1->getValueIJ(anElems[i-1], 2), 0.000001); - } - - // check case of different operands: support - MESH * aMeshOneMore = MEDMEMTest_createTestMesh(); - const GROUP* aGroupOneMore = aMeshOneMore->getGroup(MED_EN::MED_FACE, 1); - FIELD * aFieldOnGroup3 = - createFieldOnGroup(aMeshOneMore, aGroupOneMore, "Test_Diff_Mesh", "test"); - for (int i = 1; i <= nbVals; i++) - { - aFieldOnGroup3->setValueIJ(anElems[i-1], 1, 2*i); - aFieldOnGroup3->setValueIJ(anElems[i-1], 2, 3*i); - } - const double * val3 = aFieldOnGroup3->getValue(); - - //CPPUNIT_ASSERT_NO_THROW(); - try - { - aPtr = FIELD::addDeep(*aFieldOnGroup1, *aFieldOnGroup3); - aPtr->setName(aFieldOnGroup1->getName()); - aPtr->setDescription(aFieldOnGroup1->getDescription()); - compareField_(aFieldOnGroup1, aPtr, true, true); - val_res = aPtr->getValue(); - for (int i = 0; i < len; i++) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL(val1[i] + val3[i], val_res[i], 0.000001); - } - delete aPtr; - - aPtr = FIELD::subDeep(*aFieldOnGroup1, *aFieldOnGroup3); - delete aPtr; - aPtr = FIELD::mulDeep(*aFieldOnGroup1, *aFieldOnGroup3); - delete aPtr; - aPtr = FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup3); - delete aPtr; - } - catch (MEDEXCEPTION & ex) - { - CPPUNIT_FAIL(ex.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception in FIELD::xxxDeep()"); - } - - CPPUNIT_ASSERT_THROW(FIELD::add(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::sub(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::mul(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::div(*aFieldOnGroup1, *aFieldOnGroup3), MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 + *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 - *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 * *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 / *aFieldOnGroup3, MEDEXCEPTION); - - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 += *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 -= *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 *= *aFieldOnGroup3, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 /= *aFieldOnGroup3, MEDEXCEPTION); - - // check case of different operands: MEDComponentsUnits - aFieldOnGroup1->setMEDComponentUnit(1, "unit3"); - - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 + *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 - *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 += *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(*aFieldOnGroup1 -= *aFieldOnGroup2, MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::add(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::sub(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::addDeep(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(FIELD::subDeep(*aFieldOnGroup1, *aFieldOnGroup2), MEDEXCEPTION); - - //CPPUNIT_ASSERT_NO_THROW(); - try - { - aPtr = FIELD::mul(*aFieldOnGroup1, *aFieldOnGroup2); - delete aPtr; - aPtr = FIELD::div(*aFieldOnGroup1, *aFieldOnGroup2); - delete aPtr; - aPtr = FIELD::mulDeep(*aFieldOnGroup1, *aFieldOnGroup2); - delete aPtr; - aPtr = FIELD::divDeep(*aFieldOnGroup1, *aFieldOnGroup2); - delete aPtr; - - *aFieldOnGroup1 *= *aFieldOnGroup2; - *aFieldOnGroup1 /= *aFieldOnGroup2; - - FIELD *aPr = *aFieldOnGroup1 * *aFieldOnGroup2; - FIELD *aQu = *aFieldOnGroup1 / *aFieldOnGroup2; - aPr->removeReference(); - aQu->removeReference(); - } - catch (MEDEXCEPTION & ex) - { - CPPUNIT_FAIL(ex.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // restore MED units - aFieldOnGroup1->setMEDComponentUnit(1, "unit1"); - - // check case of different operands: numberOfComponents - //#ifdef ENABLE_FAULTS - // (BUG) Cannot allocate value of higher dimension because of _componentsTypes reinitialization - // Must be MEDEXCEPTION instead. And on attempt to change nb.components must be the same behaviour. - aFieldOnGroup1->deallocValue(); - CPPUNIT_ASSERT_THROW(aFieldOnGroup1->allocValue(/*dim*/5), MEDEXCEPTION); - //#endif - - aSubSupport1->removeReference(); - delete [] anElems1; - - delete aScalarProduct; - delete aSubField1; - delete anAreaField; - delete barycenter; - delete aFieldOnGroup1; - delete aFieldOnGroup2; - delete aFieldOnGroup3; - - delete aMesh; - delete aMeshOneMore; - - ///////////////////// - // TEST 5: Drivers // - ///////////////////// - testDrivers(); -} - -int main (int argc, char** argv) -{ - MEDMEMTest_testField(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Formulae.cxx b/src/MEDMEMCppTest/MEDMEMTest_Formulae.cxx deleted file mode 100644 index 52401d568..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Formulae.cxx +++ /dev/null @@ -1,629 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "VolSurfFormulae.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Exception.hxx" - -#include -#include -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #17: MEDMEM_Formulae.hxx } MEDMEMTest_Formulae.cxx - -/*! - * Check methods (13), defined in MEDMEM_Formulae.hxx: - * - * (+) inline void CalculateBarycenterDyn(const double **pts, int nbPts, int dim, double *bary); - * - * (+) inline double CalculateAreaForPolyg(const double **coords, int nbOfPtsInPolygs, int spaceDim); - * (+) inline double CalculateAreaForTria(const double *p1, const double *p2, - * const double *p3, int spaceDim); - * (+) inline double CalculateAreaForQuad(const double *p1, const double *p2, - * const double *p3, const double *p4, int spaceDim); - * - * (+) inline void CalculateNormalForTria(const double *p1, const double *p2, - * const double *p3, double *normal); - * (+) inline void CalculateNormalForQuad(const double *p1, const double *p2, - * const double *p3, const double *p4, double *normal); - * (+) inline void CalculateNormalForPolyg(const double **coords, int nbOfPtsInPolygs, double *normal); - * - * (+) inline double CalculateVolumeForTetra(const double *p1, const double *p2, - * const double *p3, const double *p4); - * (+) inline double CalculateVolumeForPyra(const double *p1, const double *p2, - * const double *p3, const double *p4, const double *p5); - * (+) inline double CalculateVolumeForPenta(const double *p1, const double *p2, const double *p3, - * const double *p4, const double *p5, const double *p6); - * (+) inline double CalculateVolumeForHexa(const double *pt1, const double *pt2, const double *pt3, - * const double *pt4, const double *pt5, const double *pt6, - * const double *pt7, const double *pt8); - * (+) inline double CalculateVolumeForPolyh(const double ***pts, const int *nbOfNodesPerFaces, - * int nbOfFaces, const double *bary); - * - * (+) template inline double addComponentsOfVec(const double **pts, int rk); - * (+) template<> inline double addComponentsOfVec<1>(const double **pts, int rk); - * - * (+) template inline void CalculateBarycenter(const double **pts, double *bary); - * (-) template<> inline void CalculateBarycenter<2,0>(const double **pts, double *bary); - * (-) template<> inline void CalculateBarycenter<3,0>(const double **pts, double *bary); - * (-) template<> inline void CalculateBarycenter<4,0>(const double **pts, double *bary); - * (-) template<> inline void CalculateBarycenter<5,0>(const double **pts, double *bary); - * (-) template<> inline void CalculateBarycenter<6,0>(const double **pts, double *bary); - * (-) template<> inline void CalculateBarycenter<7,0>(const double **pts, double *bary); - * (-) template<> inline void CalculateBarycenter<8,0>(const double **pts, double *bary); - */ -void MEDMEMTest::testFormulae() -{ - double val; - - // ^y - // | - // *3 - // 4 | - // .*. . . . . . *6,7 - // | - // . .8* . . . . . - // | 5 2,9 - // . . . .*. * . . - // 1| - // -.-.-*-.-.-.-.-.-->x - // | - - // S_12634 = (3 + (3+4.8)*2 + 4.8 + 1.5*4)/2 = 1.5 + 7.8 + 2.4 + 3 = 14.7 - // S_143652 = S_14362 - S_625 = 14.7 - 2 * 1.5 / 2 = 13.2 - - double xy1[2] = { 0.0, 0.0}; - double xy2[2] = { 3.0, 1.0}; - double xy3[2] = { 0.0, 4.0}; - double xy4[2] = {-1.5, 3.0}; - double xy5[2] = { 1.5, 1.0}; - double xy6[2] = { 4.8, 3.0}; - - double xyz1[3] = { 0.0, 0.0, 0.0}; - double xyz2[3] = { 3.0, 1.0, 4.0}; // cos(alpha) = 3/5 - double xyz3[3] = { 0.0, 4.0, 0.0}; - double xyz4[3] = {-1.5, 3.0, -2.0}; // z4 = z2 * x4 / x2 = - 4 * 1.5 / 3 - double xyz5[3] = { 1.5, 1.0, 2.0}; // z5 = z2 * x5 / x2 = 4 * 1.5 / 3 - double xyz6[3] = { 4.8, 3.0, 6.4}; // z6 = z2 * x6 / x2 = 4 * 4.8 / 3 - double xyz7[3] = { 4.8, 3.0, 0.0}; - double xyz8[3] = { 0.0, 2.0, 0.0}; - double xyz9[3] = { 3.0, 1.0, 0.0}; - - // S_3d = S_2d * 5.0 / 3.0 - - /////////////////////////// - // CalculateAreaForPolyg // - /////////////////////////// - { - // 2D: Convex polygon - const double * poly_2d_cc[5] = {xy1, xy2, xy6, xy3, xy4}; - const double * poly_2d_cw[5] = {xy1, xy4, xy3, xy6, xy2}; - - // counter-clockwise - val = INTERP_KERNEL::calculateAreaForPolyg(poly_2d_cc, /*nbOfPtsInPolygs*/5, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-14.7, val, 0.000001); - - // clockwise - val = INTERP_KERNEL::calculateAreaForPolyg(poly_2d_cw, /*nbOfPtsInPolygs*/5, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(14.7, val, 0.000001); - - // 2D: Non-convex polygon - const double * poly_2d_nc[6] = {xy1, xy4, xy3, xy6, xy5, xy2}; - val = INTERP_KERNEL::calculateAreaForPolyg(poly_2d_nc, /*nbOfPtsInPolygs*/6, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(13.2, val, 0.000001); - - // 3D: Convex polygon - const double * poly_3d_cc[5] = {xyz1, xyz2, xyz6, xyz3, xyz4}; - - val = INTERP_KERNEL::calculateAreaForPolyg(poly_3d_cc, /*nbOfPtsInPolygs*/5, /*dim*/3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(24.5, val, 0.000001); - - // 3D: Non-convex polygon - const double * poly_3d_nc[6] = {xyz1, xyz4, xyz3, xyz6, xyz5, xyz2}; - val = INTERP_KERNEL::calculateAreaForPolyg(poly_3d_nc, /*nbOfPtsInPolygs*/6, /*dim*/3); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Wrong area calculation for non-convex polygons in 3D space, - // because area of triangle is always positive - // It's a spec - //CPPUNIT_ASSERT_DOUBLES_EQUAL(22.0, val, 0.000001); - CPPUNIT_ASSERT( abs(22.0-val)>0.000001 ); - //#endif - } - - ////////////////////////// - // CalculateAreaForTria // - ////////////////////////// - { - // 2D: counter-clockwise - val = INTERP_KERNEL::calculateAreaForTria(xy1, xy2, xy3, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.0, val, 0.000001); - - // 2D: clockwise - val = INTERP_KERNEL::calculateAreaForTria(xy2, xy1, xy3, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.0, val, 0.000001); - - // 3D - val = INTERP_KERNEL::calculateAreaForTria(xyz1, xyz2, xyz3, /*dim*/3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, val, 0.000001); - - // Invalid (three points on one line) - val = INTERP_KERNEL::calculateAreaForTria(xyz1, xyz8, xyz3, /*dim*/3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, val, 0.000001); - } - - ////////////////////////// - // CalculateAreaForQuad // - ////////////////////////// - { - // 2D: Convex quadrangle - - // counter-clockwise - val = INTERP_KERNEL::calculateAreaForQuad(xy1, xy2, xy3, xy4, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-9.0, val, 0.000001); - - // clockwise - val = INTERP_KERNEL::calculateAreaForQuad(xy2, xy1, xy4, xy3, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0, val, 0.000001); - - // wrong order - CPPUNIT_ASSERT_NO_THROW(INTERP_KERNEL::calculateAreaForQuad(xy2, xy1, xy3, xy4, /*dim*/2)); - - // 2D: Non-convex quadrangle - - // counter-clockwise - val = INTERP_KERNEL::calculateAreaForQuad(xy1, xy2, xy3, xy5, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-3.0, val, 0.000001); - - // clockwise - val = INTERP_KERNEL::calculateAreaForQuad(xy1, xy5, xy3, xy2, /*dim*/2); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, val, 0.000001); - - // 3D: Convex quadrangle - - // good order - val = INTERP_KERNEL::calculateAreaForQuad(xyz1, xyz2, xyz3, xyz4, /*dim*/3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(15.0, val, 0.000001); - - // wrong order - CPPUNIT_ASSERT_NO_THROW(INTERP_KERNEL::calculateAreaForQuad(xyz1, xyz4, xyz2, xyz3, /*dim*/3)); - - // 3D: Non-convex quadrangle - val = INTERP_KERNEL::calculateAreaForQuad(xyz1, xyz2, xyz3, xyz5, /*dim*/3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, val, 0.000001); - - // 3D: Non-planar quadrangle - double xyz7[3] = {-1.5, 3.0, 2.0}; - CPPUNIT_ASSERT_NO_THROW(INTERP_KERNEL::calculateAreaForQuad(xyz1, xyz2, xyz3, xyz7, /*dim*/3)); - } - - //////////////////////////// - // CalculateNormalForTria // - //////////////////////////// - { - double tria_normal [3]; - - // Triangle in plane XOY, normal is opposit to axis Z - INTERP_KERNEL::calculateNormalForTria(xyz1, xyz3, xyz7, tria_normal); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, tria_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, tria_normal[1], 0.0000001); // Ny - CPPUNIT_ASSERT(tria_normal[2] < -0.0000001); // Nz - - // Triangle in plane XOY, normal co-directed with axis Z - INTERP_KERNEL::calculateNormalForTria(xyz1, xyz7, xyz3, tria_normal); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, tria_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, tria_normal[1], 0.0000001); // Ny - CPPUNIT_ASSERT(tria_normal[2] > 0.0000001); // Nz - - // Triangle in 3D - INTERP_KERNEL::calculateNormalForTria(xyz1, xyz3, xyz6, tria_normal); - double koeff = tria_normal[0]/12.8; - //CPPUNIT_ASSERT_DOUBLES_EQUAL(12.8, tria_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0 , tria_normal[1], 0.0000001); // Ny - CPPUNIT_ASSERT_DOUBLES_EQUAL(-9.6 * koeff, tria_normal[2], 0.0000001); // Nz - - // Invalid Triangle (three points on one line) - CPPUNIT_ASSERT_NO_THROW(INTERP_KERNEL::calculateNormalForTria(xyz1, xyz8, xyz3, tria_normal)); - //MEDMEMTest_DumpArray(cout, tria_normal, 3, "Invalid Triangle normal"); - //Invalid Triangle normal: {0, 0, 0} - } - - //////////////////////////// - // CalculateNormalForQuad // - //////////////////////////// - { - double quad_normal [3]; - - // Quadrangle in plane XOY, normal is opposit to axis Z - INTERP_KERNEL::calculateNormalForQuad(xyz1, xyz3, xyz7, xyz9, quad_normal); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, quad_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, quad_normal[1], 0.0000001); // Ny - CPPUNIT_ASSERT(quad_normal[2] < -0.0000001); // Nz - - // Quadrangle in plane XOY, normal co-directed with axis Z - INTERP_KERNEL::calculateNormalForQuad(xyz1, xyz9, xyz7, xyz3, quad_normal); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, quad_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, quad_normal[1], 0.0000001); // Ny - CPPUNIT_ASSERT(quad_normal[2] > 0.0000001); // Nz - - // Quadrangle in 3D - INTERP_KERNEL::calculateNormalForQuad(xyz1, xyz3, xyz6, xyz2, quad_normal); - //MEDMEMTest_DumpArray(cout, quad_normal, 3, "Quadrangle in 3D normal"); - double koeff = quad_normal[0]/15.6; - //CPPUNIT_ASSERT_DOUBLES_EQUAL(15.6, quad_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0 , quad_normal[1], 0.0000001); // Ny - CPPUNIT_ASSERT_DOUBLES_EQUAL(-11.7 * koeff, quad_normal[2], 0.0000001); // Nz - - // Invalid Quadrangle (four points on one line) - CPPUNIT_ASSERT_NO_THROW(INTERP_KERNEL::calculateNormalForQuad(xyz1, xyz8, xyz3, xyz3, quad_normal)); - //MEDMEMTest_DumpArray(cout, quad_normal, 3, "Invalid Quadrangle normal"); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) division on zero in CalculateNormalForQuad(), if quadrangle is singular - //Invalid Quadrangle normal: {nan, nan, nan} - // Spec. Wait for an improvement - // CPPUNIT_ASSERT(quad_normal[0] < DBL_MAX); - // CPPUNIT_ASSERT(quad_normal[1] < DBL_MAX); - // CPPUNIT_ASSERT(quad_normal[2] < DBL_MAX); - //#endif - } - - ///////////////////////////// - // CalculateNormalForPolyg // - ///////////////////////////// - { - double poly_normal [3]; - const double * polygon_cc[4] = {xyz1, xyz3, xyz7, xyz9}; - const double * polygon_er[4] = {xyz1, xyz8, xyz3, xyz7}; - const double * polygon_cw[4] = {xyz1, xyz9, xyz7, xyz3}; - const double * polygon_3d[4] = {xyz1, xyz3, xyz6, xyz2}; - const double * polygon_si[4] = {xyz1, xyz8, xyz3, xyz3}; - - // Polygon in plane XOY, normal is opposit to axis Z - INTERP_KERNEL::calculateNormalForPolyg(polygon_cc, /*nbOfPtsInPolygs*/4, poly_normal); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, poly_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, poly_normal[1], 0.0000001); // Ny - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Normal for polygon is wrong. Confired to be a bug - CPPUNIT_ASSERT_DOUBLES_EQUAL(-11.7, poly_normal[2], 0.0000001); // Nz - //#endif - - // Polygon in plane XOY, normal co-directed with axis Z - INTERP_KERNEL::calculateNormalForPolyg(polygon_cw, /*nbOfPtsInPolygs*/4, poly_normal); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, poly_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, poly_normal[1], 0.0000001); // Ny - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Normal for polygon is wrong. Confired to be a bug - CPPUNIT_ASSERT_DOUBLES_EQUAL(11.7, poly_normal[2], 0.0000001); // Nz - //#endif - - // Polygon in plane XOY, normal is opposit to axis Z, first three points lay on one line - //CPPUNIT_ASSERT_THROW(CalculateNormalForPolyg(polygon_er, /*nbOfPtsInPolygs*/4, - // poly_normal),MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(INTERP_KERNEL::calculateNormalForPolyg(polygon_er, /*nbOfPtsInPolygs*/4, - poly_normal)); - //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, poly_normal[0], 0.0000001); // Nx - //CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, poly_normal[1], 0.0000001); // Ny - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Normal for polygon is wrong if first (three) points are on one line - // Spec, can be improved - // CPPUNIT_ASSERT(poly_normal[2] < -0.0000001); // Nz - //#endif - - // Polygon in 3D - INTERP_KERNEL::calculateNormalForPolyg(polygon_3d, /*nbOfPtsInPolygs*/4, poly_normal); - double koeff = poly_normal[0]/15.6; - //CPPUNIT_ASSERT_DOUBLES_EQUAL(15.6, poly_normal[0], 0.0000001); // Nx - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.0 , poly_normal[1], 0.0000001); // Ny - CPPUNIT_ASSERT_DOUBLES_EQUAL(-11.7 * koeff, poly_normal[2], 0.0000001); // Nz - - // Invalid Polygon (four points on one line) - bool isException=false; - try - { - INTERP_KERNEL::calculateNormalForPolyg(polygon_si, /*nbOfPtsInPolygs*/4, - poly_normal); - } - catch(std::exception& e) - { - isException=true; - } - CPPUNIT_ASSERT(isException); - //MEDMEMTest_DumpArray(cout, poly_normal, 3, "Invalid Polygon normal"); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) division on zero in CalculateNormalForPolyg(), if polygon is singular - //Invalid Polygon normal: {nan, nan, nan} - // Cinfirmed to be a bug - //CPPUNIT_ASSERT(poly_normal[0] < DBL_MAX); - //CPPUNIT_ASSERT(poly_normal[1] < DBL_MAX); - //CPPUNIT_ASSERT(poly_normal[2] < DBL_MAX); - //#endif - } - - ///////////////////////////// - // CalculateVolumeForTetra // - ///////////////////////////// - { - // good - val = INTERP_KERNEL::calculateVolumeForTetra(xyz1, xyz3, xyz7, xyz5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.4, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForTetra(xyz1, xyz7, xyz3, xyz5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.4, val, 0.000001); - - // good - val = INTERP_KERNEL::calculateVolumeForTetra(xyz1, xyz7, xyz3, xyz4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(6.4, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForTetra(xyz1, xyz3, xyz7, xyz4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.4, val, 0.000001); - - // singular (in plane) - val = INTERP_KERNEL::calculateVolumeForTetra(xyz1, xyz3, xyz7, xyz9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, val, 0.000001); - } - - //////////////////////////// - // CalculateVolumeForPyra // - //////////////////////////// - { - // good - val = INTERP_KERNEL::calculateVolumeForPyra(xyz1, xyz3, xyz7, xyz9, xyz5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForPyra(xyz1, xyz9, xyz7, xyz3, xyz5); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-7.8, val, 0.000001); - - // good - val = INTERP_KERNEL::calculateVolumeForPyra(xyz1, xyz9, xyz7, xyz3, xyz4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(7.8, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForPyra(xyz1, xyz3, xyz7, xyz9, xyz4); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-7.8, val, 0.000001); - - // singular (in plane) - val = INTERP_KERNEL::calculateVolumeForPyra(xyz1, xyz3, xyz7, xyz9, xyz8); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, val, 0.000001); - } - - ///////////////////////////// - // CalculateVolumeForPenta // - ///////////////////////////// - { - double top1[3] = {xyz1[0], xyz1[1], xyz1[2] + 10.0}; - double top3[3] = {xyz3[0], xyz3[1], xyz3[2] + 10.0}; - double top7[3] = {xyz7[0], xyz7[1], xyz7[2] + 10.0}; - - // good - val = INTERP_KERNEL::calculateVolumeForPenta(xyz1, xyz3, xyz7, top1, top3, top7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForPenta(xyz1, xyz7, xyz3, top1, top7, top3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-96.0, val, 0.000001); - - // good - top1[0] = top1[0] + 7.0; - top3[0] = top3[0] + 7.0; - top7[0] = top7[0] + 7.0; - - val = INTERP_KERNEL::calculateVolumeForPenta(xyz1, xyz3, xyz7, top1, top3, top7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(96.0, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForPenta(xyz1, xyz7, xyz3, top1, top7, top3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-96.0, val, 0.000001); - - // singular (in plane) - top1[2] = top1[2] - 10.0; - top3[2] = top3[2] - 10.0; - top7[2] = top7[2] - 10.0; - - val = INTERP_KERNEL::calculateVolumeForPenta(xyz1, xyz3, xyz7, top1, top3, top7); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, val, 0.000001); - } - - //////////////////////////// - // CalculateVolumeForHexa // - //////////////////////////// - { - double top1[3] = {xyz1[0], xyz1[1], xyz1[2] + 10.0}; - double top3[3] = {xyz3[0], xyz3[1], xyz3[2] + 10.0}; - double top7[3] = {xyz7[0], xyz7[1], xyz7[2] + 10.0}; - double top9[3] = {xyz9[0], xyz9[1], xyz9[2] + 10.0}; - - // good - val = INTERP_KERNEL::calculateVolumeForHexa(xyz1, xyz3, xyz7, xyz9, top1, top3, top7, top9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(117.0, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForHexa(xyz1, xyz9, xyz7, xyz3, top1, top9, top7, top3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-117.0, val, 0.000001); - - // good - top1[0] = top1[0] + 7.0; - top3[0] = top3[0] + 7.0; - top7[0] = top7[0] + 7.0; - top9[0] = top9[0] + 7.0; - - val = INTERP_KERNEL::calculateVolumeForHexa(xyz1, xyz3, xyz7, xyz9, top1, top3, top7, top9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(117.0, val, 0.000001); - - // reversed - val = INTERP_KERNEL::calculateVolumeForHexa(xyz1, xyz9, xyz7, xyz3, top1, top9, top7, top3); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-117.0, val, 0.000001); - - // singular (in plane) - top1[2] = top1[2] - 10.0; - top3[2] = top3[2] - 10.0; - top7[2] = top7[2] - 10.0; - top9[2] = top9[2] - 10.0; - - val = INTERP_KERNEL::calculateVolumeForHexa(xyz1, xyz3, xyz7, xyz9, top1, top3, top7, top9); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, val, 0.000001); - } - - ///////////////////////////// - // CalculateVolumeForPolyh // - ///////////////////////////// - // inline double CalculateVolumeForPolyh(const double ***pts, const int *nbOfNodesPerFaces, - // int nbOfFaces, const double *bary); - { - int nbFaces = 4; - int nbOfNodesPerFaces[4] = {3,3,3,3}; - - const double * nodes[4] = {xyz1, xyz7, xyz3, xyz5}; - double bary[3]; - INTERP_KERNEL::calculateBarycenterDyn(nodes, 4, /*dim*/3, bary); - - // good - const double * fa1[3] = {xyz1, xyz7, xyz3}; - const double * fa2[3] = {xyz1, xyz3, xyz5}; - const double * fa3[3] = {xyz3, xyz7, xyz5}; - const double * fa4[3] = {xyz7, xyz1, xyz5}; - const double ** polyh[4] = {fa1, fa2, fa3, fa4}; - - val = INTERP_KERNEL::calculateVolumeForPolyh(polyh, nbOfNodesPerFaces, nbFaces, bary); - CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.4, val, 0.000001); - - // reversed - //const double * fa1_r[3] = {xyz1, xyz3, xyz7}; - //const double * fa2_r[3] = {xyz3, xyz1, xyz5}; - //const double * fa3_r[3] = {xyz7, xyz3, xyz5}; - //const double * fa4_r[3] = {xyz1, xyz7, xyz5}; - //const double ** polyh_r[4] = {fa1_r, fa2_r, fa3_r, fa4_r}; - // - //val = CalculateVolumeForPolyh(polyh_r, nbOfNodesPerFaces, nbFaces, bary); - //CPPUNIT_ASSERT_DOUBLES_EQUAL(-6.4, val, 0.000001); - - // singular (in plane) - const double * nodes_si[4] = {xyz1, xyz7, xyz3, xyz9}; - double bary_si[3]; - INTERP_KERNEL::calculateBarycenterDyn(nodes_si, 4, /*dim*/3, bary_si); - - const double * fa1_si[3] = {xyz1, xyz7, xyz3}; - const double * fa2_si[3] = {xyz1, xyz3, xyz9}; - const double * fa3_si[3] = {xyz3, xyz7, xyz9}; - const double * fa4_si[3] = {xyz7, xyz1, xyz9}; - const double ** polyh_si[4] = {fa1_si, fa2_si, fa3_si, fa4_si}; - - val = INTERP_KERNEL::calculateVolumeForPolyh(polyh_si, nbOfNodesPerFaces, nbFaces, bary_si); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, val, 0.000001); - } - - //////////////////////// - // addComponentsOfVec // - //////////////////////// - { - // five points - const double * pts[5] = {xyz2, xyz1, xyz3, xyz4, xyz5}; - - val = INTERP_KERNEL::addComponentsOfVec<5>(pts, 0); // x - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, val, 0.000001); - - val = INTERP_KERNEL::addComponentsOfVec<5>(pts, 1); // y - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0, val, 0.000001); - - val = INTERP_KERNEL::addComponentsOfVec<5>(pts, 2); // z - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, val, 0.000001); - - // one point: xyz2 - val = INTERP_KERNEL::addComponentsOfVec<1>(pts, 0); // x - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, val, 0.000001); - - val = INTERP_KERNEL::addComponentsOfVec<1>(pts, 1); // y - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, val, 0.000001); - - val = INTERP_KERNEL::addComponentsOfVec<1>(pts, 2); // z - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, val, 0.000001); - } - - //////////////////////////// - // CalculateBarycenterDyn // - //////////////////////////// - { - // five points - const double * pts[5] = {xyz2, xyz1, xyz3, xyz4, xyz5}; - double bary_3d[3]; - double bary_2d[2]; - - INTERP_KERNEL::calculateBarycenterDyn(pts, /*nbPts*/5, /*dim*/3, bary_3d); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0/5.0, bary_3d[0], 0.000001); // x - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0/5.0, bary_3d[1], 0.000001); // y - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0/5.0, bary_3d[2], 0.000001); // z - - INTERP_KERNEL::calculateBarycenterDyn(pts, /*nbPts*/5, /*dim*/2, bary_2d); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0/5.0, bary_2d[0], 0.000001); // x - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0/5.0, bary_2d[1], 0.000001); // y - - // one point: xyz2 - INTERP_KERNEL::calculateBarycenterDyn(pts, /*nbPts*/1, /*dim*/3, bary_3d); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, bary_3d[0], 0.000001); // x - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, bary_3d[1], 0.000001); // y - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, bary_3d[2], 0.000001); // z - } - - ///////////////////////// - // CalculateBarycenter // - ///////////////////////// - // template inline void CalculateBarycenter(const double **pts, double *bary); - // template<> inline void CalculateBarycenter<2,0>(const double **pts, double *bary); - // template<> inline void CalculateBarycenter<3,0>(const double **pts, double *bary); - // template<> inline void CalculateBarycenter<4,0>(const double **pts, double *bary); - // template<> inline void CalculateBarycenter<5,0>(const double **pts, double *bary); - // template<> inline void CalculateBarycenter<6,0>(const double **pts, double *bary); - // template<> inline void CalculateBarycenter<7,0>(const double **pts, double *bary); - // template<> inline void CalculateBarycenter<8,0>(const double **pts, double *bary); - { - // five points - const double * pts[5] = {xyz2, xyz1, xyz3, xyz4, xyz5}; - double bary_3d[3]; - double bary_2d[2]; - - INTERP_KERNEL::calculateBarycenter<5,3>(pts, bary_3d); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0/5.0, bary_3d[0], 0.000001); // x - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0/5.0, bary_3d[1], 0.000001); // y - CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0/5.0, bary_3d[2], 0.000001); // z - - INTERP_KERNEL::calculateBarycenter<5,2>(pts, bary_2d); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0/5.0, bary_2d[0], 0.000001); // x - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0/5.0, bary_2d[1], 0.000001); // y - - // one point: xyz2 : NOT IMPLEMENTED!!! - //CalculateBarycenter<1,3>(pts, bary_3d); - //CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, bary_3d[0], 0.000001); - //CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, bary_3d[1], 0.000001); - //CPPUNIT_ASSERT_DOUBLES_EQUAL(4.0, bary_3d[2], 0.000001); - } -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_GaussLocalization.cxx b/src/MEDMEMCppTest/MEDMEMTest_GaussLocalization.cxx deleted file mode 100644 index 7db40f98c..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_GaussLocalization.cxx +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_GaussLocalization.hxx" -#include "MEDMEM_STRING.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #18: MEDMEM_GaussLocalization.hxx } MEDMEMTest.cxx - -/*! - * Check methods (13), defined in MEDMEM_GaussLocalization.hxx: - * class GAUSS_LOCALIZATION_ { - * (+) virtual MED_EN::medModeSwitch getInterlacingType() const; - * (+) virtual ~GAUSS_LOCALIZATION_(); - * } - * (+) template class GAUSS_LOCALIZATION; - * - * (+) template ostream & operator<< - * (ostream &os, const GAUSS_LOCALIZATION &loc); - * - * template class GAUSS_LOCALIZATION : public GAUSS_LOCALIZATION_ { - * (+) GAUSS_LOCALIZATION() throw (MEDEXCEPTION); - * (+) GAUSS_LOCALIZATION(const string & locName, - * const MED_EN::medGeometryElement typeGeo, - * const int nGauss, - * const ArrayNoGauss & cooRef, - * const ArrayNoGauss & cooGauss, - * const vector & wg) throw (MEDEXCEPTION); - * (+) GAUSS_LOCALIZATION(const string & locName, - * const MED_EN::medGeometryElement typeGeo, - * const int nGauss, - * const double * const cooRef, - * const double * const cooGauss, - * const double * const wg) throw (MEDEXCEPTION); - * (+) virtual ~GAUSS_LOCALIZATION(); - * - * (+) GAUSS_LOCALIZATION & operator=(const GAUSS_LOCALIZATION & gaussLoc); - * (+) bool operator == (const GAUSS_LOCALIZATION &loc) const; - * - * (+) string getName() const; - * (+) MED_EN::medGeometryElement getType() const; - * - * (+) int getNbGauss() const; - * (+) ArrayNoGauss getRefCoo () const; - * (+) ArrayNoGauss getGsCoo () const; - * (+) vector getWeight () const; - * - * (+) inline MED_EN::medModeSwitch getInterlacingType() const; - * } - */ -void MEDMEMTest::testGaussLocalization() -{ - // GAUSS_LOCALIZATION_ - GAUSS_LOCALIZATION_ aGL_; - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_UNDEFINED_INTERLACE, aGL_.getInterlacingType()); - - // GAUSS_LOCALIZATION empty constructor and InterlaceType - GAUSS_LOCALIZATION<> anEmptyGL1; - MED_EN::medModeSwitch aDefaultInterlaceType = anEmptyGL1.getInterlacingType(); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FULL_INTERLACE, aDefaultInterlaceType); - - GAUSS_LOCALIZATION anEmptyGL2; - MED_EN::medModeSwitch anInterlaceType2 = anEmptyGL2.getInterlacingType(); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NO_INTERLACE, anInterlaceType2); - - // Construction from C++ arrays - double cooRef[6] = {1.,1., 2.,4., 3.,9.}; // xy xy xy - double cooGauss[10] = {7.,7., 6.,6., 5.,5., 4.,3., 2.,1.}; // x1,y1 x2,y2 x3,y3 x4,y4 x5,y5 - double wg[5] = {1., 2., 3., 4., 5.}; - - GAUSS_LOCALIZATION<> gl1 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef, cooGauss, wg); - GAUSS_LOCALIZATION<> gl2 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef, cooGauss, wg); - - // getXXX - CPPUNIT_ASSERT(gl1.getName() == "GL1"); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_TRIA3, gl1.getType()); - CPPUNIT_ASSERT_EQUAL(5, gl1.getNbGauss()); - - GAUSS_LOCALIZATION<>::ArrayNoGauss cooRefBack = gl1.getRefCoo(); - GAUSS_LOCALIZATION<>::ArrayNoGauss cooGaussBack = gl1.getGsCoo(); - vector wgBack = gl1.getWeight(); - - double * cooRefBack_ptr = cooRefBack.getPtr(); - double * cooGaussBack_ptr = cooGaussBack.getPtr(); - - // (BUG)Reading uninitialized memory here - // TODO fix - for (int i = 0; i < 10; i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL(cooRef[i%6], cooRefBack_ptr[i%6], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(cooGauss[i], cooGaussBack_ptr[i], 0.000001); - CPPUNIT_ASSERT_DOUBLES_EQUAL(wg[i%5] , wgBack[i%5] , 0.000001); - } - - // Operators == and = - CPPUNIT_ASSERT(gl1 == gl2); - CPPUNIT_ASSERT_EQUAL(gl1, gl2); - - GAUSS_LOCALIZATION<> gl1_c; - gl1_c = gl1; - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Badly copyed arrays as a result of operator= usage - CPPUNIT_ASSERT_EQUAL(gl1, gl1_c); - // Invalid read of size 8 - // at 0x342B157A: MEDMEM::MEDMEM_Array::operator==(MEDMEM::MEDMEM_Array const&) const (MEDMEM_nArray.hxx:255) - // by 0x342A1CDA: MEDMEM::GAUSS_LOCALIZATION::operator==(MEDMEM::GAUSS_LOCALIZATION const&) const (MEDMEM_GaussLocalization.hxx:175) - // by 0x34315F98: CppUnit::assertion_traits >::equal(MEDMEM::GAUSS_LOCALIZATION const&, MEDMEM::GAUSS_LOCALIZATION const&) (TestAssert.h:40) - // by 0x34314D35: void CppUnit::assertEquals >(MEDMEM::GAUSS_LOCALIZATION const&, MEDMEM::GAUSS_LOCALIZATION const&, CppUnit::SourceLine, std::string const&) (TestAssert.h:62) - // by 0x34311D6F: MEDMEMTest::testGaussLocalization() (MEDMEMTest_GaussLocalization.cxx:132) - // Address 0x35B5FC98 is 0 bytes inside a block of size 48 free'd - // at 0x3414CD61: operator delete[](void*) (vg_replace_malloc.c:161) - // by 0x341D88CA: MEDMEM::PointerOf::~PointerOf() (MEDMEM_PointerOf.hxx:141) - // by 0x341D56C7: MEDMEM::MEDMEM_Array::~MEDMEM_Array() (MEDMEM_nArray.hxx:52) - // by 0x34314F58: MEDMEM::GAUSS_LOCALIZATION::operator=(MEDMEM::GAUSS_LOCALIZATION const&) (MEDMEM_GaussLocalization.hxx:166) - // by 0x34311CCC: MEDMEMTest::testGaussLocalization() (MEDMEMTest_GaussLocalization.cxx:128) - //#endif - - // same name, type and nb.gauss, but different coords or weights - double cooRef_ch[6] = {1.,1., 2.,8., 3.,9.}; - double cooGauss_ch[10] = {7.,8., 6.,6., 5.,5., 4.,3., 2.,1.}; - double wg_ch[5] = {1., 2., 8., 4., 5.}; - - GAUSS_LOCALIZATION<> gl3 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef_ch, cooGauss, wg); - GAUSS_LOCALIZATION<> gl4 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef, cooGauss_ch, wg); - GAUSS_LOCALIZATION<> gl5 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef, cooGauss, wg_ch); - - CPPUNIT_ASSERT(!(gl1 == gl3)); - CPPUNIT_ASSERT(!(gl1 == gl4)); - CPPUNIT_ASSERT(!(gl1 == gl5)); - - // different name or type, or nb.gauss - double cooRef_quad[8] = {1.,1., 2.,4., 3.,9., 4., 16.}; - double cooGauss_4[8] = {7.,8., 6.,6., 5.,5., 4.,3.}; - double wg_4[4] = {1., 2., 8., 4.}; - - GAUSS_LOCALIZATION<> gl6 ("GL6", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef, cooGauss, wg); - GAUSS_LOCALIZATION<> gl7 ("GL1", MED_EN::MED_QUAD4, /*nGauss*/5, cooRef_quad, cooGauss, wg); - GAUSS_LOCALIZATION<> gl8 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/4, cooRef, cooGauss_4, wg_4); - - CPPUNIT_ASSERT(!(gl1 == gl6)); - CPPUNIT_ASSERT(!(gl1 == gl7)); - CPPUNIT_ASSERT(!(gl1 == gl8)); - - // Operator << - ostringstream ostr1; - ostr1 << gl1; - CPPUNIT_ASSERT(ostr1.str() != ""); - - ostringstream ostr2; - ostr2 << gl2; - CPPUNIT_ASSERT_EQUAL(ostr1.str(), ostr2.str()); - - // Construction from ArrayNoGauss and vector - GAUSS_LOCALIZATION<> gl9 ("GL1", MED_EN::MED_TRIA3, /*nGauss*/5, cooRefBack, cooGaussBack, wgBack); - CPPUNIT_ASSERT(gl1 == gl9); - - // NoInterlace - double cooRef_ni[6] = {1.,2.,3., 1.,4.,9.}; // xxx yyy - double cooGauss_ni[10] = {7.,6.,5.,4.,2., 7.,6.,5.,3.,1.}; // x1,x2,x3,x4,x5 y1,y2,y3,y4,y5 - - GAUSS_LOCALIZATION gl10 ("GL10", MED_EN::MED_TRIA3, /*nGauss*/5, cooRef_ni, cooGauss_ni, wg); - - GAUSS_LOCALIZATION::ArrayNoGauss cooRefBack_ni = gl10.getRefCoo(); - GAUSS_LOCALIZATION::ArrayNoGauss cooGaussBack_ni = gl10.getGsCoo(); - - for (int i = 1; i <= 3; i++) { // nb. nodes - for (int j = 1; j <= 2; j++) { // dim - CPPUNIT_ASSERT_DOUBLES_EQUAL(cooRefBack.getIJ(i, j), cooRefBack_ni.getIJ(i, j), 0.000001); - } - } - - for (int i = 1; i <= 5; i++) { // nGauss - for (int j = 1; j <= 2; j++) { // dim - CPPUNIT_ASSERT_DOUBLES_EQUAL(cooGaussBack.getIJ(i, j), cooGaussBack_ni.getIJ(i, j), 0.000001); - } - } -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_GetVolumeAbs.cxx b/src/MEDMEMCppTest/MEDMEMTest_GetVolumeAbs.cxx deleted file mode 100644 index afa1cb7b6..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_GetVolumeAbs.cxx +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_GibiMeshDriver.hxx" - -#include -#include - -using namespace std; -using namespace MEDMEM; - -void MEDMEMTest::testGetVolumeAbs() -{ - double coords[63]= - { - 0., 0., 0. - ,2., 0., 0. - ,2., 1., 0. - ,1., 2., 0. - ,0., 1., 0. - ,2., 2., 0. - , 0., 2., 0. - , 0., 0., 1. - , 2., 0., 1. - , 2., 1., 1. - , 1., 2., 1. - , 0., 1., 1. - , 2., 2., 1. - , 0., 2., 1. - , 0., 0., 2. - , 2., 0., 2. - , 2., 1., 2. - , 1., 2., 2. - , 0., 1., 2. - , 2., 2., 2. - , 0., 2., 2. - }; - int connNodalCellClassical[24]= - { - 10, 11, 13, 17, 18, 20, - 4, 5, 7, 11, 12, 14, - 11, 12, 14, 18, 19, 21, - 3, 4, 6, 10, 11, 13 - }; - int polyHedraConn[60+12]= - { - 8, 9, 10, 11, 12, -1, - 15, 16, 17, 18, 19, -1, - 8, 9, 16, 15, -1, - 9, 10, 17, 16, -1, - 10, 11, 18, 17, -1, - 11, 12, 19, 18, -1, - 12, 8, 15, 19, - //cell2 - 1, 2, 3, 4, 5, -1, - 8, 9, 10, 11, 12, -1, - 1, 2, 9, 8, -1, - 2, 3, 10, 9, -1, - 3, 4, 11, 10, -1, - 4, 5, 12, 11, -1, - 5, 1, 8, 12 - }; - int polyHedraInd[3]= - { - 1,37,73 - }; - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=21; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN", - MED_EN::MED_FULL_INTERLACE); - string coordname[3] = - { - "x", "y", "z" - }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info - const MED_EN::medGeometryElement classicalTypesCell[2]= - { - MED_EN::MED_PENTA6,MED_POLYHEDRA - }; - const int nbOfCellElts[2]= - { - 4,2 - }; - meshing->setNumberOfTypes(2,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_PENTA6,connNodalCellClassical); - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA, polyHedraConn,polyHedraInd); - // - const SUPPORT *sup=meshing->getSupportOnAll(MED_CELL); - FIELD *volumes=meshing->getVolume(sup); - const double *vals=volumes->getValue(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[1],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[2],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[3],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.,vals[4],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.,vals[5],1e-13); - volumes->removeReference(); - volumes=meshing->getVolume(sup,false); - vals=volumes->getValue(); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[0],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[1],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[2],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,vals[3],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,vals[4],1e-13); - CPPUNIT_ASSERT_DOUBLES_EQUAL(2.,vals[5],1e-13); - // - volumes->removeReference(); - meshing->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_GibiMeshDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_GibiMeshDriver.cxx deleted file mode 100644 index b55454fac..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_GibiMeshDriver.cxx +++ /dev/null @@ -1,493 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (31), defined in MEDMEM_GibiMeshDriver.hxx: - * class GIBI_MESH_DRIVER : public GENDRIVER { - * (+) GIBI_MESH_DRIVER(); - * (+) GIBI_MESH_DRIVER(const string & fileName, MESH * ptrMesh, MED_EN::med_mode_acces accessMode); - * (+) GIBI_MESH_DRIVER(const GIBI_MESH_DRIVER & driver); - * (+) virtual ~GIBI_MESH_DRIVER(); - * (+) virtual void write(void) const = 0; - * (+) virtual void read (void) = 0; - * (+) void setMeshName(const string & meshName); - * (+) string getMeshName() const; - * (+) static MED_EN::medGeometryElement gibi2medGeom(size_t gibiTypeNb); - * (+) static int med2gibiGeom(MED_EN::medGeometryElement medGeomType); - * } - * class GIBI_MESH_RDONLY_DRIVER : public virtual GIBI_MESH_DRIVER { - * (+) GIBI_MESH_RDONLY_DRIVER(); - * (+) GIBI_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver); - * (+) virtual ~GIBI_MESH_RDONLY_DRIVER(); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * (+) void open(); - * (+) void close(); - * } - * class GIBI_MESH_WRONLY_DRIVER : public virtual GIBI_MESH_DRIVER { - * (+) GIBI_MESH_WRONLY_DRIVER(); - * (+) GIBI_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver); - * (+) virtual ~GIBI_MESH_WRONLY_DRIVER(); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * (+) void open(); - * (+) void close(); - * } - * class GIBI_MESH_RDWR_DRIVER : public GIBI_MESH_RDONLY_DRIVER, public GIBI_MESH_WRONLY_DRIVER { - * (+) GIBI_MESH_RDWR_DRIVER(); - * (+) GIBI_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver); - * (+) ~GIBI_MESH_RDWR_DRIVER(); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * (+) void open(); - * (+) void close(); - * } - * class GIBI_MED_RDONLY_DRIVER : public GIBI_MESH_RDONLY_DRIVER { - * (+) GIBI_MED_RDONLY_DRIVER(); - * (+) GIBI_MED_RDONLY_DRIVER(const string & fileName, MED * ptrMed); - * (+) GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver); - * (+) virtual ~GIBI_MED_RDONLY_DRIVER(); - * (+) void read (void) throw (MEDEXCEPTION); - * } - * class GIBI_MED_WRONLY_DRIVER : public GIBI_MESH_WRONLY_DRIVER { - * (+) GIBI_MED_WRONLY_DRIVER(); - * (+) GIBI_MED_WRONLY_DRIVER(const string & fileName, MED * ptrMed, MESH * ptrMesh); - * (+) GIBI_MED_WRONLY_DRIVER(const GIBI_MED_WRONLY_DRIVER & driver); - * (+) virtual ~GIBI_MED_WRONLY_DRIVER(); - * (+) void write(void) const throw (MEDEXCEPTION); - * } - */ - -void MEDMEMTest::testGibiMeshDriver() -{ - MESH *aMesh = new MESH; - MESH *aMesh_NULL = NULL; - MESH *aMesh_2 = new MESH; - vector rdFields; - vector wrFields; - - string filename_rd = getResourceFile("Darcy3_3D_H_10x10x10.sauve"); - string filenamemed_rd = getResourceFile("test_2D.sauve"); - string filename_wr = makeTmpFile("myWr_Darcy3_3D_H_10x10x10.sauve"); - string tmpfile = makeTmpFile("tmp.sauve"); - string tmpfile_rdwr = makeTmpFile("rdwr_tmp.sauve"); - string filenamemed_wr = makeTmpFile("myWrMed_elle_3D_HPr_10x10x10.sauve"); - string tmpfilemed = makeTmpFile("tmpmed.sauve"); - string meshname = "Darcy3_3D_H_10x10x10"; - string newmeshname = "new" + meshname; - string fileNotExistsName_rd = "notExists.sauve"; - string fileNotExistsName_wr = "/path_not_exists/file_not_exists.sauve"; - string filename_rdwr = makeTmpFile("myRdWr_Darcy3_3D_H_10x10x10.sauve", filename_rd); - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - aRemover.Register(tmpfile); - aRemover.Register(tmpfilemed); - aRemover.Register(filenamemed_wr); - aRemover.Register(tmpfile_rdwr); - aRemover.Register(filename_rdwr); - - //Test gibi2medGeom() and med2gibiGeom() methods - size_t aSize = 17; - CPPUNIT_ASSERT_EQUAL(GIBI_MESH_DRIVER::gibi2medGeom(aSize), MED_PENTA15); - CPPUNIT_ASSERT_EQUAL(GIBI_MESH_DRIVER::med2gibiGeom(MED_PENTA15), 17); - - //---------------------------Test GIBI MESH READ ONLY part--------------------------------// - { - { - //Creation of an incorrect read only driver - GIBI_MESH_RDONLY_DRIVER *aInvalidGibiRdDriver = - new GIBI_MESH_RDONLY_DRIVER(fileNotExistsName_rd, aMesh); - /************************************************************************/ - // WARNING: if you have memory access error just after this constructor, - // this means that MEDMEMCppTest has been compiled w/o -DHAS_XDR - // while MEDMEM, with -DHAS_XDR - /************************************************************************/ - - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidGibiRdDriver->open(), MEDEXCEPTION); - - delete aInvalidGibiRdDriver; - } - - //Creation a correct Gibi read only driver (normal constructor) - GIBI_MESH_RDONLY_DRIVER *aGibiRdDriver = - new GIBI_MESH_RDONLY_DRIVER(filename_rd, aMesh); - - //Check driver - CPPUNIT_ASSERT(aGibiRdDriver); - - //Trying read mesh from file, if file is not open - CPPUNIT_ASSERT_THROW(aGibiRdDriver->read(), MEDEXCEPTION); - - //Test open() method - CPPUNIT_ASSERT_NO_THROW(aGibiRdDriver->open()); - - //Trying open file secondary. - CPPUNIT_ASSERT_NO_THROW(aGibiRdDriver->open()); - - //Test setMeshName() and getMeshName() methods - CPPUNIT_ASSERT_NO_THROW(aGibiRdDriver->setMeshName(meshname)); - CPPUNIT_ASSERT_EQUAL(meshname, aGibiRdDriver->getMeshName()); - - //Test read() method - CPPUNIT_ASSERT_NO_THROW(aGibiRdDriver->read()); - - //Trying fill not empty mesh - CPPUNIT_ASSERT_THROW(aGibiRdDriver->read(), MEDEXCEPTION); - - //Test write() method for GIBI READ ONLY driver - CPPUNIT_ASSERT_THROW(aGibiRdDriver->write(), MEDEXCEPTION); - - //Check Mesh - CPPUNIT_ASSERT(aMesh); - - //Test close method - CPPUNIT_ASSERT_NO_THROW(aGibiRdDriver->close()); - - //Default constructor - { - GIBI_MESH_RDONLY_DRIVER aGibiRdDriverCpy_1; - } - - //Test copy constructor and operator==(), defined in GENDRIVER class - { - GIBI_MESH_RDONLY_DRIVER aGibiRdDriverCpy_2 (*aGibiRdDriver); - CPPUNIT_ASSERT(aGibiRdDriverCpy_2.GENDRIVER::operator==(*aGibiRdDriver)); - - //Test (friend ostream & operator <<) defined GENDRIVER class - ostringstream rostr1, rostr2; - rostr1 << *aGibiRdDriver; - rostr2 << aGibiRdDriverCpy_2; - CPPUNIT_ASSERT(rostr1.str() != ""); - CPPUNIT_ASSERT(rostr1.str() == rostr2.str()); - } - - delete aGibiRdDriver; - } - - //-------------------------------Test GIBI WRITE ONLY part------------------------------// - { - { - //Creation a incorrect gibi write only driver - GIBI_MESH_WRONLY_DRIVER *aInvalidGibiWrDriver = - new GIBI_MESH_WRONLY_DRIVER(fileNotExistsName_wr, aMesh); - - //Trying open non existing file - CPPUNIT_ASSERT_THROW(aInvalidGibiWrDriver->open(), MEDEXCEPTION); - - delete aInvalidGibiWrDriver; - } - - //Trying write empty mesh - { - GIBI_MESH_WRONLY_DRIVER *aTmpGibiWrDriver = - new GIBI_MESH_WRONLY_DRIVER(tmpfile, aMesh_NULL); - aTmpGibiWrDriver->open(); - - CPPUNIT_ASSERT_THROW(aTmpGibiWrDriver->write(),MEDEXCEPTION); - aTmpGibiWrDriver->close(); - - delete aTmpGibiWrDriver; - } - - //Creation a correct gibi write only drivers - GIBI_MESH_WRONLY_DRIVER *aGibiWrDriver = - new GIBI_MESH_WRONLY_DRIVER(filename_wr, aMesh); - - //Check driver - CPPUNIT_ASSERT(aGibiWrDriver); - - //Trying write mesh to file, if file is not open - CPPUNIT_ASSERT_THROW(aGibiWrDriver->write(), MEDEXCEPTION); - - //Test open() method - CPPUNIT_ASSERT_NO_THROW(aGibiWrDriver->open()); - - CPPUNIT_ASSERT_NO_THROW(aGibiWrDriver->open()); - - //Test setMeshName() and getMeshName() methods - CPPUNIT_ASSERT_NO_THROW(aGibiWrDriver->setMeshName(newmeshname)); - CPPUNIT_ASSERT_EQUAL(newmeshname, aGibiWrDriver->getMeshName()); - - //Test write() method - CPPUNIT_ASSERT_NO_THROW(aGibiWrDriver->write()); - - //Test read() method for GIBI WRITE ONLY driver - CPPUNIT_ASSERT_THROW(aGibiWrDriver->read(), MEDEXCEPTION); - - //Test close method - CPPUNIT_ASSERT_NO_THROW(aGibiWrDriver->close()); - - //Default constructor - GIBI_MESH_WRONLY_DRIVER aGibiWrDriverCpy_1; - - //Test copy constructor - GIBI_MESH_WRONLY_DRIVER aGibiWrDriverCpy_2 (*aGibiWrDriver); - - //Test (bool operator ==) defined GENDRIVER class - CPPUNIT_ASSERT(aGibiWrDriverCpy_2.GENDRIVER::operator==(*aGibiWrDriver)); - - //Test (friend ostream & operator <<) defined GENDRIVER class - ostringstream wostr1, wostr2; - wostr1 << *aGibiWrDriver; - wostr2 << aGibiWrDriverCpy_2; - CPPUNIT_ASSERT(wostr1.str() != ""); - CPPUNIT_ASSERT(wostr1.str() == wostr2.str()); - - delete aGibiWrDriver; - } - - //-------------------------------Test GIBI READ/WRITE part---------------------------------// - { - { - //Creation a incorrect gibi read/write driver - GIBI_MESH_RDWR_DRIVER *aInvalidGibiRdWrDriver = - new GIBI_MESH_RDWR_DRIVER(fileNotExistsName_wr, aMesh_2); - - //Trying read/write from not existing file - CPPUNIT_ASSERT_THROW(aInvalidGibiRdWrDriver->read(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidGibiRdWrDriver->write(), MEDEXCEPTION); - - delete aInvalidGibiRdWrDriver; - } - - //Trying write empty mesh - { - GIBI_MESH_RDWR_DRIVER *aTmpGibiRdWrDriver = - new GIBI_MESH_RDWR_DRIVER(tmpfile_rdwr, aMesh_NULL); - CPPUNIT_ASSERT_THROW(aTmpGibiRdWrDriver->write(), MEDEXCEPTION); - delete aTmpGibiRdWrDriver; - } - - //Creation a correct read/write driver - GIBI_MESH_RDWR_DRIVER *aGibiRdWrDriver = - new GIBI_MESH_RDWR_DRIVER(filename_rdwr, aMesh_2); - - //Test open/close methods - CPPUNIT_ASSERT_NO_THROW(aGibiRdWrDriver->open()); - CPPUNIT_ASSERT_NO_THROW(aGibiRdWrDriver->close()); - - //Check driver - CPPUNIT_ASSERT(aGibiRdWrDriver); - - //Test read() method - CPPUNIT_ASSERT_NO_THROW(aGibiRdWrDriver->read()); - - //Check Mesh - CPPUNIT_ASSERT(aMesh); - - //Trying fill not empty mesh - CPPUNIT_ASSERT_THROW(aGibiRdWrDriver->read(),MEDEXCEPTION); - - //Test write() method - aGibiRdWrDriver->setMeshName(newmeshname); - CPPUNIT_ASSERT_NO_THROW(aGibiRdWrDriver->write()); - - //Default constructor - GIBI_MESH_RDWR_DRIVER aGibiRdWrDriverCpy_1; - - //Test copy constructor - GIBI_MESH_RDWR_DRIVER aGibiRdWrDriverCpy_2 (*aGibiRdWrDriver); - - //Test (bool operator ==) - CPPUNIT_ASSERT(aGibiRdWrDriverCpy_2.GENDRIVER::operator==(*aGibiRdWrDriver)); - - //Test (ostream & operator <<) - ostringstream rwostr1, rwostr2; - rwostr1 << *aGibiRdWrDriver; - rwostr2 << aGibiRdWrDriverCpy_2; - CPPUNIT_ASSERT(rwostr1.str() != ""); - CPPUNIT_ASSERT(rwostr1.str() == rwostr2.str()); - - delete aGibiRdWrDriver; - } - - //----------------------------Test GIBI_MED_RDONLY_DRIVER---------------------------- - { - { - GIBI_MED_RDONLY_DRIVER *aInvalidMedGibiRdDriver = - new GIBI_MED_RDONLY_DRIVER(fileNotExistsName_rd, rdFields); - - //Trying open not exising file - CPPUNIT_ASSERT_THROW(aInvalidMedGibiRdDriver->open(), MEDEXCEPTION); - - delete aInvalidMedGibiRdDriver; - } - - //Creation a correct Gibi read only driver (normal constructor) - GIBI_MED_RDONLY_DRIVER *aGibiMedRdDriver = - new GIBI_MED_RDONLY_DRIVER(filenamemed_rd, rdFields); - - //Check driver - CPPUNIT_ASSERT(aGibiMedRdDriver); - - //Trying read mesh from file, if file is not open - CPPUNIT_ASSERT_THROW(aGibiMedRdDriver->read(), MEDEXCEPTION); - - //Test open() method - CPPUNIT_ASSERT_NO_THROW(aGibiMedRdDriver->open()); - - //#ifdef ENABLE_FORCED_FAILURES - //Trying open file secondary. - //CPPUNIT_ASSERT_THROW(aGibiMedRdDriver->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aGibiMedRdDriver->open()); - //This case is not work, seems it BUG - //#endif - - //Test read() method - CPPUNIT_ASSERT_NO_THROW(aGibiMedRdDriver->read()); - - //Test write() method for GIBI MED READ ONLY driver - CPPUNIT_ASSERT_THROW(aGibiMedRdDriver->write(), MEDEXCEPTION); - - //Check Med - CPPUNIT_ASSERT_EQUAL(1,int(rdFields.size())); - - //Test close method - CPPUNIT_ASSERT_NO_THROW(aGibiMedRdDriver->close()); - - //Default constructor - GIBI_MED_RDONLY_DRIVER aGibiMedRdDriverCpy_1; - - //Test (bool operator ==) defined in GENDRIVER class - CPPUNIT_ASSERT(! aGibiMedRdDriverCpy_1.GENDRIVER::operator==(*aGibiMedRdDriver)); - - //Test copy constructor - // commented since this test is not important - //GIBI_MED_RDONLY_DRIVER aGibiMedRdDriverCpy_2 (*aGibiMedRdDriver); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Copy constructor of GIBI_MED_RDONLY_DRIVER is not implemented - // Small importance - //CPPUNIT_ASSERT(aGibiMedRdDriverCpy_2.GENDRIVER::operator==(*aGibiMedRdDriver)); - //#endif - - //Test (friend ostream & operator <<) defined in GENDRIVER class - // commented since this test is not important - //ostringstream medrostr1, medrostr2; - //medrostr1 << *aGibiMedRdDriver; - //medrostr2 << aGibiMedRdDriverCpy_2; - //CPPUNIT_ASSERT(medrostr1.str() != ""); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Copy constructor of GIBI_MED_RDONLY_DRIVER is not implemented - //CPPUNIT_ASSERT(medrostr1.str() == medrostr2.str()); - //#endif - - rdFields[0]->removeReference(); - - delete aGibiMedRdDriver; - } - - //----------------------------Test GIBI MED WRITE ONLY part----------------------------------// - { - { - //Creation a incorrect gibi med write only driver - GIBI_MED_WRONLY_DRIVER *aInvalidGibiMedWrDriver = - new GIBI_MED_WRONLY_DRIVER(fileNotExistsName_wr, wrFields, aMesh); - - //Trying open non existing file - CPPUNIT_ASSERT_THROW(aInvalidGibiMedWrDriver->open(), MEDEXCEPTION); - - delete aInvalidGibiMedWrDriver; - } - - //Trying create gibi med write only driver with null MESH - CPPUNIT_ASSERT_THROW(new GIBI_MED_WRONLY_DRIVER(tmpfilemed, wrFields, aMesh_NULL), MEDEXCEPTION); - - //Creation a correct gibi med write only drivers - GIBI_MED_WRONLY_DRIVER *aGibiMedWrDriver = - new GIBI_MED_WRONLY_DRIVER(filenamemed_wr, wrFields, aMesh); - - //Check driver - CPPUNIT_ASSERT(aGibiMedWrDriver); - - //Trying write mesh to file, if file is not open - CPPUNIT_ASSERT_THROW(aGibiMedWrDriver->write(), MEDEXCEPTION); - - //Test open() method - CPPUNIT_ASSERT_NO_THROW(aGibiMedWrDriver->open()); - - //Trying open file secondary. - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Exception is generated, but second call to open() function breaks driver - //CPPUNIT_ASSERT_THROW(aGibiMedWrDriver->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aGibiMedWrDriver->open()); - //#endif - - //Test write() method - CPPUNIT_ASSERT_NO_THROW(aGibiMedWrDriver->write()); - - //Test read() method for GIBI MED WRITE ONLY driver - CPPUNIT_ASSERT_THROW(aGibiMedWrDriver->read(), MEDEXCEPTION); - - //Test close method - CPPUNIT_ASSERT_NO_THROW(aGibiMedWrDriver->close()); - - //Default constructor - GIBI_MED_WRONLY_DRIVER aGibiMedWrDriverCpy_1; - - //Test copy constructor - { - GIBI_MED_WRONLY_DRIVER aGibiMedWrDriverCpy_2 (*aGibiMedWrDriver); - - //Test (bool operator ==) defined in GENDRIVER class - // commented since this test is not important - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Copy constructor of GIBI_MED_WRONLY_DRIVER is not implemented!!! - //CPPUNIT_ASSERT(aGibiMedWrDriverCpy_2.GENDRIVER::operator==(*aGibiMedWrDriver)); - //#endif - - //Test (friend ostream & operator <<) defined GENDRIVER class - // commented since this test is not important - //ostringstream medwostr1, medwostr2; - //medwostr1 << *aGibiMedWrDriver; - //medwostr2 << aGibiMedWrDriverCpy_2; - //CPPUNIT_ASSERT(medwostr1.str() != ""); - //#ifdef ENABLE_FORCED_FAILURES - // Copy constructor of GIBI_MED_WRONLY_DRIVER is not implemented!!! - //CPPUNIT_ASSERT(medwostr1.str() == medwostr2.str()); - //#endif - } - - delete aGibiMedWrDriver; - } - //Delete all objects - aMesh->removeReference(); - aMesh_2->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Grid.cxx b/src/MEDMEMCppTest/MEDMEMTest_Grid.cxx deleted file mode 100644 index e63cf818c..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Grid.cxx +++ /dev/null @@ -1,623 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - - -/*! - * Check methods (23), defined in MEDMEM_Grid.hxx: - * class GRID: public MESH { - * (+) GRID(); - * (+) GRID(const MED_EN::med_grid_type type); - * (BUG:operator=() not implemented but init() not called) GRID(const GRID &m); - * (+) GRID(driverTypes driverType, const string & fileName="",const string & meshName=""); - * (+) GRID(const std::vector >& xyz_array, - * const std::vector& coord_name, - * const std::vector& coord_unit, - * const MED_EN::med_grid_type type=MED_EN::MED_CARTESIAN); - * (NOT IMPLEMENTED) GRID & operator=(const GRID &m); - * (+) virtual ~GRID(); - * (+) virtual void init(); - * (+) virtual const MESH * convertInMESH() const - * (+) inline int getNodeNumber(const int i, const int j=0, const int k=0) const; - * (+) inline int getCellNumber(const int i, const int j=0, const int k=0) const; - * (+) int getEdgeNumber - * (const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION); - * (+) int getFaceNumber - * (const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION); - * (+) void getNodePosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) void getCellPosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) void getEdgePosition - * (const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) void getFacePosition - * (const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) inline MED_EN::med_grid_type getGridType() const; - * (+) int getArrayLength(const int Axis) const throw (MEDEXCEPTION); - * (+) const double getArrayValue (const int Axis, const int i) const throw (MEDEXCEPTION); - * (+) inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const; - * (+) inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const; - * (+) inline int getNumberOfElements - * (MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const; - * (+) inline MED_EN::medGeometryElement getElementType - * (MED_EN::medEntityMesh Entity, int Number) const; - * (+) inline void setGridType(MED_EN::med_grid_type gridType); - * } - */ -void MEDMEMTest::testGrid() -{ - string filename = getResourceFile("test19.med") ; - string filenameout21 = makeTmpFile("myGridWrite_grid21.med"); - ostringstream out; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filenameout21); - - // Remove file in advance to ensure it does not exist at the moment of writing, - // because files are not removed by the MEDMEMTest_TmpFilesRemover in case of - // Segmentation Fault (in previous tests execution). - { - MEDMEMTest_TmpFilesRemover aRemover1; - aRemover1.Register(filenameout21); - } - - MEDFILEBROWSER * myMed = new MEDFILEBROWSER(filename); - - int nbMeshes = myMed->getNumberOfMeshes(); - CPPUNIT_ASSERT(nbMeshes); - - vector mesh_names = myMed->getMeshNames(); - CPPUNIT_ASSERT(mesh_names.size() != 0); - - ////////////////////////////// - // test1 "CARTESIAN GRID" // - ////////////////////////////// - { - CPPUNIT_ASSERT(myMed->isStructuredMesh(mesh_names[0])); - - CPPUNIT_ASSERT_THROW( MESH(MED_DRIVER, myMed->getFileName(), mesh_names[0]), MEDEXCEPTION); - - GMESH* myMesh = new GRID(MED_DRIVER, myMed->getFileName(), mesh_names[0]); - std::auto_ptr meshDeleter(myMesh); - - CPPUNIT_ASSERT(myMesh != NULL); - CPPUNIT_ASSERT(myMesh->getIsAGrid()); - - GRID* myGrid = dynamic_cast(myMesh); - CPPUNIT_ASSERT(myGrid); - - CPPUNIT_ASSERT_THROW(myGrid->getArrayLength(0), MEDEXCEPTION); - - int I, J, K; - CPPUNIT_ASSERT_NO_THROW(I = myGrid->getArrayLength(1)); - CPPUNIT_ASSERT_NO_THROW(J = myGrid->getArrayLength(2)); - CPPUNIT_ASSERT_NO_THROW(K = myGrid->getArrayLength(3)); - - CPPUNIT_ASSERT(I); - CPPUNIT_ASSERT(J); - - med_grid_type grid_type = myGrid->getGridType(); - CPPUNIT_ASSERT_MESSAGE("Wrong grid type", grid_type == MED_CARTESIAN); - - const MESH* mesh = myGrid->convertInMESH(); - const double * coordinates = mesh->getCoordinates(MED_FULL_INTERLACE); - int SpaceDimension = myGrid->getSpaceDimension(); - for (int axe = 0; axe < SpaceDimension; axe++) { - for (int num = 0; num < myGrid->getNumberOfNodes(); num++) { - double coordinate; - CPPUNIT_ASSERT_NO_THROW(coordinate = mesh->getCoordinate(num + 1, axe + 1)); - //cout << "coordinate = " << coordinate << endl; - CPPUNIT_ASSERT(fabs(coordinate - coordinates[(num * SpaceDimension)+axe]) < 0.001); - } - } - - int nbTypesCell = myGrid->getNumberOfTypes(MED_CELL); - CPPUNIT_ASSERT(nbTypesCell == 1); - - const medGeometryElement* types; - CPPUNIT_ASSERT_NO_THROW(types = myGrid->getTypes(MED_CELL)); - CPPUNIT_ASSERT(types[0] == MED_QUAD4); - - int nbElem = 0; - CPPUNIT_ASSERT_NO_THROW(nbElem = myGrid->getNumberOfElements(MED_CELL,types[0])); - CPPUNIT_ASSERT(nbElem); - - int nbNodes = myGrid->getNumberOfNodes(); - CPPUNIT_ASSERT(nbNodes); - - int ijkNode[3]; - int NodeNumber; - for (int nbNode = 1; nbNode <= nbNodes; nbNode++) { - CPPUNIT_ASSERT_NO_THROW(myGrid->getNodePosition(nbNode, ijkNode[0], ijkNode[1], ijkNode[2])); - CPPUNIT_ASSERT_NO_THROW(NodeNumber = myGrid->getNodeNumber(ijkNode[0], ijkNode[1], ijkNode[2])); - CPPUNIT_ASSERT(NodeNumber == nbNode); - } - - int nbCells = myGrid->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT(nbCells); - - int ijkCell[3]; - int CellNumber; - for (int nbCell = 1; nbCell <= nbCells; nbCell++) { - CPPUNIT_ASSERT_NO_THROW(myGrid->getCellPosition(nbCell, ijkCell[0], ijkCell[1], ijkCell[2])); - CPPUNIT_ASSERT_NO_THROW(CellNumber = myGrid->getCellNumber(ijkCell[0], ijkCell[1], ijkCell[2])); - CPPUNIT_ASSERT(CellNumber == nbCell); - } - - int nbEdges = myGrid->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT(nbEdges); - - int ijkAxisEdge[4]; - int EdgeNumber; - for (int nbEdge = 1; nbEdge <= nbEdges; nbEdge++) { - CPPUNIT_ASSERT_NO_THROW(myGrid->getEdgePosition(nbEdge, ijkAxisEdge[0], ijkAxisEdge[1], - ijkAxisEdge[2], ijkAxisEdge[3])); - CPPUNIT_ASSERT_NO_THROW(EdgeNumber = myGrid->getEdgeNumber(ijkAxisEdge[0], ijkAxisEdge[1], - ijkAxisEdge[2], ijkAxisEdge[3])); - CPPUNIT_ASSERT(EdgeNumber == nbEdge); - } - - int nbFaces = myGrid->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT(nbFaces == 0); - - //#ifdef ENABLE_FORCED_FAILURES - // To remove getFacePosition() from API - //CPPUNIT_FAIL("ERROR: nbFaces == 0, but getFacePosition(AnyNumber, ...) - return position(i,j,k)"); - //#endif - int ijkAxisFace[4]; - CPPUNIT_ASSERT_NO_THROW(myGrid->getFacePosition(6, ijkAxisFace[0], ijkAxisFace[1], - ijkAxisFace[2], ijkAxisFace[3])); - CPPUNIT_ASSERT(ijkAxisFace[0]); - CPPUNIT_ASSERT(ijkAxisFace[1]); - CPPUNIT_ASSERT(ijkAxisFace[2]); - - /*int FaceNumber; - for(int nbFace = 1; nbFace <= nbFaces; nbFace++) - { - CPPUNIT_ASSERT_NO_THROW( myGrid->getFacePosition(nbFace, ijkAxisFace[0], ijkAxisFace[1], - ijkAxisFace[2], ijkAxisFace[3])); - CPPUNIT_ASSERT_NO_THROW( EdgeNumber = myGrid->getEdgeNumber(ijkAxisFace[0], ijkAxisFace[1], - ijkAxisFace[2], ijkAxisFace[3])); - CPPUNIT_ASSERT(FaceNumber == nbFace); - }*/ - - bool existConnect = false; - CPPUNIT_ASSERT_NO_THROW(existConnect = mesh->existConnectivity(MED_NODAL, MED_CELL)); - if (!existConnect) { - CPPUNIT_ASSERT_NO_THROW(mesh->calculateConnectivity(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(mesh->existConnectivity(MED_NODAL, MED_CELL)); - } - - const int* Connectivity; - const int* connectivity_index; - CPPUNIT_ASSERT_NO_THROW(Connectivity = mesh->getConnectivity( MED_NODAL, MED_CELL, types[0])); - CPPUNIT_ASSERT_NO_THROW(connectivity_index = mesh->getConnectivityIndex(MED_NODAL, MED_CELL)); - out << "Nodal connectivity" << endl; - for (int j = 0; j < nbElem; j++) { - out << "Element "<< j+1 << " : "; - for (int k = connectivity_index[j]; k < connectivity_index[j+1]; k++) - out << Connectivity[k-1] << " "; - out << endl; - } - - const int * ReverseNodalConnectivity; - const int * ReverseConnectivityIndex; - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivity = mesh->getReverseConnectivity(MED_NODAL)); - CPPUNIT_ASSERT_NO_THROW(ReverseConnectivityIndex = mesh->getReverseConnectivityIndex(MED_NODAL)); - for (int i = 0; i < nbNodes; i++) { - out << "Node "<< i+1 << " : "; - for (int j = ReverseConnectivityIndex[i]; j < ReverseConnectivityIndex[i+1]; j++) - out << ReverseNodalConnectivity[j-1] << " "; - out << endl; - } - - const int* myGlobalNbIdx; - CPPUNIT_ASSERT_NO_THROW(myGlobalNbIdx = mesh->getGlobalNumberingIndex(MED_CELL)); - for (int i = 0; i <= nbTypesCell; i++) { - if (i == nbTypesCell) { - CPPUNIT_ASSERT_THROW(myGrid->getElementType(MED_CELL, myGlobalNbIdx[i]), MEDEXCEPTION); - break; - } - medGeometryElement aElem; - CPPUNIT_ASSERT_NO_THROW(aElem = myGrid->getElementType(MED_CELL, myGlobalNbIdx[i])); - CPPUNIT_ASSERT(types[0] == aElem); - } - - CPPUNIT_ASSERT_NO_THROW(existConnect = mesh->existConnectivity(MED_DESCENDING, MED_CELL)); - if (!existConnect) { - CPPUNIT_ASSERT_NO_THROW(mesh->calculateConnectivity( MED_DESCENDING, MED_CELL)); - CPPUNIT_ASSERT(mesh->existConnectivity(MED_DESCENDING, MED_CELL)); - } - - const int* ConnectivityDes; - const int* connectivity_index_des; - CPPUNIT_ASSERT_NO_THROW(ConnectivityDes = mesh->getConnectivity(MED_DESCENDING, - MED_CELL, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_NO_THROW(connectivity_index_des = - mesh->getConnectivityIndex(MED_DESCENDING, MED_CELL)); - out<<"Descending connectivity"<getReverseConnectivity(MED_DESCENDING)); - CPPUNIT_ASSERT_NO_THROW(ReverseConnectivityIndexDes = - mesh->getReverseConnectivityIndex(MED_DESCENDING)); - for (int i = 0; i < nbNodes; i++) { - out << "Node "<< i+1 << " : "; - for (int j = ReverseConnectivityIndexDes[i]; j < ReverseConnectivityIndexDes[i+1]; j++) - out << ReverseDesConnectivity[j-1] << " "; - out << endl; - } - mesh->removeReference(); - - } - - ////////////////////////////// - // test2 "MED_BODY_FITTED" // - ////////////////////////////// - { - CPPUNIT_ASSERT_THROW( MESH(MED_DRIVER, myMed->getFileName(), mesh_names[1]), MEDEXCEPTION); - - GMESH* myMesh1 = new GRID(MED_DRIVER,myMed->getFileName(),mesh_names[1]); - std::auto_ptr meshDeleter(myMesh1); - - CPPUNIT_ASSERT(myMesh1 != NULL); - CPPUNIT_ASSERT(myMesh1->getIsAGrid()); - - GRID* myGrid1 = dynamic_cast(myMesh1); - CPPUNIT_ASSERT(myGrid1); - - int I, J, K; - CPPUNIT_ASSERT_NO_THROW(I = myGrid1->getArrayLength(1)); - CPPUNIT_ASSERT_NO_THROW(J = myGrid1->getArrayLength(2)); - CPPUNIT_ASSERT_NO_THROW(K = myGrid1->getArrayLength(3)); - - CPPUNIT_ASSERT(I == 2); - CPPUNIT_ASSERT(J == 2); - - med_grid_type grid_type = myGrid1->getGridType(); - CPPUNIT_ASSERT_MESSAGE("Wrong grid type", grid_type == MED_BODY_FITTED); - - int nbTypesCell = myGrid1->getNumberOfTypes(MED_CELL); - CPPUNIT_ASSERT(nbTypesCell == 1); - - const medGeometryElement* types1; - CPPUNIT_ASSERT_NO_THROW( types1 = myGrid1->getTypes(MED_CELL) ); - CPPUNIT_ASSERT( types1[0] == MED_QUAD4); - - int nbElem; - CPPUNIT_ASSERT_NO_THROW(nbElem = myGrid1->getNumberOfElements(MED_CELL, types1[0])); - CPPUNIT_ASSERT(nbElem); - - const int* BodyConnectivity; - const int* body_connectivity_index; - int ijkNodeBody[3]; - const MESH* mesh = myGrid1->convertInMESH(); - CPPUNIT_ASSERT_NO_THROW(BodyConnectivity = mesh->getConnectivity( MED_NODAL, MED_CELL, types1[0])); - CPPUNIT_ASSERT_NO_THROW(body_connectivity_index = mesh->getConnectivityIndex(MED_NODAL, MED_CELL)); - out<<"Nodal connectivity"<getNodePosition(BodyConnectivity[k-1], ijkNodeBody[0], - ijkNodeBody[1], ijkNodeBody[2])); - out << BodyConnectivity[k-1] << " "; - } - out << endl; - } - mesh->removeReference(); - } - - /////////////////////////////////////////////////// - // test3 "maa1" which in fact is not a pure GRID // - /////////////////////////////////////////////////// - { - GMESH* myMesh2 = NULL; - - CPPUNIT_ASSERT_THROW( myMesh2 = new GRID( MED_DRIVER,myMed->getFileName(),mesh_names[2]), - MEDEXCEPTION ); - CPPUNIT_ASSERT_NO_THROW( myMesh2 = new MESH( MED_DRIVER,myMed->getFileName(),mesh_names[2])); - - CPPUNIT_ASSERT(myMesh2 != NULL); - CPPUNIT_ASSERT(!(myMesh2->getIsAGrid())); - myMesh2->removeReference(); - } - - delete myMed; - - //////////////////////////// - // test4 create new GRID // - //////////////////////////// - - // Default constructor and destructor - { - GRID* myGrid2 = new GRID(); - CPPUNIT_ASSERT(myGrid2->getIsAGrid()); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_CARTESIAN); - CPPUNIT_ASSERT(!myGrid2->getArrayLength(1)); - CPPUNIT_ASSERT(!myGrid2->getArrayLength(2)); - CPPUNIT_ASSERT(!myGrid2->getArrayLength(3)); - myGrid2->removeReference(); - } - - // Constructor with grid type, setGridType() - { - GRID* myGrid2 = new GRID(MED_POLAR); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_POLAR); - myGrid2->setGridType(MED_CARTESIAN); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_CARTESIAN); - myGrid2->removeReference(); - } - - // Constructor with coordinate values, getArrayValue(), init() - { - vector > xyz; - const int nbCoords = 3; - xyz.resize(nbCoords); - for ( int i = 0; i < nbCoords; i++ ) - { - xyz[i].resize(i + 2); - for ( int j = 0; j < i + 2; j++ ) - xyz[i][j] = j; - } - vector Coord_Names; - Coord_Names.resize(nbCoords); - Coord_Names[0] = "X"; - Coord_Names[1] = "Y"; - Coord_Names[2] = "Z"; - - vector Coord_Units; - Coord_Units.resize(nbCoords); - for(int i = 0; i < 3; i++) - Coord_Units[i] = "cm"; - - GRID* myGrid2; - - try{ - myGrid2 = new GRID(xyz, Coord_Names, Coord_Units, MED_CARTESIAN); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // testing convertInMESH() - // We fill a map of all possible coordinate triples. - // After iteration through all coordinates, this map should contain only "true" as data. - // "true" in some map element during iteration means duplicated node position. - // "false" in some map element after iteration means empty node position. - map found; - for ( unsigned i1 = 0; i1 < xyz[0].size(); i1++ ) - for ( unsigned i2 = 0; i2 < xyz[1].size(); i2++ ) - for ( unsigned i3 = 0; i3 < xyz[2].size(); i3++ ) - found[int(xyz[0][i1] * 100 + xyz[1][i2] * 10 + xyz[2][i3])] = false; - - const MESH* mesh = myGrid2->convertInMESH(); - COORDINATE* coords = (COORDINATE*)mesh->getCoordinateptr(); - CPPUNIT_ASSERT(coords); - for (int num = 0; num < myGrid2->getNumberOfNodes(); num++) { - int x = int(coords->getCoordinate(num + 1, 1)); - int y = int(coords->getCoordinate(num + 1, 2)); - int z = int(coords->getCoordinate(num + 1, 3)); - CPPUNIT_ASSERT(!found[x * 100 + y * 10 + z]); - found[x * 100 + y * 10 + z] = true; - } - - for ( map::iterator it = found.begin(); it != found.end(); it++ ) - CPPUNIT_ASSERT((*it).second); - - // Testing fillConnectivity() and getConnectivityptr() - // Basic testing: presence of connectivity arrays, element types and number of elements - CONNECTIVITY* conn = (CONNECTIVITY*)mesh->getConnectivityptr(); - CPPUNIT_ASSERT(conn); - bool hasFaces = myGrid2->getArrayLength(3), hasEdges = myGrid2->getArrayLength(2); - medGeometryElement aCellGeometry; - if (hasFaces) aCellGeometry = MED_HEXA8; - else if (hasEdges) aCellGeometry = MED_QUAD4; - else aCellGeometry = MED_SEG2; - CPPUNIT_ASSERT(conn->getElementType(MED_CELL, 1) == aCellGeometry); - CPPUNIT_ASSERT(conn->existConnectivity(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(conn->existConnectivity(MED_DESCENDING, MED_CELL)); - //test getCellsTypes - CELLMODEL* cellmodel = (CELLMODEL*)mesh->getCellsTypes(MED_CELL); - CPPUNIT_ASSERT(cellmodel); - - int nbCells, nbFaces, nbEdges; - - int iLen = myGrid2->getArrayLength(1); - int jLen = myGrid2->getArrayLength(2); - int kLen = myGrid2->getArrayLength(3); - int iLenMin1 = myGrid2->getArrayLength(1)-1; - int jLenMin1 = myGrid2->getArrayLength(2)-1; - int kLenMin1 = myGrid2->getArrayLength(3)-1; - const int* aCellCount = conn->getGlobalNumberingIndex(MED_CELL); - nbCells = iLenMin1 * jLenMin1 * kLenMin1; - CPPUNIT_ASSERT(aCellCount[1] - 1 == nbCells); - - if (hasFaces){ - CPPUNIT_ASSERT(conn->getElementType(MED_FACE, 1) == MED_QUAD4); - nbFaces = iLen * jLenMin1 * kLenMin1; - nbFaces += jLen * kLenMin1 * iLenMin1; - nbFaces += kLen * iLenMin1 * jLenMin1; - const int* aFaceCount = conn->getGlobalNumberingIndex(MED_FACE); - CPPUNIT_ASSERT(aFaceCount[1] - 1 == nbFaces); - CPPUNIT_ASSERT(conn->existConnectivity(MED_NODAL, MED_FACE)); - //test getCellsTypes - CELLMODEL* cellmodelF = (CELLMODEL*)mesh->getCellsTypes(MED_FACE); - CPPUNIT_ASSERT(cellmodelF); - } - if (hasEdges){ - CPPUNIT_ASSERT(conn->getElementType(MED_EDGE, 1) == MED_SEG2); - if (kLen) { // 3d grid - nbEdges = iLenMin1 * jLen * kLen; - nbEdges += jLenMin1 * kLen * iLen; - nbEdges += kLenMin1 * iLen * jLen; - } - else if (jLen) { // 2d - nbEdges = iLenMin1 * jLen; - nbEdges += jLenMin1 * iLen; - } - const int* anEdgeCount = conn->getGlobalNumberingIndex(MED_EDGE); - CPPUNIT_ASSERT(anEdgeCount[1] - 1 == nbEdges); - CPPUNIT_ASSERT(conn->existConnectivity(MED_NODAL, MED_EDGE)); - //test getCellsTypes - CELLMODEL* cellmodelE = (CELLMODEL*)mesh->getCellsTypes(MED_EDGE); - CPPUNIT_ASSERT(cellmodelE); - - } - - // Testing getArrayValue() - for ( int ii = 1; ii <= nbCoords; ii++ ) - for ( int jj = 0; jj < ii + 1; jj++ ) - CPPUNIT_ASSERT(myGrid2->getArrayValue(ii, jj) == xyz[ii - 1][jj]); - - CPPUNIT_ASSERT_THROW(myGrid2->getArrayValue(nbCoords + 1, 0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(myGrid2->getArrayValue(1, myGrid2->getArrayLength(1) + 1), MEDEXCEPTION); - myGrid2->setGridType(MED_POLAR); - - //testing read/write functions - - // add new driver - int idGridV21; - - try - { - idGridV21 = const_cast(mesh)->addDriver(MED_DRIVER,filenameout21); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // write this driver to file as an unstructured mesh - CPPUNIT_ASSERT_NO_THROW(mesh->write(idGridV21)); - - GRID* myGrid3 = new GRID(); - // add new driver for myGrid3 - int driver; - CPPUNIT_ASSERT_NO_THROW(driver = myGrid3->addDriver(MED_DRIVER, filenameout21)); - - //#ifdef ENABLE_FORCED_FAILURES - // ? (BUG) ? "The mesh dimension |-1| seems to be incorrect for - // the mesh : |Default Mesh Name|" - // TO CHECK writing CAREFULLY - // !!!!!!!!! Mesh was written as UNSTRUCTURED - // changed on THROW accoding to EAP - CPPUNIT_ASSERT_THROW(myGrid3->read(driver),MEDEXCEPTION); - //CPPUNIT_ASSERT_NO_THROW(myGrid3->read(driver)); - - // Testing getArrayValue() - //for ( int ii = 1; ii <= nbCoords; ii++ ) - // for ( int jj = 0; jj < ii + 1; jj++ ) - // CPPUNIT_ASSERT(myGrid3->getArrayValue(ii, jj) == xyz[ii - 1][jj]); - - //CPPUNIT_ASSERT(myGrid3->getGridType() == MED_POLAR); - //#endif - - myGrid3->removeReference(); - - //test init() - CPPUNIT_ASSERT_NO_THROW(myGrid2->init()); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_CARTESIAN); - CPPUNIT_ASSERT(myGrid2->getArrayLength(1) == 0); - CPPUNIT_ASSERT(myGrid2->getArrayLength(2) == 0); - CPPUNIT_ASSERT(myGrid2->getArrayLength(3) == 0); - //#ifdef ENABLE_FAULTS - // (BUG) Segmentation Fault - //myGrid2->makeUnstructured(); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // TODO: fix it - unstructured mesh should be simply empty, actually useless - //CPPUNIT_FAIL("ERROR:makeUnstructured() - there is no check if grid is empty or not"); - //#endif - - myGrid2->removeReference(); - mesh->removeReference(); - } - - { - GRID* myGrid2; - CPPUNIT_ASSERT_NO_THROW(myGrid2 = new GRID(MED_DRIVER, filename, mesh_names[1])); - - // Check if something has been read - full mesh data testing is above - CPPUNIT_ASSERT(myGrid2->getSpaceDimension()); - CPPUNIT_ASSERT(myGrid2->getNumberOfNodes()); - CPPUNIT_ASSERT(myGrid2->getNumberOfTypes(MED_CELL) == 1); - const medGeometryElement* types2; - CPPUNIT_ASSERT_NO_THROW(types2 = myGrid2->getTypes(MED_CELL)); - int nbElem; - CPPUNIT_ASSERT_NO_THROW(nbElem = myGrid2->getNumberOfElements(MED_CELL,types2[0])); - CPPUNIT_ASSERT(nbElem); - myGrid2->removeReference(); - } - - { - GRID* myGrid4 = new GRID(); - filename = getResourceFile("pointe.med"); - myGrid4->setName("maa1"); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename, myGrid4); - myMeshDriver.setMeshName("maa1"); - - // add new driver for myGrid4 - int driver; - CPPUNIT_ASSERT_NO_THROW(driver = myGrid4->addDriver(myMeshDriver)); - - // MED Exception : MED_MESH_RDONLY_DRIVER21::getGRID() : The number - // of nodes |-1| seems to be incorrect for the mesh : |maa1| - // But this exception seems to be correct reaction on attempt - // to read a grid from a file, which does not contain it. - CPPUNIT_ASSERT_THROW(myGrid4->read(driver), MEDEXCEPTION); - - myGrid4->removeReference(); - } -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Grid_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_Grid_fault.cxx deleted file mode 100644 index 590c44997..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Grid_fault.cxx +++ /dev/null @@ -1,651 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - - -/*! - * Check methods (23), defined in MEDMEM_Grid.hxx: - * class GRID: public MESH { - * (+) GRID(); - * (+) GRID(const MED_EN::med_grid_type type); - * (BUG:operator=() not implemented but init() not called) GRID(const GRID &m); - * (+) GRID(driverTypes driverType, const string & fileName="",const string & meshName=""); - * (+) GRID(const std::vector >& xyz_array, - * const std::vector& coord_name, - * const std::vector& coord_unit, - * const MED_EN::med_grid_type type=MED_EN::MED_CARTESIAN); - * (NOT IMPLEMENTED) GRID & operator=(const GRID &m); - * (+) virtual ~GRID(); - * (+) virtual void init(); - * (+) virtual const MESH * convertInMESH() const - * (+) inline int getNodeNumber(const int i, const int j=0, const int k=0) const; - * (+) inline int getCellNumber(const int i, const int j=0, const int k=0) const; - * (+) int getEdgeNumber - * (const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION); - * (+) int getFaceNumber - * (const int Axis, const int i, const int j=0, const int k=0) const throw (MEDEXCEPTION); - * (+) void getNodePosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) void getCellPosition(const int Number, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) void getEdgePosition - * (const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) void getFacePosition - * (const int Number, int& Axis, int& i, int& j, int& k) const throw (MEDEXCEPTION); - * (+) inline MED_EN::med_grid_type getGridType() const; - * (+) int getArrayLength(const int Axis) const throw (MEDEXCEPTION); - * (+) const double getArrayValue (const int Axis, const int i) const throw (MEDEXCEPTION); - * (+) inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const; - * (+) inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const; - * (+) inline int getNumberOfElements - * (MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type) const; - * (+) inline MED_EN::medGeometryElement getElementType - * (MED_EN::medEntityMesh Entity, int Number) const; - * (+) inline void setGridType(MED_EN::med_grid_type gridType); - * } - */ -static void MEDMEMTest_testGrid() -{ - string filename = getResourceFile("test19.med") ; - string filenameout21 = makeTmpFile("myGridWrite_grid21.med"); - ostringstream out; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filenameout21); - - // Remove file in advance to ensure it does not exist at the moment of writing, - // because files are not removed by the MEDMEMTest_TmpFilesRemover in case of - // Segmentation Fault (in previous tests execution). - { - MEDMEMTest_TmpFilesRemover aRemover1; - aRemover1.Register(filenameout21); - } - - MEDFILEBROWSER * myMed = new MEDFILEBROWSER(filename); - - int nbMeshes = myMed->getNumberOfMeshes(); - CPPUNIT_ASSERT(nbMeshes); - - vector mesh_names = myMed->getMeshNames(); - CPPUNIT_ASSERT(mesh_names.size() != 0); - - ////////////////////////////// - // test1 "CARTESIAN GRID" // - ////////////////////////////// - { - CPPUNIT_ASSERT(myMed->isStructuredMesh(mesh_names[0])); - - CPPUNIT_ASSERT_THROW( MESH(MED_DRIVER, myMed->getFileName(), mesh_names[0]), MEDEXCEPTION); - - GMESH* myMesh = new GRID(MED_DRIVER, myMed->getFileName(), mesh_names[0]); - std::auto_ptr meshDeleter(myMesh); - - CPPUNIT_ASSERT(myMesh != NULL); - CPPUNIT_ASSERT(myMesh->getIsAGrid()); - - GRID* myGrid = dynamic_cast(myMesh); - CPPUNIT_ASSERT(myGrid); - - CPPUNIT_ASSERT_THROW(myGrid->getArrayLength(0), MEDEXCEPTION); - - int I, J, K; - CPPUNIT_ASSERT_NO_THROW(I = myGrid->getArrayLength(1)); - CPPUNIT_ASSERT_NO_THROW(J = myGrid->getArrayLength(2)); - CPPUNIT_ASSERT_NO_THROW(K = myGrid->getArrayLength(3)); - - CPPUNIT_ASSERT(I); - CPPUNIT_ASSERT(J); - - med_grid_type grid_type = myGrid->getGridType(); - CPPUNIT_ASSERT_MESSAGE("Wrong grid type", grid_type == MED_CARTESIAN); - - const MESH* mesh = myGrid->convertInMESH(); - const double * coordinates = mesh->getCoordinates(MED_FULL_INTERLACE); - int SpaceDimension = myGrid->getSpaceDimension(); - for (int axe = 0; axe < SpaceDimension; axe++) { - for (int num = 0; num < myGrid->getNumberOfNodes(); num++) { - double coordinate; - CPPUNIT_ASSERT_NO_THROW(coordinate = mesh->getCoordinate(num + 1, axe + 1)); - //cout << "coordinate = " << coordinate << endl; - CPPUNIT_ASSERT(fabs(coordinate - coordinates[(num * SpaceDimension)+axe]) < 0.001); - } - } - - int nbTypesCell = myGrid->getNumberOfTypes(MED_CELL); - CPPUNIT_ASSERT(nbTypesCell == 1); - - const medGeometryElement* types; - CPPUNIT_ASSERT_NO_THROW(types = myGrid->getTypes(MED_CELL)); -//#ifdef ENABLE_FORCED_FAILURES - // Compilation warning about GRID::getTypes(): - // "inline function - // `virtual const MED_EN::medGeometryElement* MEDMEM::GRID::getTypes(MED_EN::medEntityMesh) const' - // used but never defined". - // In MEDMEM_Grid.hxx: - // inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const; - // But implemented in MEDMEM_Grid.cxx: - // const MED_EN::medGeometryElement * GRID::getTypes(MED_EN::medEntityMesh entity) const -// CPPUNIT_FAIL("Problem with GRID::getTypes() method implementation."); -//#endif - CPPUNIT_ASSERT(types[0] == MED_QUAD4); - - int nbElem = 0; - CPPUNIT_ASSERT_NO_THROW(nbElem = myGrid->getNumberOfElements(MED_CELL,types[0])); - CPPUNIT_ASSERT(nbElem); - - int nbNodes = myGrid->getNumberOfNodes(); - CPPUNIT_ASSERT(nbNodes); - - int ijkNode[3]; - int NodeNumber; - for (int nbNode = 1; nbNode <= nbNodes; nbNode++) { - CPPUNIT_ASSERT_NO_THROW(myGrid->getNodePosition(nbNode, ijkNode[0], ijkNode[1], ijkNode[2])); - CPPUNIT_ASSERT_NO_THROW(NodeNumber = myGrid->getNodeNumber(ijkNode[0], ijkNode[1], ijkNode[2])); - CPPUNIT_ASSERT(NodeNumber == nbNode); - } - - int nbCells = myGrid->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT(nbCells); - - int ijkCell[3]; - int CellNumber; - for (int nbCell = 1; nbCell <= nbCells; nbCell++) { - CPPUNIT_ASSERT_NO_THROW(myGrid->getCellPosition(nbCell, ijkCell[0], ijkCell[1], ijkCell[2])); - CPPUNIT_ASSERT_NO_THROW(CellNumber = myGrid->getCellNumber(ijkCell[0], ijkCell[1], ijkCell[2])); - CPPUNIT_ASSERT(CellNumber == nbCell); - } - - int nbEdges = myGrid->getNumberOfElements(MED_EDGE, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT(nbEdges); - - int ijkAxisEdge[4]; - int EdgeNumber; - for (int nbEdge = 1; nbEdge <= nbEdges; nbEdge++) { - CPPUNIT_ASSERT_NO_THROW(myGrid->getEdgePosition(nbEdge, ijkAxisEdge[0], ijkAxisEdge[1], - ijkAxisEdge[2], ijkAxisEdge[3])); - CPPUNIT_ASSERT_NO_THROW(EdgeNumber = myGrid->getEdgeNumber(ijkAxisEdge[0], ijkAxisEdge[1], - ijkAxisEdge[2], ijkAxisEdge[3])); - CPPUNIT_ASSERT(EdgeNumber == nbEdge); - } - - int nbFaces = myGrid->getNumberOfElements(MED_FACE, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT(nbFaces == 0); - -//#ifdef ENABLE_FORCED_FAILURES - CPPUNIT_FAIL("ERROR: nbFaces == 0, but getFacePosition(AnyNumber, ...) - return position(i,j,k)"); -//#endif - int ijkAxisFace[4]; - CPPUNIT_ASSERT_NO_THROW(myGrid->getFacePosition(6, ijkAxisFace[0], ijkAxisFace[1], - ijkAxisFace[2], ijkAxisFace[3])); - CPPUNIT_ASSERT(ijkAxisFace[0]); - CPPUNIT_ASSERT(ijkAxisFace[1]); - CPPUNIT_ASSERT(ijkAxisFace[2]); - - /*int FaceNumber; - for(int nbFace = 1; nbFace <= nbFaces; nbFace++) - { - CPPUNIT_ASSERT_NO_THROW( myGrid->getFacePosition(nbFace, ijkAxisFace[0], ijkAxisFace[1], - ijkAxisFace[2], ijkAxisFace[3])); - CPPUNIT_ASSERT_NO_THROW( EdgeNumber = myGrid->getEdgeNumber(ijkAxisFace[0], ijkAxisFace[1], - ijkAxisFace[2], ijkAxisFace[3])); - CPPUNIT_ASSERT(FaceNumber == nbFace); - }*/ - - bool existConnect = false; - CPPUNIT_ASSERT_NO_THROW(existConnect = mesh->existConnectivity(MED_NODAL, MED_CELL)); - if (!existConnect) { - CPPUNIT_ASSERT_NO_THROW(mesh->calculateConnectivity( MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(mesh->existConnectivity(MED_NODAL, MED_CELL)); - } - - const int* Connectivity; - const int* connectivity_index; - CPPUNIT_ASSERT_NO_THROW(Connectivity = mesh->getConnectivity( MED_NODAL, - MED_CELL, types[0])); - CPPUNIT_ASSERT_NO_THROW(connectivity_index = mesh->getConnectivityIndex(MED_NODAL, MED_CELL)); - out << "Nodal connectivity" << endl; - for (int j = 0; j < nbElem; j++) { - out << "Element "<< j+1 << " : "; - for (int k = connectivity_index[j]; k < connectivity_index[j+1]; k++) - out << Connectivity[k-1] << " "; - out << endl; - } - - const int * ReverseNodalConnectivity; - const int * ReverseConnectivityIndex; - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivity = mesh->getReverseConnectivity(MED_NODAL)); - CPPUNIT_ASSERT_NO_THROW(ReverseConnectivityIndex = mesh->getReverseConnectivityIndex(MED_NODAL)); - for (int i = 0; i < nbNodes; i++) { - out << "Node "<< i+1 << " : "; - for (int j = ReverseConnectivityIndex[i]; j < ReverseConnectivityIndex[i+1]; j++) - out << ReverseNodalConnectivity[j-1] << " "; - out << endl; - } - - const int* myGlobalNbIdx; - CPPUNIT_ASSERT_NO_THROW(myGlobalNbIdx = mesh->getGlobalNumberingIndex(MED_CELL)); - for (int i = 0; i <= nbTypesCell; i++) { - if (i == nbTypesCell) { - CPPUNIT_ASSERT_THROW(myGrid->getElementType(MED_CELL, myGlobalNbIdx[i]), MEDEXCEPTION); - break; - } - medGeometryElement aElem; - CPPUNIT_ASSERT_NO_THROW(aElem = myGrid->getElementType(MED_CELL, myGlobalNbIdx[i])); - CPPUNIT_ASSERT(types[0] == aElem); - } - - CPPUNIT_ASSERT_NO_THROW(existConnect = mesh->existConnectivity(MED_DESCENDING, MED_CELL)); - if (!existConnect) { - CPPUNIT_ASSERT_NO_THROW(mesh->calculateConnectivity( MED_DESCENDING, MED_CELL)); - CPPUNIT_ASSERT(mesh->existConnectivity(MED_DESCENDING, MED_CELL)); - } - - const int* ConnectivityDes; - const int* connectivity_index_des; - CPPUNIT_ASSERT_NO_THROW(ConnectivityDes = mesh->getConnectivity( MED_DESCENDING, - MED_CELL, MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_NO_THROW(connectivity_index_des = - mesh->getConnectivityIndex(MED_DESCENDING, MED_CELL)); - out<<"Descending connectivity"<getReverseConnectivity(MED_DESCENDING)); - CPPUNIT_ASSERT_NO_THROW(ReverseConnectivityIndexDes = - mesh->getReverseConnectivityIndex(MED_DESCENDING)); - for (int i = 0; i < nbNodes; i++) { - out << "Node "<< i+1 << " : "; - for (int j = ReverseConnectivityIndexDes[i]; j < ReverseConnectivityIndexDes[i+1]; j++) - out << ReverseDesConnectivity[j-1] << " "; - out << endl; - } - mesh->removeReference(); - - } - - ////////////////////////////// - // test2 "MED_BODY_FITTED" // - ////////////////////////////// - { - CPPUNIT_ASSERT_THROW( MESH(MED_DRIVER, myMed->getFileName(), mesh_names[1]), MEDEXCEPTION); - - GMESH* myMesh1 = new GRID(MED_DRIVER,myMed->getFileName(),mesh_names[1]); - std::auto_ptr meshDeleter(myMesh1); - - CPPUNIT_ASSERT(myMesh1 != NULL); - CPPUNIT_ASSERT(myMesh1->getIsAGrid()); - - GRID* myGrid1 = dynamic_cast(myMesh1); - CPPUNIT_ASSERT(myGrid1); - - int I, J, K; - CPPUNIT_ASSERT_NO_THROW(I = myGrid1->getArrayLength(1)); - CPPUNIT_ASSERT_NO_THROW(J = myGrid1->getArrayLength(2)); - CPPUNIT_ASSERT_NO_THROW(K = myGrid1->getArrayLength(3)); - - CPPUNIT_ASSERT(I == 2); - CPPUNIT_ASSERT(J == 2); - - med_grid_type grid_type = myGrid1->getGridType(); - CPPUNIT_ASSERT_MESSAGE("Wrong grid type", grid_type == MED_BODY_FITTED); - - int nbTypesCell = myGrid1->getNumberOfTypes(MED_CELL); - CPPUNIT_ASSERT(nbTypesCell == 1); - - const medGeometryElement* types1; - CPPUNIT_ASSERT_NO_THROW( types1 = myGrid1->getTypes(MED_CELL) ); - CPPUNIT_ASSERT( types1[0] == MED_QUAD4); - - int nbElem; - CPPUNIT_ASSERT_NO_THROW(nbElem = myGrid1->getNumberOfElements(MED_CELL, types1[0])); - CPPUNIT_ASSERT(nbElem); - - const int* BodyConnectivity; - const int* body_connectivity_index; - int ijkNodeBody[3]; - const MESH* mesh = myGrid1->convertInMESH(); - CPPUNIT_ASSERT_NO_THROW(BodyConnectivity = mesh->getConnectivity( MED_NODAL, - MED_CELL, types1[0])); - CPPUNIT_ASSERT_NO_THROW(body_connectivity_index = mesh->getConnectivityIndex(MED_NODAL, MED_CELL)); - out<<"Nodal connectivity"<getNodePosition(BodyConnectivity[k-1], ijkNodeBody[0], - ijkNodeBody[1], ijkNodeBody[2])); - out << BodyConnectivity[k-1] << " "; - } - out << endl; - } - mesh->removeReference(); - } - - /////////////////////////////////////////////////// - // test3 "maa1" which in fact is not a pure GRID // - /////////////////////////////////////////////////// - { - GMESH* myMesh2 = NULL; - - CPPUNIT_ASSERT_THROW( myMesh2 = new GRID( MED_DRIVER,myMed->getFileName(),mesh_names[2]), - MEDEXCEPTION ); - CPPUNIT_ASSERT_NO_THROW( myMesh2 = new MESH( MED_DRIVER,myMed->getFileName(),mesh_names[2])); - - CPPUNIT_ASSERT(myMesh2 != NULL); - CPPUNIT_ASSERT(!(myMesh2->getIsAGrid())); - myMesh2->removeReference(); - } - - delete myMed; - - //////////////////////////// - // test4 create new GRID // - //////////////////////////// - - // Default constructor and destructor - { - GRID* myGrid2 = new GRID(); - CPPUNIT_ASSERT(myGrid2->getIsAGrid()); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_CARTESIAN); - CPPUNIT_ASSERT(!myGrid2->getArrayLength(1)); - CPPUNIT_ASSERT(!myGrid2->getArrayLength(2)); - CPPUNIT_ASSERT(!myGrid2->getArrayLength(3)); - myGrid2->removeReference(); - } - - // Constructor with grid type, setGridType() - { - GRID* myGrid2 = new GRID(MED_POLAR); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_POLAR); - myGrid2->setGridType(MED_CARTESIAN); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_CARTESIAN); - myGrid2->removeReference(); - } - - // Constructor with coordinate values, getArrayValue(), init() - { - vector > xyz; - const int nbCoords = 3; - xyz.resize(nbCoords); - for ( int i = 0; i < nbCoords; i++ ) - { - xyz[i].resize(i + 2); - for ( int j = 0; j < i + 2; j++ ) - xyz[i][j] = j; - } - vector Coord_Names; - Coord_Names.resize(nbCoords); - Coord_Names[0] = "X"; - Coord_Names[1] = "Y"; - Coord_Names[2] = "Z"; - - vector Coord_Units; - Coord_Units.resize(nbCoords); - for(int i = 0; i < 3; i++) - Coord_Units[i] = "cm"; - - GRID* myGrid2; - - try{ - myGrid2 = new GRID(xyz, Coord_Names, Coord_Units, MED_CARTESIAN); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // testing getCoordinateptr() and fillCoordinates() - // We fill a map of all possible coordinate triples. - // After iteration through all coordinates, this map should contain only "true" as data. - // "true" in some map element during iteration means duplicated node position. - // "false" in some map element after iteration means empty node position. - map found; - for ( unsigned i1 = 0; i1 < xyz[0].size(); i1++ ) - for ( unsigned i2 = 0; i2 < xyz[1].size(); i2++ ) - for ( unsigned i3 = 0; i3 < xyz[2].size(); i3++ ) - found[ xyz[0][i1] * 100 + xyz[1][i2] * 10 + xyz[2][i3] ] = false; - - const MESH* mesh = myGrid2->convertInMESH(); - COORDINATE* coords = (COORDINATE*)mesh->getCoordinateptr(); - CPPUNIT_ASSERT(coords); - for (int num = 0; num < myGrid2->getNumberOfNodes(); num++) { - int x = int(coords->getCoordinate(num + 1, 1)); - int y = int(coords->getCoordinate(num + 1, 2)); - int z = int(coords->getCoordinate(num + 1, 3)); - CPPUNIT_ASSERT(!found[x * 100 + y * 10 + z]); - found[x * 100 + y * 10 + z] = true; - } - - for ( map::iterator it = found.begin(); it != found.end(); it++ ) - CPPUNIT_ASSERT((*it).second); - - // Testing fillConnectivity() and getConnectivityptr() - // Basic testing: presence of connectivity arrays, element types and number of elements - CONNECTIVITY* conn = (CONNECTIVITY*)mesh->getConnectivityptr(); - CPPUNIT_ASSERT(conn); - bool hasFaces = myGrid2->getArrayLength(3), hasEdges = myGrid2->getArrayLength(2); - medGeometryElement aCellGeometry; - if (hasFaces) aCellGeometry = MED_HEXA8; - else if (hasEdges) aCellGeometry = MED_QUAD4; - else aCellGeometry = MED_SEG2; - CPPUNIT_ASSERT(conn->getElementType(MED_CELL, 1) == aCellGeometry); - CPPUNIT_ASSERT(conn->existConnectivity(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(conn->existConnectivity(MED_DESCENDING, MED_CELL)); - //test getCellsTypes - CELLMODEL* cellmodel = (CELLMODEL*)mesh->getCellsTypes(MED_CELL); - CPPUNIT_ASSERT(cellmodel); - - int nbCells, nbFaces, nbEdges; - - int iLen = myGrid2->getArrayLength(1); - int jLen = myGrid2->getArrayLength(2); - int kLen = myGrid2->getArrayLength(3); - int iLenMin1 = myGrid2->getArrayLength(1)-1; - int jLenMin1 = myGrid2->getArrayLength(2)-1; - int kLenMin1 = myGrid2->getArrayLength(3)-1; - const int* aCellCount = conn->getGlobalNumberingIndex(MED_CELL); - nbCells = iLenMin1 * jLenMin1 * kLenMin1; - CPPUNIT_ASSERT(aCellCount[1] - 1 == nbCells); - - if (hasFaces){ - CPPUNIT_ASSERT(conn->getElementType(MED_FACE, 1) == MED_QUAD4); - nbFaces = iLen * jLenMin1 * kLenMin1; - nbFaces += jLen * kLenMin1 * iLenMin1; - nbFaces += kLen * iLenMin1 * jLenMin1; - const int* aFaceCount = conn->getGlobalNumberingIndex(MED_FACE); - CPPUNIT_ASSERT(aFaceCount[1] - 1 == nbFaces); - CPPUNIT_ASSERT(conn->existConnectivity(MED_NODAL, MED_FACE)); - //test getCellsTypes - CELLMODEL* cellmodelF = (CELLMODEL*)mesh->getCellsTypes(MED_FACE); - CPPUNIT_ASSERT(cellmodelF); - } - if (hasEdges){ - CPPUNIT_ASSERT(conn->getElementType(MED_EDGE, 1) == MED_SEG2); - if (kLen) { // 3d grid - nbEdges = iLenMin1 * jLen * kLen; - nbEdges += jLenMin1 * kLen * iLen; - nbEdges += kLenMin1 * iLen * jLen; - } - else if (jLen) { // 2d - nbEdges = iLenMin1 * jLen; - nbEdges += jLenMin1 * iLen; - } - const int* anEdgeCount = conn->getGlobalNumberingIndex(MED_EDGE); - CPPUNIT_ASSERT(anEdgeCount[1] - 1 == nbEdges); - CPPUNIT_ASSERT(conn->existConnectivity(MED_NODAL, MED_EDGE)); - //test getCellsTypes - CELLMODEL* cellmodelE = (CELLMODEL*)mesh->getCellsTypes(MED_EDGE); - CPPUNIT_ASSERT(cellmodelE); - - } - - // Testing getArrayValue() - for ( int ii = 1; ii <= nbCoords; ii++ ) - for ( int jj = 0; jj < ii + 1; jj++ ) - CPPUNIT_ASSERT(myGrid2->getArrayValue(ii, jj) == xyz[ii - 1][jj]); - - CPPUNIT_ASSERT_THROW(myGrid2->getArrayValue(nbCoords + 1, 0), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(myGrid2->getArrayValue(1, myGrid2->getArrayLength(1) + 1), MEDEXCEPTION); - myGrid2->setGridType(MED_POLAR); - - //testing read/write functions - - // add new driver - int idGridV21; - - try - { - idGridV21 = const_cast(mesh)->addDriver(MED_DRIVER,filenameout21); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // write this driver to file as an unstructured mesh - CPPUNIT_ASSERT_NO_THROW(mesh->write(idGridV21)); - - GRID* myGrid3 = new GRID(); - // add new driver for myGrid3 - int driver; - CPPUNIT_ASSERT_NO_THROW(driver = myGrid3->addDriver(MED_DRIVER, filenameout21)); - -//#ifdef ENABLE_FORCED_FAILURES - // ? (BUG) ? "The mesh dimension |-1| seems to be incorrect for the mesh : |Default Mesh Name|" - CPPUNIT_ASSERT_NO_THROW(myGrid3->read(driver)); - - // Testing getArrayValue() - for ( int ii = 1; ii <= nbCoords; ii++ ) - for ( int jj = 0; jj < ii + 1; jj++ ) - CPPUNIT_ASSERT(myGrid3->getArrayValue(ii, jj) == xyz[ii - 1][jj]); - - CPPUNIT_ASSERT(myGrid3->getGridType() == MED_POLAR); -//#endif - - myGrid3->removeReference(); - - //test init() - CPPUNIT_ASSERT_NO_THROW(myGrid2->init()); - CPPUNIT_ASSERT(myGrid2->getGridType() == MED_CARTESIAN); - CPPUNIT_ASSERT(myGrid2->getArrayLength(1) == 0); - CPPUNIT_ASSERT(myGrid2->getArrayLength(2) == 0); - CPPUNIT_ASSERT(myGrid2->getArrayLength(3) == 0); -//#ifdef ENABLE_FAULTS - // (BUG) Segmentation Fault - //myGrid2->makeUnstructured(); -//#endif -//#ifdef ENABLE_FORCED_FAILURES -// CPPUNIT_FAIL("ERROR:makeUnstructured() - there is no check if grid is empty or not"); -//#endif - - myGrid2->removeReference(); - mesh->removeReference(); - } - -//#ifdef ENABLE_FORCED_FAILURES - { - GRID* myGrid2; - // ? (BUG) ? MED Exception in /dn20/salome/jfa/V3/SRC/MED_SRC/src/MEDMEM/MEDMEM_MedM - //eshDriver21.cxx [430] : MED_MESH_RDONLY_DRIVER21::getCOORDINATE() : The number - //of nodes |0| seems to be incorrect for the mesh : |bodyfitted| - CPPUNIT_ASSERT_NO_THROW(myGrid2 = new GRID(MED_DRIVER, filename, mesh_names[1])); - - // Check if something has been read - full mesh data testing is above - CPPUNIT_ASSERT(myGrid2->getSpaceDimension()); - CPPUNIT_ASSERT(myGrid2->getNumberOfNodes()); - CPPUNIT_ASSERT(myGrid2->getNumberOfTypes(MED_CELL) == 1); - const medGeometryElement* types2; - CPPUNIT_ASSERT_NO_THROW(types2 = myGrid2->getTypes(MED_CELL)); - int nbElem; - CPPUNIT_ASSERT_NO_THROW(nbElem = myGrid2->getNumberOfElements(MED_CELL,types2[0])); - CPPUNIT_ASSERT(nbElem); - myGrid2->removeReference(); - } -//#endif - - { - GRID* myGrid4 = new GRID(); - filename = getResourceFile("pointe.med"); - myGrid4->setName("maa1"); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename, myGrid4); - myMeshDriver.setMeshName("maa1"); - - // add new driver for myGrid4 - int driver; - CPPUNIT_ASSERT_NO_THROW(driver = myGrid4->addDriver(myMeshDriver)); - - // ??? ERROR:myGrid4->fillMeshAfterRead()- this method is incomplete: - // currently it only resets _is_coordinates_filled and _is_connectivity_filled - // flags that leads to grid reconstruction - - // MED Exception : MED_MESH_RDONLY_DRIVER21::getGRID() : The number - // of nodes |-1| seems to be incorrect for the mesh : |maa1| - // But this exception seems to be correct reaction on attempt - // to read a grid from a file, which does not contain it. - CPPUNIT_ASSERT_THROW(myGrid4->read(driver), MEDEXCEPTION); - //CPPUNIT_ASSERT_NO_THROW(myGrid4->read(driver)); - /*CPPUNIT_ASSERT(myGrid4->getArrayLength(1) == 0); - CPPUNIT_ASSERT(myGrid4->getArrayLength(2) == 0); - CPPUNIT_ASSERT(myGrid4->getArrayLength(3) == 0); - myGrid4->fillMeshAfterRead(); - CPPUNIT_ASSERT(myGrid4->getArrayLength(1) != 0); - CPPUNIT_ASSERT(myGrid4->getArrayLength(2) != 0); - CPPUNIT_ASSERT(myGrid4->getArrayLength(3) != 0);*/ - - myGrid4->removeReference(); - } -} - -int main (int argc, char** argv) -{ - MEDMEMTest_testGrid(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Group.cxx b/src/MEDMEMCppTest/MEDMEMTest_Group.cxx deleted file mode 100644 index 60c464f80..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Group.cxx +++ /dev/null @@ -1,146 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include - -#include "MEDMEM_Group.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_MedMeshDriver.hxx" - -#include -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (10), defined in MEDMEM_Group.hxx: - * class GROUP : virtual public SUPPORT { - * (+) GROUP(); - * (+) GROUP(const string & name, const list & family) throw (MEDEXCEPTION); - * (+) GROUP(const GROUP & m); - * (+) virtual ~GROUP(); - * (+) GROUP & operator=(const GROUP &group); - * (+) friend ostream & operator<<(ostream &os, GROUP &my); - * (+) inline void setNumberOfFamilies(int numberOfFamilies); - * (+) inline void setFamilies(vector Family); - * (+) inline int getNumberOfFamilies() const; - * (+) inline vector getFamilies() const; - * (+) inline FAMILY * getFamily(int i) const; - * } - */ -void MEDMEMTest::testGroup() -{ - string filename = getResourceFile("pointe.med") ; - string meshname = "maa1"; - - MESH * myMesh=new MESH; - myMesh->setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver(filename,myMesh); - myMeshDriver.setMeshName(meshname); - myMeshDriver.open(); - myMeshDriver.read(); - myMeshDriver.close(); - - const GROUP * myGroup = myMesh->getGroup(MED_NODE,1); - CPPUNIT_ASSERT(myGroup != NULL); - - int NumberOfFamillies = myGroup->getNumberOfFamilies(); - CPPUNIT_ASSERT(NumberOfFamillies != 0); - - vector aFamilies = myGroup->getFamilies(); - CPPUNIT_ASSERT(NumberOfFamillies == (int)aFamilies.size()); - list aList; - - for (int j=1;j<=NumberOfFamillies;j++) - { - try{ - aList.push_back(myGroup->getFamily(j)); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT_EQUAL(myGroup->getFamily(j)->getName(), aFamilies[j-1]->getName()); - } - - GROUP* myGroup2 = new GROUP(*myGroup); - - ostringstream os; - os << *myGroup2; - CPPUNIT_ASSERT(os.str() != ""); - - GROUP *myGroup3=new GROUP; - try{ - *myGroup3 = *myGroup2; - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_EQUAL(*myGroup3, *myGroup2); - myGroup3->removeReference(); - - GROUP *myGroup4=new GROUP; - const GROUP * Group = myMesh->getGroup(MED_NODE,2); - CPPUNIT_ASSERT(Group != NULL); - - int NumberOfFamillies1 = Group->getNumberOfFamilies(); - CPPUNIT_ASSERT(NumberOfFamillies1 != 0); - if(NumberOfFamillies1) - { - myGroup4->setNumberOfFamilies(NumberOfFamillies1); - myGroup4->setFamilies(Group->getFamilies()); - for(int i = 1; i <= myGroup4->getNumberOfFamilies(); i++ ) - { - CPPUNIT_ASSERT_EQUAL(myGroup4->getFamily(i), Group->getFamily(i)); - } - } - myGroup4->removeReference(); - if(aList.size()) - { - try{ - GROUP *myGroup5=new GROUP("newFamily", aList); - myGroup5->removeReference(); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - myGroup2->removeReference(); - myMesh->removeReference() ; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_MedFieldDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_MedFieldDriver.cxx deleted file mode 100644 index 217eb7d39..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_MedFieldDriver.cxx +++ /dev/null @@ -1,670 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -/*! - * Check methods (17), defined in MEDMEM_MedFieldDriver22.hxx: - * template class MED_FIELD_DRIVER22 : public virtual MED_FIELD_DRIVER { - * (+) MED_FIELD_DRIVER22(); - * (+) template MED_FIELD_DRIVER22(const string & fileName, - * FIELD * ptrField, MED_EN::med_mode_acces accessMode); - * (+) MED_FIELD_DRIVER22(const MED_FIELD_DRIVER22 & fieldDriver); - * (+) virtual ~MED_FIELD_DRIVER22(); - * (+) void open() throw (MEDEXCEPTION); - * (+) void close(); - * } - * template class MED_FIELD_RDONLY_DRIVER : public virtual MED_FIELD_DRIVER22, - * public virtual IMED_FIELD_RDONLY_DRIVER { - * (+) MED_FIELD_RDONLY_DRIVER(); - * (+) template MED_FIELD_RDONLY_DRIVER - * (const string & fileName, FIELD * ptrField); - * (+) MED_FIELD_RDONLY_DRIVER(const MED_FIELD_RDONLY_DRIVER & fieldDriver); - * (+) virtual ~MED_FIELD_RDONLY_DRIVER(); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * } - * template class MED_FIELD_WRONLY_DRIVER : public virtual MED_FIELD_DRIVER22, - * public virtual IMED_FIELD_WRONLY_DRIVER { - * (+) MED_FIELD_WRONLY_DRIVER(); - * (+) template MED_FIELD_WRONLY_DRIVER - * (const string & fileName, FIELD * ptrField); - * (+) MED_FIELD_WRONLY_DRIVER(const MED_FIELD_WRONLY_DRIVER & fieldDriver); - * (+) virtual ~MED_FIELD_WRONLY_DRIVER(); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * } - * template class MED_FIELD_RDWR_DRIVER22 : public MED_FIELD_RDONLY_DRIVER, - * public MED_FIELD_WRONLY_DRIVER, public IMED_FIELD_RDWR_DRIVER { - * (+) MED_FIELD_RDWR_DRIVER22(); - * (+) template MED_FIELD_RDWR_DRIVER22 - * (const string & fileName, FIELD * ptrField); - * (+) MED_FIELD_RDWR_DRIVER22(const MED_FIELD_RDWR_DRIVER22 & fieldDriver); - * (+) ~MED_FIELD_RDWR_DRIVER22(); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * } - */ -void MEDMEMTest::testMedFieldDriver() -{ - FIELD *aField = new FIELD(); - FIELD *aField_1 = new FIELD(); - FIELD *aField_2 = new FIELD(); - string filename_rd = getResourceFile("pointe.med"); - string filenameWithOutFileds = getResourceFile("mesh.med"); - string filenameWithOutFileds_rdwr = makeTmpFile("mesh.med", filenameWithOutFileds); - string fileldnotexist = "anyfield"; - string fieldname = "fieldnodeint"; - string fieldname_cpy = fieldname + "_cpy"; - string fileNotExist_rd = "notExist22.med"; - string emptyfilename = ""; - - string filename_wr = makeTmpFile("myWrField_pointe22.med", filename_rd); - string fileNotExist_wr = "/path_not_exist/file_not_exist.med"; - string emptyfile_wr = makeTmpFile("myWrField_pointe_empty22.med"); - string other_file = getResourceFile("cube_hexa8.med"); - string other_file_wr = makeTmpFile("myWRcube_hexa8.med", other_file); - - string filename_rdwr = makeTmpFile("myRdWrField_pointe22.med", filename_rd); - string emptyfile_rdwr = makeTmpFile("myRdWrField_pointe_empty22.med"); - string fieldnameDouble = "fieldnodedouble"; - string fieldnameDouble_cpy = fieldnameDouble + "_cpy"; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - aRemover.Register(emptyfile_wr); - aRemover.Register(other_file_wr); - aRemover.Register(filename_rdwr); - aRemover.Register(emptyfile_rdwr); - aRemover.Register(filenameWithOutFileds_rdwr); - - //--------------------------Test READ ONLY part------------------------------// - - ///////////////////////////////////// - // TEST1: Open not existing file // - ///////////////////////////////////// - - //Creation Invalid Read Only MedFieldDriver22 (file not exist) - MED_FIELD_RDONLY_DRIVER *aInvalidMedRdFieldDriver22_1 = - new MED_FIELD_RDONLY_DRIVER(fileNotExist_rd, aField); - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidMedRdFieldDriver22_1->open(), MEDEXCEPTION); - - ////////////////////////////////////////////// - // TEST2: Open file with empty file name /// - ////////////////////////////////////////////// - - //Creation Invalid Read Only MedFieldDriver22 (empty file name) - MED_FIELD_RDONLY_DRIVER *aInvalidMedRdFieldDriver22_2 = - new MED_FIELD_RDONLY_DRIVER(emptyfilename, aField); - //Trying file with empty name - CPPUNIT_ASSERT_THROW(aInvalidMedRdFieldDriver22_2->open(), MEDEXCEPTION); - - ///////////////////////////////////////////////////// - // TEST3: Reading field from file without fields // - ///////////////////////////////////////////////////// - MED_FIELD_RDONLY_DRIVER *aInvalidMedRdFieldDriver22_3 = - new MED_FIELD_RDONLY_DRIVER(filenameWithOutFileds, aField); - aInvalidMedRdFieldDriver22_3->open(); - aInvalidMedRdFieldDriver22_3->setFieldName(fieldname); - //Trying read field from file - CPPUNIT_ASSERT_THROW(aInvalidMedRdFieldDriver22_3->read(), MEDEXCEPTION); - aInvalidMedRdFieldDriver22_3->close(); - - //////////////////////// - // TEST4: Main test // - //////////////////////// - //Creation correct Read Only MedFieldDriver22 - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver22 = - new MED_FIELD_RDONLY_DRIVER(filename_rd, aField); - - //Check driver - CPPUNIT_ASSERT(aMedRdFieldDriver22); - - //Trying read field before open file - CPPUNIT_ASSERT_THROW(aMedRdFieldDriver22->read(),MEDEXCEPTION); - - //Test open() method - try - { - aMedRdFieldDriver22->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //#ifdef ENABLE_FORCED_FAILURES - //Trying open file secondary. - //CPPUNIT_ASSERT_THROW(aMedRdFieldDriver22->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aMedRdFieldDriver22->open()); - // (BUG) No exception in this case - //#endif - - //Trying read field form file if it name is empty - CPPUNIT_ASSERT_THROW(aMedRdFieldDriver22->read(), MEDEXCEPTION); - - //Test setFieldName() and getFieldName() - try - { - aMedRdFieldDriver22->setFieldName(fileldnotexist); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT_EQUAL(fileldnotexist, aMedRdFieldDriver22->getFieldName()); - - //Trying read not existing field from file - CPPUNIT_ASSERT_THROW(aMedRdFieldDriver22->read(), MEDEXCEPTION); - - //Test read() method - aMedRdFieldDriver22->setFieldName(fieldname); - try - { - aMedRdFieldDriver22->read(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test write() method for READ ONLY driver - CPPUNIT_ASSERT_THROW(aMedRdFieldDriver22->write(), MEDEXCEPTION); - - //Test close() method - try - { - aMedRdFieldDriver22->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Default constructor - MED_FIELD_RDONLY_DRIVER aMedRdFieldDriver22Cpy_1; - - //Test (void operator =) defined in GENDRIVER class in MEDMEM_GenDriver.hxx - aMedRdFieldDriver22Cpy_1 = *aMedRdFieldDriver22; - - //Test (bool operator ==) defined GENDRIVER class in MEDMEM_GenDriver.hxx - CPPUNIT_ASSERT(aMedRdFieldDriver22Cpy_1 == *aMedRdFieldDriver22); - - //Test copy constructorg - MED_FIELD_RDONLY_DRIVER aMedRdFieldDriver22Cpy_2 (*aMedRdFieldDriver22); - CPPUNIT_ASSERT_EQUAL(aMedRdFieldDriver22Cpy_2, *aMedRdFieldDriver22); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream rostr1, rostr2; - rostr1< *aInvalidMedWrFieldDriver22_1 = - new MED_FIELD_WRONLY_DRIVER(fileNotExist_wr, aField_1); - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidMedWrFieldDriver22_1->open(), MEDEXCEPTION); - - ///////////////////////////////////////////// - // TEST2: Open file with empty file name // - ///////////////////////////////////////////// - //Creation Invalid Write Only MedFieldDriver22 (empty file name) - MED_FIELD_WRONLY_DRIVER *aInvalidMedWrFieldDriver22_2 = - new MED_FIELD_WRONLY_DRIVER(emptyfilename, aField_1); - //Trying open not existing file and file with empty name - CPPUNIT_ASSERT_THROW(aInvalidMedWrFieldDriver22_2->open(), MEDEXCEPTION); - - /////////////////////////////////////////////////////// - // TEST3: Writing field in empty file without mesh // - /////////////////////////////////////////////////////// - //Creation Invalid Write Only MedFieldDriver22 - MED_FIELD_WRONLY_DRIVER *aInvalidMedWrFieldDriver22_3 = - new MED_FIELD_WRONLY_DRIVER(emptyfile_wr, aField); - - aInvalidMedWrFieldDriver22_3->open(); - //#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_ASSERT_THROW(aInvalidMedWrFieldDriver22_3->write(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aInvalidMedWrFieldDriver22_3->write()); - //(Bug) No Exception in this case - aInvalidMedWrFieldDriver22_3->close(); - //#endif - - ////////////////////////////////////////////// - // TEST4: Writing field in the other file // - ////////////////////////////////////////////// - - //Creation Invalid Write Only MedFieldDriver22 - MED_FIELD_WRONLY_DRIVER *aInvalidMedWrFieldDriver22_4 = - new MED_FIELD_WRONLY_DRIVER(other_file_wr, aField); - aInvalidMedWrFieldDriver22_4->open(); - //#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_ASSERT_THROW(aInvalidMedWrFieldDriver22_4->write(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aInvalidMedWrFieldDriver22_4->write()); - //(Bug) No Exception in this case - //#endif - - //////////////////////// - // TEST5: Main test // - //////////////////////// - - //Creation correct Write Only MedFieldDriver22 - MED_FIELD_WRONLY_DRIVER *aMedWrFieldDriver22 = - new MED_FIELD_WRONLY_DRIVER(filename_wr, aField); - - //Check driver - CPPUNIT_ASSERT(aMedWrFieldDriver22); - - //Trying write field before open file - //#ifdef ENABLE_FORCED_FAILURES - CPPUNIT_ASSERT_THROW(aMedWrFieldDriver22->write(),MEDEXCEPTION); - // (BUG) No exception in this case - //#endif - - //Test open() method - try - { - aMedWrFieldDriver22->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //#ifdef ENABLE_FORCED_FAILURES - //Trying open file secondary. - //CPPUNIT_ASSERT_THROW(aMedWrFieldDriver22->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aMedWrFieldDriver22->open()); - // (BUG) No exception in this case - //#endif - - //Test setFieldName() and getFieldName - aField->setName(fieldname_cpy); - try - { - aMedWrFieldDriver22->setFieldName(fieldname_cpy); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT_EQUAL(fieldname_cpy, aMedWrFieldDriver22->getFieldName()); - - //Test write() method - try - { - aMedWrFieldDriver22->write(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test read() method for Write only part - CPPUNIT_ASSERT_THROW(aMedWrFieldDriver22->read(),MEDEXCEPTION); - - //Test close() method - try - { - aMedWrFieldDriver22->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Default constructor - MED_FIELD_WRONLY_DRIVER aMedWrFieldDriver22Cpy_1; - - //Test (void operator =) defined in GENDRIVER class - aMedWrFieldDriver22Cpy_1 = *aMedWrFieldDriver22; - - //Test (bool operator ==) defined in GENDRIVER class - CPPUNIT_ASSERT(aMedWrFieldDriver22Cpy_1.GENDRIVER::operator==(*aMedWrFieldDriver22)); - - //Test copy constructor - MED_FIELD_WRONLY_DRIVER aMedWrFieldDriver22Cpy_2 (*aMedWrFieldDriver22); - CPPUNIT_ASSERT_EQUAL(aMedWrFieldDriver22Cpy_2, *aMedWrFieldDriver22); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream wostr1, wostr2; - wostr1 << aMedWrFieldDriver22Cpy_1; - wostr2 << aMedWrFieldDriver22Cpy_2; - CPPUNIT_ASSERT(wostr1.str() != ""); - CPPUNIT_ASSERT(wostr1.str() == wostr2.str()); - - - //--------------------------Test READ/WRITE part------------------------------// - - ///////////////////////////////////// - // TEST1: Open not existing file // - ///////////////////////////////////// - - //Creation Invalid Read/Write MedFieldDriver22 (file not exist) - MED_FIELD_RDWR_DRIVER *aInvalidMedRdWrFieldDriver22_1 = - new MED_FIELD_RDWR_DRIVER(fileNotExist_wr, aField_1); - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidMedRdWrFieldDriver22_1->open(), MEDEXCEPTION); - - ///////////////////////////////////////////// - // TEST2: Open file with empty file name // - ///////////////////////////////////////////// - //Creation Invalid Read/Write MedFieldDriver22 (empty file name) - MED_FIELD_RDWR_DRIVER *aInvalidMedRdWrFieldDriver22_2 = - new MED_FIELD_RDWR_DRIVER(emptyfilename, aField_1); - //Trying open not existing file and file with empty name - CPPUNIT_ASSERT_THROW(aInvalidMedRdWrFieldDriver22_2->open(), MEDEXCEPTION); - - ///////////////////////////////////////////////////// - // TEST3: Reading field from file without fields // - ///////////////////////////////////////////////////// - MED_FIELD_RDWR_DRIVER *aInvalidMedRdWrFieldDriver22_3 = - new MED_FIELD_RDWR_DRIVER(filenameWithOutFileds_rdwr, aField_1); - aInvalidMedRdWrFieldDriver22_3->open(); - aInvalidMedRdWrFieldDriver22_3->setFieldName(fieldname); - //Trying read field from file - CPPUNIT_ASSERT_THROW(aInvalidMedRdWrFieldDriver22_3->read(), MEDEXCEPTION); - aInvalidMedRdWrFieldDriver22_3->close(); - - /////////////////////////////////////////////////////// - // TEST4: Writing field in empty file without mesh // - /////////////////////////////////////////////////////// - - //Creation Invalid Read/Write MedFieldDriver22 - MED_FIELD_RDWR_DRIVER *aInvalidMedRdWrFieldDriver22_4 = - new MED_FIELD_RDWR_DRIVER(emptyfile_rdwr, aField); - - aInvalidMedRdWrFieldDriver22_4->open(); - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_ASSERT_THROW(aInvalidMedRdWrFieldDriver22_4->write(), MEDEXCEPTION); - // (BUG) No exception in this case - //#endif - - ////////////////////////////////////////////// - // TEST6: Writing field in the other file // - ////////////////////////////////////////////// - - //Creation Invalid Read/Write MedFieldDriver22 - MED_FIELD_RDWR_DRIVER *aInvalidMedRdWrFieldDriver22_5 = - new MED_FIELD_RDWR_DRIVER(other_file_wr, aField); - aInvalidMedRdWrFieldDriver22_5->open(); - //#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_ASSERT_THROW(aInvalidMedRdWrFieldDriver22_5->write(), MEDEXCEPTION); - // (BUG) No exception in this case - //#endif - - //////////////////////// - // TEST7: Main test // - //////////////////////// - - //Creation correct Read/Write MedFieldDriver22 - MED_FIELD_RDWR_DRIVER *aMedRdWrFieldDriver22 = - new MED_FIELD_RDWR_DRIVER(filename_rdwr, aField_2); - - //Check driver - CPPUNIT_ASSERT(aMedRdWrFieldDriver22); - - //Trying read/write field before open file - CPPUNIT_ASSERT_THROW(aMedRdWrFieldDriver22->read(),MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aMedRdWrFieldDriver22->write(),MEDEXCEPTION); - - //Test open() method - try - { - aMedRdWrFieldDriver22->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //#ifdef ENABLE_FORCED_FAILURES - //Trying open file secondary. - //CPPUNIT_ASSERT_THROW(aMedRdWrFieldDriver22->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aMedRdWrFieldDriver22->open()); - // (BUG) No exception in this case - //#endif - - //Trying read field from file if field name is empty - CPPUNIT_ASSERT_THROW(aMedRdFieldDriver22->read(), MEDEXCEPTION); - - //Test setFieldName() and getFieldName - try - { - aMedRdWrFieldDriver22->setFieldName(fileldnotexist); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT_EQUAL(fileldnotexist, aMedRdWrFieldDriver22->getFieldName()); - - //Trying read not existing field from file - CPPUNIT_ASSERT_THROW(aMedRdWrFieldDriver22->read(), MEDEXCEPTION); - - //Test read() method - aMedRdWrFieldDriver22->setFieldName(fieldnameDouble); - try - { - aMedRdWrFieldDriver22->read(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Trying write field in the file with empty name - aField_2->setName(emptyfilename); - aMedRdWrFieldDriver22->setFieldName(emptyfilename); - CPPUNIT_ASSERT_THROW(aMedRdWrFieldDriver22->write(), MEDEXCEPTION); - - //Test write() method - aField_2->setName(fieldnameDouble_cpy); - aMedRdWrFieldDriver22->setFieldName(fieldnameDouble_cpy); - try - { - aMedRdWrFieldDriver22->write(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test close() method - try - { - aMedRdWrFieldDriver22->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Default constructor - MED_FIELD_RDWR_DRIVER aMedRdWrFieldDriver22Cpy_1; - - //Test (void operator =) defined in GENDRIVER class - aMedRdWrFieldDriver22Cpy_1 = *aMedRdWrFieldDriver22; - - //Test (bool operator ==) defined in GENDRIVER class - CPPUNIT_ASSERT(aMedRdWrFieldDriver22Cpy_1.GENDRIVER::operator==(*aMedRdWrFieldDriver22)); - - //Test copy constructor - MED_FIELD_RDWR_DRIVER aMedRdWrFieldDriver22Cpy_2 (*aMedRdWrFieldDriver22); - CPPUNIT_ASSERT_EQUAL(aMedRdWrFieldDriver22Cpy_2, *aMedRdWrFieldDriver22); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream rwostr1, rwostr2; - rwostr1 << aMedRdWrFieldDriver22Cpy_1; - rwostr2 << aMedRdWrFieldDriver22Cpy_2; - CPPUNIT_ASSERT(rwostr1.str() != ""); - CPPUNIT_ASSERT(rwostr1.str() == rwostr2.str()); - - /////////////////////////////////////////////////////////////////////////////////// - // Test for the issue 0021211. Check that a support of partial field - // (group or family) is restored at reading - { - string filenameRDWR = makeTmpFile("filenameRDWR.med"); - aRemover.Register(filenameRDWR); - - MESH* mesh = new MESH(MED_DRIVER, filenameWithOutFileds, "Mesh 1"); - mesh->setName("UniqueMeshName"); - //mesh->setMeshDimension(3); need to make mdump work on 2D mesh in 3D space - - FAMILY* family = const_cast( mesh->getFamily( MED_EDGE, 1 )); - family->setName( healName( family->getName() )); - - // mesh is 2D, make a field on the 1st FAMILY of segments - FIELD* field = new FIELD( family, /*NumberOfComponents=*/1); - field->setName( "FieldOnFamily"); - field->setComponentsNames(&fileldnotexist); - field->setComponentsDescriptions(&fileldnotexist); - field->setMEDComponentsUnits(&fileldnotexist); - double* vals = const_cast( field->getValue() ); - const int nbVals = family->getNumberOfElements( MED_ALL_ELEMENTS ); - for ( int i = 0; i < nbVals; ++i ) vals[i] = i; - - // store the mesh and the field in a file - int drv = mesh->addDriver( MED_DRIVER, filenameRDWR, mesh->getName() ); - CPPUNIT_ASSERT_NO_THROW( mesh->write(drv) ); - drv = field->addDriver( MED_DRIVER, filenameRDWR, field->getName() ); - CPPUNIT_ASSERT_NO_THROW( field->write(drv) ); - - // Check 1) read the field back and check it's support - string familyName = family->getName(); - const SUPPORT* supOnAll = mesh->getSupportOnAll( family->getEntity() ); - FIELD* field2 = - new FIELD( supOnAll, MED_DRIVER, filenameRDWR, field->getName()); - const SUPPORT* support2 = field2->getSupport(); - CPPUNIT_ASSERT( support2 == family ); - CPPUNIT_ASSERT_EQUAL( familyName, support2->getName() ); // name must not change - - // Check 2) if a support with name corresponding to a profile is not found, - // the new SUPPORT must not have name "SupportOnAll_MED_entity" - ((FAMILY*)family)->setName("setName"); - FIELD* field3 = - new FIELD( supOnAll, MED_DRIVER, filenameRDWR, field->getName()); - const SUPPORT* support3 = field3->getSupport(); - CPPUNIT_ASSERT( support3 != family ); - CPPUNIT_ASSERT( support3->getName() != supOnAll->getName()); - - // delete - field->removeReference(); - field2->removeReference(); - field3->removeReference(); - mesh->removeReference(); - } - // End Test for the issue 0021211 - /////////////////////////////////////////////////////////////////////////////////// - - //Delete all objects - aField->removeReference(); - aField_1->removeReference(); - aField_2->removeReference(); - - delete aInvalidMedRdFieldDriver22_1; - delete aInvalidMedRdFieldDriver22_2; - delete aInvalidMedRdFieldDriver22_3; - delete aMedRdFieldDriver22; - - delete aInvalidMedWrFieldDriver22_1; - delete aInvalidMedWrFieldDriver22_2; - delete aInvalidMedWrFieldDriver22_3; - delete aInvalidMedWrFieldDriver22_4; - delete aMedWrFieldDriver22; - - delete aInvalidMedRdWrFieldDriver22_1; - delete aInvalidMedRdWrFieldDriver22_2; - delete aInvalidMedRdWrFieldDriver22_3; - delete aInvalidMedRdWrFieldDriver22_4; - delete aInvalidMedRdWrFieldDriver22_5; - delete aMedRdWrFieldDriver22; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_MedFileBrowser.cxx b/src/MEDMEMCppTest/MEDMEMTest_MedFileBrowser.cxx deleted file mode 100644 index 8570e6d75..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_MedFileBrowser.cxx +++ /dev/null @@ -1,285 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_MedFileBrowser.hxx" - -// #include -// #include - -#ifdef WIN32 -#include -#endif - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -// #30: MEDMEM_MedFileBrowser.hxx } MEDMEMTest_MedFileBrowser.cxx - -/*! - * Check methods defined in MEDMEM_MedFileBrowser.hxx: - * class MEDFILEBROWSER { - * (+) MEDFILEBROWSER(); - * (+) MEDFILEBROWSER (const string & fileName) throw (MEDEXCEPTION); - * (+) void readFileStruct(const string & fileName) throw (MEDEXCEPTION); - * (+) std::string getFileName() const; - * (+) int getNumberOfMeshes (void) const; - * (+) int getNumberOfFields (void) const; - * (+) void getMeshNames (string * meshNames) const throw (MEDEXCEPTION); - * (+) vector getMeshNames () const; - * (+) void getFieldNames (string * fieldNames) const throw (MEDEXCEPTION); - * (+) vector getFieldNames () const; - * (+) bool isStructuredMesh(const std::string & meshName) const throw (MEDEXCEPTION); - * (+) MED_EN::med_type_champ getFieldType (const std::string & fieldName) const throw (MEDEXCEPTION) ; - * (+) std::string getMeshName (const std::string & fieldName) const throw (MEDEXCEPTION) ; - * (+) vector getFieldIteration (const string & fieldName) const throw (MEDEXCEPTION); - * } - */ -namespace -{ - void check_bad_file( MEDFILEBROWSER& myMed ) - { - vector names(1); - CPPUNIT_ASSERT_EQUAL( 0, myMed.getNumberOfMeshes() ); - CPPUNIT_ASSERT_EQUAL( 0, myMed.getNumberOfFields() ); - CPPUNIT_ASSERT_NO_THROW( myMed.getMeshNames( & names[0] )); - CPPUNIT_ASSERT_NO_THROW( myMed.getFieldNames( & names[0] )); - CPPUNIT_ASSERT_THROW( myMed.isStructuredMesh( "meshName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( myMed.getFieldType( "fieldName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( myMed.getMeshName( "fieldName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( myMed.getFieldIteration( "" ), MEDEXCEPTION); - } -} -// CppUnit::assertion_traits<> to use CPPUNIT_ASSERT_EQUAL for VEC_DT_IT_ -namespace CppUnit -{ - struct EQ_DT_IT_ - { - bool operator() (const DT_IT_ &p1, const DT_IT_ &p2) const - { - return p1.dt == p2.dt && p1.it == p2.it; - } - }; - template <> - struct assertion_traits - { - static bool equal( MEDMEM::VEC_DT_IT_ x, MEDMEM::VEC_DT_IT_ y ) - { - return x.size() == y.size() && std::equal(x.begin(),x.end(), y.begin(), EQ_DT_IT_()); - } - - static std::string toString( const MEDMEM::VEC_DT_IT_& x ) - { - MEDMEM::STRING ost("{ "); - for ( unsigned i = 0; i < x.size(); ++i ) - ost << "{ " << x[i].dt << ", " << x[i].it << " }" << ( i+1==x.size() ? " " : ", "); - return ost << "}"; - } - }; -} - -void MEDMEMTest::testMedFileBrowser() -{ - string filename = getResourceFile("pointe.med"); - string filename_21 = getResourceFile("pointe_V21.med"); - string filename_inexist = "InexistentFile.med"; - string filename_otherFormat = getResourceFile("test_2D.sauve"); - - vector names; - - // 1. constructor MEDFILEBROWSER() - // -------------------------------- - MEDFILEBROWSER myMed; - check_bad_file( myMed ); - - // 2. Constructor MEDFILEBROWSER (const std::string & fileName) throw (MEDEXCEPTION) - // ---------------------------------------------------------------------------------- - - // Existent med file (pointe.med) - CPPUNIT_ASSERT_NO_THROW( MEDFILEBROWSER myMed( filename )); - - // Inexistent med file - CPPUNIT_ASSERT_THROW( MEDFILEBROWSER myMed( filename_inexist ), MEDEXCEPTION); - - // Unsupported version med file - CPPUNIT_ASSERT_THROW( MEDFILEBROWSER myMed( filename_21 ), MEDEXCEPTION); - - // Not med file - CPPUNIT_ASSERT_THROW( MEDFILEBROWSER myMed( filename_otherFormat ), MEDEXCEPTION); - - // 3. void readFileStruct(const std::string & fileName) throw (MEDEXCEPTION) - // -------------------------------------------------------------------------- - MEDFILEBROWSER pointe_med, empty_med, ko_med; - - // Inexistent med file - CPPUNIT_ASSERT_THROW( ko_med.readFileStruct( filename_inexist ), MEDEXCEPTION); - check_bad_file( ko_med ); - - // Unsupported version med file - CPPUNIT_ASSERT_THROW( ko_med.readFileStruct( filename_21 ), MEDEXCEPTION); - check_bad_file( ko_med ); - - // Not med file - CPPUNIT_ASSERT_THROW( ko_med.readFileStruct( filename_otherFormat ), MEDEXCEPTION); - check_bad_file( ko_med ); - - // Existent med file (pointe.med) - CPPUNIT_ASSERT_NO_THROW( pointe_med.readFileStruct( filename )); - - // 4. std::string getFileName() const - // ------------------------------------ - CPPUNIT_ASSERT( empty_med.getFileName().empty() ); - - CPPUNIT_ASSERT_EQUAL( filename_otherFormat, ko_med.getFileName() ); - - CPPUNIT_ASSERT_EQUAL( filename, pointe_med.getFileName() ); - - // 5. int getNumberOfMeshes ( void ) const - // ---------------------------------------- - int nbMeshes; - CPPUNIT_ASSERT_NO_THROW( nbMeshes = empty_med.getNumberOfMeshes()); - CPPUNIT_ASSERT_EQUAL( 0, nbMeshes ); - CPPUNIT_ASSERT_NO_THROW( nbMeshes = ko_med.getNumberOfMeshes()); - CPPUNIT_ASSERT_EQUAL( 0, nbMeshes ); - CPPUNIT_ASSERT_NO_THROW( nbMeshes = pointe_med.getNumberOfMeshes()); - CPPUNIT_ASSERT_EQUAL( 1, nbMeshes ); - - // 6. int getNumberOfFields ( void ) const; - // ------------------------------------------------ - int nbFields; - CPPUNIT_ASSERT_NO_THROW( nbFields = empty_med.getNumberOfFields()); - CPPUNIT_ASSERT_EQUAL( 0, nbFields ); - CPPUNIT_ASSERT_NO_THROW( nbFields = ko_med.getNumberOfFields()); - CPPUNIT_ASSERT_EQUAL( 0, nbFields ); - CPPUNIT_ASSERT_NO_THROW( nbFields = pointe_med.getNumberOfFields()); - CPPUNIT_ASSERT_EQUAL( 4, nbFields ); - - // 7. void getMeshNames ( std::string * meshNames ) const; - // ------------------------------------------------------------------- - names.resize(2,""); - string emptyStr, maa1("maa1"); - - CPPUNIT_ASSERT_NO_THROW( empty_med.getMeshNames( & names[0] )); - CPPUNIT_ASSERT_EQUAL( emptyStr, names[0] ); - CPPUNIT_ASSERT_NO_THROW( ko_med.getMeshNames( & names[0] )); - CPPUNIT_ASSERT_EQUAL( emptyStr, names[0] ); - CPPUNIT_ASSERT_NO_THROW( pointe_med.getMeshNames( & names[0] )); - CPPUNIT_ASSERT_EQUAL( maa1, names[0] ); - CPPUNIT_ASSERT_EQUAL( emptyStr, names[1] ); - - //8. void getFieldNames ( std::string * fieldNames ) const; - // ------------------------------------------------------------------- - names.clear(); - names.resize(5,""); - string - fieldcelldoublescalar("fieldcelldoublescalar"), - fieldcelldoublevector("fieldcelldoublevector" ), - fieldnodedouble("fieldnodedouble" ), - fieldnodeint("fieldnodeint" ); - - - CPPUNIT_ASSERT_NO_THROW( empty_med.getFieldNames( & names[0] )); - CPPUNIT_ASSERT_EQUAL( emptyStr, names[0] ); - CPPUNIT_ASSERT_NO_THROW( ko_med.getFieldNames( & names[0] )); - CPPUNIT_ASSERT_EQUAL( emptyStr, names[0] ); - CPPUNIT_ASSERT_NO_THROW( pointe_med.getFieldNames( & names[0] )); - CPPUNIT_ASSERT_EQUAL( fieldcelldoublescalar, names[0] ); - CPPUNIT_ASSERT_EQUAL( fieldcelldoublevector, names[1] ); - CPPUNIT_ASSERT_EQUAL( fieldnodedouble , names[2] ); - CPPUNIT_ASSERT_EQUAL( fieldnodeint , names[3] ); - CPPUNIT_ASSERT_EQUAL( emptyStr, names[4] ); - - //9. std::vector< std::string > getMeshNames () const; - // ---------------------------------------------------- - CPPUNIT_ASSERT_NO_THROW( names = empty_med.getMeshNames() ); - CPPUNIT_ASSERT_EQUAL(0, int( names.size() )); - CPPUNIT_ASSERT_NO_THROW( names = ko_med.getMeshNames() ); - CPPUNIT_ASSERT_EQUAL(0, int( names.size() )); - CPPUNIT_ASSERT_NO_THROW( names = pointe_med.getMeshNames() ); - CPPUNIT_ASSERT_EQUAL(1, int( names.size() )); - CPPUNIT_ASSERT_EQUAL(maa1, names[0] ); - - // 10. std::vector< std::string > getFieldNames() const; - // ------------------------------------------------------ - CPPUNIT_ASSERT_NO_THROW( names = empty_med.getFieldNames() ); - CPPUNIT_ASSERT_EQUAL(0, int( names.size() )); - CPPUNIT_ASSERT_NO_THROW( names = ko_med.getFieldNames() ); - CPPUNIT_ASSERT_EQUAL(0, int( names.size() )); - CPPUNIT_ASSERT_NO_THROW( names = pointe_med.getFieldNames() ); - CPPUNIT_ASSERT_EQUAL(4, int( names.size() )); - CPPUNIT_ASSERT_EQUAL( fieldcelldoublescalar, names[0] ); - CPPUNIT_ASSERT_EQUAL( fieldcelldoublevector, names[1] ); - CPPUNIT_ASSERT_EQUAL( fieldnodedouble , names[2] ); - CPPUNIT_ASSERT_EQUAL( fieldnodeint , names[3] ); - - // 11. bool isStructuredMesh(const std::string & meshName) const throw (MEDEXCEPTION); - // ------------------------------------------------------------------------------------ - - CPPUNIT_ASSERT_THROW( empty_med. isStructuredMesh( "meshName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( ko_med. isStructuredMesh( "meshName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( pointe_med.isStructuredMesh( "meshName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW( pointe_med.isStructuredMesh( "maa1" )); - CPPUNIT_ASSERT( !pointe_med.isStructuredMesh( "maa1" )); - - // 12. med_type_champ getFieldType (const string & fieldName) const throw (MEDEXCEPTION) ; - // ---------------------------------------------------------------------------------------- - CPPUNIT_ASSERT_THROW( empty_med.getFieldType( "fieldName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( pointe_med.getFieldType( "fieldName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW( pointe_med.getFieldType( "fieldnodeint" )); - CPPUNIT_ASSERT_EQUAL( MED_REEL64, pointe_med.getFieldType( "fieldcelldoublescalar" )); - CPPUNIT_ASSERT_EQUAL( MED_REEL64, pointe_med.getFieldType( "fieldcelldoublevector" )); - CPPUNIT_ASSERT_EQUAL( MED_INT32, pointe_med.getFieldType( "fieldnodeint" )); - - // 13. string getMeshName (const std::string & fieldName) const throw (MEDEXCEPTION) ; - // ------------------------------------------------------------------------------------ - CPPUNIT_ASSERT_THROW( empty_med.getMeshName( "fieldnodeint" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( ko_med.getMeshName( "fieldnodeint" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( pointe_med.getMeshName( "fieldName" ), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW( pointe_med.getMeshName( "fieldnodeint" )); - names = pointe_med.getFieldNames(); - for ( unsigned i = 0; i < names.size(); ++i ) - CPPUNIT_ASSERT_EQUAL( maa1, pointe_med.getMeshName( names[i] )); - - // 14. VEC_DT_IT_ getFieldIteration (const std::string & fieldName) const throw (MEDEXCEPTION) - // --------------------------------------------------------------------------------------------- - CPPUNIT_ASSERT_THROW( empty_med.getFieldIteration( "fieldnodeint" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( ko_med.getFieldIteration( "fieldnodeint" ), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( pointe_med.getFieldIteration( "" ), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW( pointe_med.getFieldIteration( "fieldnodeint" )); - - VEC_DT_IT_ vec1dtit( 1 ); - vec1dtit[0].dt = -1; - vec1dtit[0].it = -1; - CPPUNIT_ASSERT_EQUAL( vec1dtit, pointe_med.getFieldIteration( "fieldcelldoublescalar" ) ); - CPPUNIT_ASSERT_EQUAL( vec1dtit, pointe_med.getFieldIteration( "fieldcelldoublevector" ) ); - CPPUNIT_ASSERT_EQUAL( vec1dtit, pointe_med.getFieldIteration( "fieldnodeint" ) ); - VEC_DT_IT_ vec3dtit( 3, vec1dtit[0] ); - vec3dtit[1].dt = 1; - vec3dtit[2].dt = 2; - CPPUNIT_ASSERT_EQUAL( vec3dtit, pointe_med.getFieldIteration( "fieldnodedouble" ) ); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_MedMeshDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_MedMeshDriver.cxx deleted file mode 100644 index 5ce596041..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_MedMeshDriver.cxx +++ /dev/null @@ -1,520 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -/*! - * Check methods (13), defined in MEDMEM_MedMeshDriver.hxx: - * class MED_MESH_DRIVER { - * (+) MED_MESH_DRIVER(); - * (+) MED_MESH_DRIVER(const string & fileName, MESH * ptrMesh, MED_EN::med_mode_acces accessMode); - * (+) MED_MESH_DRIVER(const MED_MESH_DRIVER22 & driver); - * (+) virtual ~MED_MESH_DRIVER(); - * (+) void open(); - * (+) void close(); - * } - * class MED_MESH_RDONLY_DRIVER : public virtual MED_MESH_DRIVER, - * { - * (+) MED_MESH_RDONLY_DRIVER(); - * (+) MED_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) MED_MESH_RDONLY_DRIVER(const MED_MESH_RDONLY_DRIVER & driver); - * (+) virtual ~MED_MESH_RDONLY_DRIVER(); - * (+) void read (void); - * } - * class MED_MESH_WRONLY_DRIVER : public virtual MED_MESH_DRIVER - * { - * (+) MED_MESH_WRONLY_DRIVER(); - * (+) MED_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) MED_MESH_WRONLY_DRIVER(const MED_MESH_WRONLY_DRIVER & driver); - * (+) virtual ~MED_MESH_WRONLY_DRIVER(); - * (+) void write(void) const; - * } - * class MED_MESH_RDWR_DRIVER : public MED_MESH_RDONLY_DRIVER, public MED_MESH_WRONLY_DRIVER - * { - * (+) MED_MESH_RDWR_DRIVER(); - * (+) MED_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) MED_MESH_RDWR_DRIVER(const MED_MESH_RDWR_DRIVER & driver); - * (+) ~MED_MESH_RDWR_DRIVER(); - * (+) void write(void) const; - * (+) void read (void); - * } - */ -void MEDMEMTest::testMedMeshDriver() -{ - MESH *aMesh = new MESH; - MESH *aMesh_1 = new MESH; - - string filename_rd = getResourceFile("pointe.med"); - string filename_wr = makeTmpFile("myWr_pointe22.med"); - string tmpfile = makeTmpFile("tmp.med"); - string meshname = "maa1"; - string newmeshname = "new" + meshname; - string fileNotExistsName_rd = "notExists.med"; - string fileNotExistsName_wr = "/path_not_exists/file_not_exists.med"; - string filename_rdwr = makeTmpFile("myRdWr_pointe22.med", filename_rd); - char* longmeshname = new char[MED_NAME_SIZE+2]; - for (int i = 0; iopen(), MEDEXCEPTION); - - //Creation a correct read only driver (normal constructor) - MED_MESH_RDONLY_DRIVER *aRdDriver22 = new MED_MESH_RDONLY_DRIVER(filename_rd, aMesh); - - //Check driver - CPPUNIT_ASSERT(aRdDriver22); - - //Trying read mesh from file, if file is not open - CPPUNIT_ASSERT_THROW(aRdDriver22->read(), MEDEXCEPTION); - - //Test open() method - try - { - aRdDriver22->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //#ifdef ENABLE_FORCED_FAILURES - //Trying open file secondary. - //CPPUNIT_ASSERT_THROW(aRdDriver22->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aRdDriver22->open()); - //This case is not work, seems it BUG - //#endif - - //Trying read mesh from file, if mesh name is not set, i.e. empty - CPPUNIT_ASSERT_THROW(aRdDriver22->read(), MEDEXCEPTION); - - //Trying read mesh from file with very long name - aRdDriver22->setMeshName(longmeshname); - CPPUNIT_ASSERT_THROW(aRdDriver22->read(), MEDEXCEPTION); - - //Set correct Mesh name - //Test setMeshName() and getMeshName() methods - try - { - aRdDriver22->setMeshName(meshname); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_EQUAL(meshname, aRdDriver22->getMeshName()); - - - //Test read() method - try - { - aRdDriver22->read(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test write() method for READ ONLY driver - CPPUNIT_ASSERT_THROW(aRdDriver22->write(), MEDEXCEPTION); - - //Check Mesh - CPPUNIT_ASSERT(aMesh); - - //Default constructor - MED_MESH_RDONLY_DRIVER aRdDriver22Cpy_1; - - //Test (void operator =) defined in GENDRIVER class in MEDMEM_GenDriver.hxx - //aRdDriver22Cpy_1 = *aRdDriver22; - - //Test (bool operator ==) defined GENDRIVER class in MEDMEM_GenDriver.hxx - CPPUNIT_ASSERT(aRdDriver22Cpy_1.GENDRIVER::operator==(*aRdDriver22)); - - //Test copy constructor - MED_MESH_RDONLY_DRIVER aRdDriver22Cpy_2 (aRdDriver22Cpy_1); - CPPUNIT_ASSERT_EQUAL(aRdDriver22Cpy_2, *aRdDriver22); - - //Test close() method - try - { - aRdDriver22->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Trying read mesh from copy closed driver - CPPUNIT_ASSERT_THROW(aRdDriver22Cpy_1.read(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aRdDriver22Cpy_2.read(), MEDEXCEPTION); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream rostr1, rostr2; - rostr1<open(), MEDEXCEPTION); - - //Trying write empty mesh - MED_MESH_WRONLY_DRIVER *aTmpWrDriver22 = new MED_MESH_WRONLY_DRIVER(tmpfile, aMesh_1); - - //#ifdef ENABLE_FORCED_FAILURES - aTmpWrDriver22->open(); - aTmpWrDriver22->setMeshName("EmptyMesh"); - CPPUNIT_ASSERT_THROW(aTmpWrDriver22->write(),MEDEXCEPTION); - aTmpWrDriver22->close(); - //Unknown exception in this case - //#endif - - //Creation a correct write only driver - MED_MESH_WRONLY_DRIVER *aWrDriver22 = new MED_MESH_WRONLY_DRIVER(filename_wr, aMesh); - - //Check driver - CPPUNIT_ASSERT(aWrDriver22); - - //Trying write mesh to file, if file is not open - CPPUNIT_ASSERT_THROW(aWrDriver22->write(), MEDEXCEPTION); - - //Test open() method - try - { - aWrDriver22->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //#ifdef ENABLE_FORCED_FAILURES - //Trying open file secondary. - //CPPUNIT_ASSERT_THROW(aWrDriver22->open(), MEDEXCEPTION); - //This case is not work, seems it BUG - //#endif - - //Test case: trying write mesh to file, if mesh name is not set, i.e empty - aMesh->setName(""); - aWrDriver22->setMeshName(""); - CPPUNIT_ASSERT_THROW(aWrDriver22->write(), MEDEXCEPTION); - - //Trying write mesh to file with very long name - aWrDriver22->setMeshName(longmeshname); - CPPUNIT_ASSERT_THROW(aWrDriver22->write(), MEDEXCEPTION); - - //Set initialy mesh name - aMesh->setName(meshname); - //Test setMeshName() and getMeshName() methods - try - { - aWrDriver22->setMeshName(meshname); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_EQUAL(meshname, aWrDriver22->getMeshName()); - - // aWrDriver22->open(); - //Test write() method - try - { - aWrDriver22->write(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test read() method for WRITE ONLY driver - CPPUNIT_ASSERT_THROW(aWrDriver22->read(), MEDEXCEPTION); - - //Default constructor - MED_MESH_WRONLY_DRIVER aWrDriver22Cpy_1; - - //Test (void operator =) defined in GENDRIVER class - //aWrDriver22Cpy_1 = *aWrDriver22; - - //Test (bool operator ==) defined GENDRIVER class - CPPUNIT_ASSERT(aWrDriver22Cpy_1.GENDRIVER::operator==(*aWrDriver22)); - - //Test copy constructor - MED_MESH_WRONLY_DRIVER aWrDriver22Cpy_2 (aWrDriver22Cpy_1); - CPPUNIT_ASSERT_EQUAL(aWrDriver22Cpy_2 , *aWrDriver22); - - try - { - aWrDriver22->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test case: Trying write mesh using copy closed driver - CPPUNIT_ASSERT_THROW(aWrDriver22Cpy_1.write(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aWrDriver22Cpy_2.write(), MEDEXCEPTION); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream wostr1, wostr2; - wostr1<open(), MEDEXCEPTION); - - //Creation a correct read/write driver - MED_MESH_RDWR_DRIVER *aRdWrDriver22 = new MED_MESH_RDWR_DRIVER(filename_rdwr, aMesh_1); - - //Check driver - CPPUNIT_ASSERT(aRdWrDriver22); - - //Test case: trying write mesh to file, if file is not open - CPPUNIT_ASSERT_THROW(aRdWrDriver22->write(), MEDEXCEPTION); - - //Test case: trying read mesh from file, if file is not open - CPPUNIT_ASSERT_THROW(aRdWrDriver22->read(), MEDEXCEPTION); - - //Test open() method - try - { - aRdWrDriver22->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //#ifdef ENABLE_FORCED_FAILURES - //Test case: trying open file secondary. - //CPPUNIT_ASSERT_THROW(aRdWrDriver22->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aRdWrDriver22->open()); - //This case is not work, seems it BUG - //#endif - - //#ifdef ENABLE_FORCED_FAILURES - //Set mesh name - aMesh_1->setName("EmptyMesh"); - aRdWrDriver22->setMeshName("EmptyMesh"); - //Trying write in file empty mesh - CPPUNIT_ASSERT_THROW(aRdWrDriver22->write(),MEDEXCEPTION); - //No exception in this case, seems it BUG - //#endif - - //Set initialy mesh name - aMesh_1->setName(meshname); - //Test setMeshName() and getMeshName() methods - try - { - aRdWrDriver22->setMeshName(meshname); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_EQUAL(meshname, aRdWrDriver22->getMeshName()); - - //Test read() method - try - { - aRdWrDriver22->read(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Trying read mesh from file, if mesh name is not set, i.e. empty - aRdWrDriver22->setMeshName(""); - aMesh_1->setName(""); - CPPUNIT_ASSERT_THROW(aRdWrDriver22->read(), MEDEXCEPTION); - - //Trying write mesh to file, if mesh name is not set, i.e empty - CPPUNIT_ASSERT_THROW(aRdWrDriver22->write(), MEDEXCEPTION); - - //Trying read mesh from file with very long name - aRdWrDriver22->setMeshName(longmeshname); - aMesh_1->setName(longmeshname); - CPPUNIT_ASSERT_THROW(aRdWrDriver22->read(), MEDEXCEPTION); - - //Trying write mesh to file with very long name - CPPUNIT_ASSERT_THROW(aRdWrDriver22->write(), MEDEXCEPTION); - - //Test write() method - aRdWrDriver22->setMeshName(newmeshname); - aMesh_1->setName(newmeshname); - try - { - aRdWrDriver22->write(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Check Mesh - CPPUNIT_ASSERT(aMesh_1); - - //Default constructor - MED_MESH_RDWR_DRIVER aRdWrDriver22Cpy_1; - - //Test (void operator =) defined in GENDRIVER class - aRdWrDriver22Cpy_1= *aRdWrDriver22; - - //Test (bool operator ==) defined GENDRIVER class - CPPUNIT_ASSERT(aRdWrDriver22Cpy_1.GENDRIVER::operator==(*aRdWrDriver22)); - - //Test copy constructor - MED_MESH_RDWR_DRIVER aRdWrDriver22Cpy_2 (aRdWrDriver22Cpy_1); - // CPPUNIT_ASSERT(aRdWrDriver22Cpy_2.GENDRIVER::operator==( *aRdWrDriver22)); - - try - { - aRdWrDriver22->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test case: trying read/write mesh using copy closed driver - CPPUNIT_ASSERT_THROW(aRdWrDriver22Cpy_1.read(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aRdWrDriver22Cpy_2.read(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aRdWrDriver22Cpy_1.write(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aRdWrDriver22Cpy_2.write(), MEDEXCEPTION); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream rwostr1, rwostr2; - rwostr1<removeReference(); - aMesh_1->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_MedVersion.cxx b/src/MEDMEMCppTest/MEDMEMTest_MedVersion.cxx deleted file mode 100644 index 155e028a1..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_MedVersion.cxx +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include - -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (not in spec), defined in MEDMEM_MedVersion.hxx: - * (+) MED_EN::medFileVersion getMedFileVersion(const string & fileName) throw (MEDEXCEPTION); - * (+) int getMedAccessMode(MED_EN::med_mode_acces mode, - * MED_EN::medFileVersion medVersion) throw (MEDEXCEPTION); - */ - -void MEDMEMTest::testMedVersion() -{ - string filename = getResourceFile("pointe_nomorereadable21.med"); - string notExistFileName = "anyfile"; - medFileVersion myFileVersion; - - // Test - getMedFileVersion - CPPUNIT_ASSERT_THROW(getMedFileVersion(notExistFileName),MEDEXCEPTION); - - CPPUNIT_ASSERT_NO_THROW(myFileVersion = getMedFileVersion(filename)); - CPPUNIT_ASSERT(myFileVersion == V21); - -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing.cxx b/src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing.cxx deleted file mode 100644 index 5da395012..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing.cxx +++ /dev/null @@ -1,2204 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Grid.hxx" - -#include -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -static void addMedFacesGroup (MESHING& meshing, int nFaces, const int *groupValue, - string groupName, const MED_EN::medGeometryElement *mytypes, - const int *index, const int *myNumberOfElements, int nbOfGeomTypes) -{ - GROUP *faces=new GROUP; - faces->setName(groupName); - faces->setMesh(&meshing); - faces->setEntity(MED_EN::MED_FACE); - faces->setNumberOfGeometricType(nbOfGeomTypes); - faces->setGeometricType(mytypes); - faces->setNumberOfElements(myNumberOfElements); - faces->setNumber(index, groupValue); - meshing.addGroup(*faces); - faces->removeReference(); -} - -/*! - * Check methods (12), defined in MEDMEM_Meshing.hxx: - * class MESHING: public MESH -{ - * (+) MESHING(); - * (+) ~MESHING(); - * (+) void setCoordinates (const int SpaceDimension, const int NumberOfNodes, - * const double * Coordinates, - * const string System, const MED_EN::medModeSwitch Mode); - * (+) void setCoordinatesNames (const string * names); - * (+) void setCoordinateName (const string name, const int i); - * (+) void setCoordinatesUnits (const string * units); - * (+) void setCoordinateUnit (const string unit, const int i); - * (+) void setNumberOfTypes (const int NumberOfTypes, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setTypes (const MED_EN::medGeometryElement * Types, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setNumberOfElements (const int * NumberOfElements, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setConnectivity (const int * Connectivity, const MED_EN::medEntityMesh Entity, - * const MED_EN::medGeometryElement Type, - * const int * PolyConnectivityIndex=0) throw (MEDEXCEPTION); - * (+) void addGroup (const GROUP & Group) throw (MEDEXCEPTION); - * -} - */ - -/*! - * Check methods (67), defined in MEDMEM_Mesh.hxx: - * class MESH : public RCBASE -{ - * (+) void init(); - * (+) MESH(); - * (+) MESH(MESH &m); - * (+) MESH & operator=(const MESH &m); - * (+) virtual bool operator==(const MESH& other) const; - * (+) virtual bool deepCompare(const MESH& other) const; - * (+) MESH(driverTypes driverType, const string & fileName="", - * const string & meshName="") throw (MEDEXCEPTION); - * (+) virtual ~MESH(); - * (+) friend ostream & operator<<(ostream &os, const MESH &my); - * (+) int addDriver(driverTypes driverType, - * const string & fileName="Default File Name.med", - * const string & driverName="Default Mesh Name", - * MED_EN::med_mode_acces access=MED_EN::MED_REMP); - * (+) int addDriver(GENDRIVER & driver); - * (+) void rmDriver(int index=0); - * (+) virtual void read(int index=0); - * (+) inline void read(const GENDRIVER & genDriver); - * (+) inline void write(int index=0); - * (+) inline void write(const GENDRIVER & genDriver, - * MED_EN::med_mode_acces medMode=MED_EN::WRONLY); - * (+) inline void write(driverTypes driverType, - * const std::string& filename, - * const std::string& meshname="", - * MED_EN::med_mode_acces medMode=MED_EN::WRONLY) const; - * (+) inline void setName(string name); - * (+) inline void setDescription(string description); - * (+) inline string getName() const; - * (+) inline string getDescription() const; - * (+) inline int getSpaceDimension() const; - * (+) inline int getMeshDimension() const; - * (+) inline bool getIsAGrid(); - * (+) inline int getNumberOfNodes() const; - * (+) virtual inline const COORDINATE * getCoordinateptr() const; - * (+) inline string getCoordinatesSystem() const; - * (+) virtual inline const double * getCoordinates(MED_EN::medModeSwitch Mode) const; - * (+) virtual inline const double getCoordinate(int Number,int Axis) const; - * (+) inline const string * getCoordinatesNames() const; - * (+) inline const string * getCoordinatesUnits() const; - * (+) virtual inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const CELLMODEL * getCellsTypes(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline string * getCellTypeNames(MED_EN::medEntityMesh Entity) const; - * (+) virtual const int * getGlobalNumberingIndex(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline int getNumberOfElements(MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type) const; - * (+) virtual inline bool existConnectivity(MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity) const; - * (+) virtual inline MED_EN::medGeometryElement getElementType - * (MED_EN::medEntityMesh Entity, int Number) const; - * (+) virtual inline void calculateConnectivity(MED_EN::medModeSwitch Mode, - * MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity) const; - * (+) virtual inline int getConnectivityLength(MED_EN::medModeSwitch Mode, - * MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type) const; - * (+) virtual inline const int * getConnectivity(MED_EN::medModeSwitch Mode, - * MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type) const; - * (+) virtual inline const int * getConnectivityIndex - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity) const; - * (+) virtual int getElementNumber(MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type, - * int * connectivity) const; - * (+) virtual inline int getReverseConnectivityLength - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual inline const int * getReverseConnectivity - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual inline int getReverseConnectivityIndexLength - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual inline const int * getReverseConnectivityIndex - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual int getNumberOfFamilies(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const vector getFamilies(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const FAMILY* getFamily(MED_EN::medEntityMesh Entity,int i) const; - * (+) virtual int getNumberOfGroups(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const vector getGroups(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const GROUP* getGroup(MED_EN::medEntityMesh Entity,int i) const; - * (+) virtual inline const CONNECTIVITY* getConnectivityptr() const; - * (+) virtual SUPPORT * getBoundaryElements(MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION); - * (+) virtual FIELD* getVolume (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getArea (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getLength (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getNormal (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getBarycenter (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) static SUPPORT * mergeSupports(const vector Supports) throw (MEDEXCEPTION); - * (+) static SUPPORT * intersectSupports(const vector Supports) throw (MEDEXCEPTION); - * (+) void createFamilies(); - * (+) SUPPORT *buildSupportOnNodeFromElementList - * (const list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); - * (do the same thing as buildSupportOnNodeFromElementList except that a SUPPORT is not created) void fillSupportOnNodeFromElementList - * (const list& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION); - * (+) SUPPORT *buildSupportOnElementsFromElementList - * (const list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); - * (+) int getElementContainingPoint(const double *coord); - * (+) vector< vector > getBoundingBox() const; - * (+) template static - * FIELD * mergeFields(const vector< FIELD * > & others, bool meshCompare=false); - * (Presently disconnected in C++) virtual void addReference() const; - * (Presently disconnected in C++) virtual void removeReference() const; - * -} - */ -void MEDMEMTest::testMeshAndMeshing() -{ - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - string filenameout21 = makeTmpFile("myMeshWrite4_pointe21.med"); - string filename_profiles_wr = makeTmpFile("myMedProfilesFieldfile.med"); - string filenameout = makeTmpFile("out.med"); - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filenameout21); - aRemover.Register(filename_profiles_wr); - aRemover.Register(filenameout); - - //////////// - // TEST 1 // - //////////// - - MESH * myMesh= new MESH(); - myMesh->setName("FIRST_MESH"); - CPPUNIT_ASSERT(myMesh != NULL); - - //test operator << - { - ostringstream out; - CPPUNIT_ASSERT_NO_THROW(out << *myMesh << endl); - } - - //test operator = - MESH *myMesh1 =new MESH( *myMesh); - - //deepCompare - bool isEqual = false; - CPPUNIT_ASSERT_NO_THROW(isEqual = myMesh1->deepCompare(*myMesh)); - CPPUNIT_ASSERT(isEqual); - myMesh1->removeReference(); - - //ensure it imposible to compare meshes - MESH *myMeshPointer = myMesh; - //test operator == - CPPUNIT_ASSERT(*myMeshPointer == *myMesh); - - myMesh->removeReference(); - - //set a MESH object - MESHING *myMeshing=new MESHING; - myMeshing->setName("meshing"); - // define coordinates - - int SpaceDimension = 3; - int NumberOfNodes = 19; - double Coordinates[57] = - { - 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 2.0, 0.0, 1.0, - 0.0, 2.0, 1.0, - -2.0, 0.0, 1.0, - 0.0, -2.0, 1.0, - 1.0, 1.0, 2.0, - -1.0, 1.0, 2.0, - -1.0, -1.0, 2.0, - 1.0, -1.0, 2.0, - 1.0, 1.0, 3.0, - -1.0, 1.0, 3.0, - -1.0, -1.0, 3.0, - 1.0, -1.0, 3.0, - 1.0, 1.0, 4.0, - -1.0, 1.0, 4.0, - -1.0, -1.0, 4.0, - 1.0, -1.0, 4.0, - 0.0, 0.0, 5.0 - }; - try - { - myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - string Names[3] = - { - "X","Y","Z" - }; - try - { - myMeshing->setCoordinatesNames(Names); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - string Units[3] = - { - "cm","cm","cm" - }; - try - { - myMeshing->setCoordinatesUnits(Units); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // define conectivities - - // cell part - - const int NumberOfTypes = 3; - medGeometryElement Types[NumberOfTypes] = - { - MED_TETRA4,MED_PYRA5,MED_HEXA8 - }; - const int NumberOfElements[NumberOfTypes] = - { - 12,2,2 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL)); - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setTypes(Types,MED_CELL)); - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfElements(NumberOfElements,MED_CELL)); - - const int sizeTetra = 12*4; - int ConnectivityTetra[sizeTetra]= - { - 1,2,3,6, - 1,2,4,3, - 1,2,5,4, - 1,2,6,5, - 2,7,4,3, - 2,8,5,4, - 2,9,6,5, - 2,10,3,6, - 2,7,3,10, - 2,8,4,7, - 2,9,5,8, - 2,10,6,9 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity(MED_CELL,MED_TETRA4,ConnectivityTetra)); - - int ConnectivityPyra[2*5]= - { - 7,8,9,10,2, - 15,18,17,16,19 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity(MED_CELL,MED_PYRA5,ConnectivityPyra)); - - int ConnectivityHexa[2*8]= - { - 11,12,13,14,7,8,9,10, - 15,16,17,18,11,12,13,14 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity(MED_CELL,MED_HEXA8,ConnectivityHexa)); - - // face part - const int NumberOfFacesTypes = 2; - medGeometryElement FacesTypes[NumberOfFacesTypes] = - { - MED_TRIA3,MED_QUAD4 - }; - const int NumberOfFacesElements[NumberOfFacesTypes] = - { - 4,4 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfTypes(NumberOfFacesTypes,MED_FACE)); - CPPUNIT_ASSERT_NO_THROW(myMeshing->setTypes(FacesTypes,MED_FACE)); - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfElements(NumberOfFacesElements,MED_FACE)); - const int nbTria = 4; - const int sizeTria = nbTria*3; - int ConnectivityTria[sizeTria]= - { - 1,4,3, - 1,5,4, - 1,6,5, - 1,3,6 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity(MED_FACE,MED_TRIA3,ConnectivityTria)); - const int nbQua = 4; - int ConnectivityQua[nbQua*4]= - { - 7,8,9,10, - 11,12,13,14, - 11,7,8,12, - 12,8,9,13 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity(MED_FACE,MED_QUAD4,ConnectivityQua)); - - int meshDimension = SpaceDimension; // because there 3D cells in the mesh - //CPPUNIT_ASSERT_NO_THROW(myMeshing->setMeshDimension(meshDimension)); - - // edge part - - // not yet implemented : if set, results are unpredictable. - - // Some groups : - - // Node : - { - GROUP *myGroup=new GROUP; - myGroup->setName("SomeNodes"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_NODE); - myGroup->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_NONE - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 4 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,5 - }; - const int value[4]= - { - 1,4,5,7 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - { - GROUP *myGroup=new GROUP; - myGroup->setName("OtherNodes"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_NODE); - myGroup->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_NONE - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 3 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,4 - }; - const int value[3]= - { - 2,3,6 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - - // Cell : - { - GROUP *myGroup=new GROUP; - myGroup->setName("SomeCells"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_CELL); - myGroup->setNumberOfGeometricType(3); - medGeometryElement myTypes[3] = - { - MED_TETRA4,MED_PYRA5,MED_HEXA8 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[3] = - { - 4,1,2 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[3+1] = - { - 1,5,6,8 - }; - const int value[4+1+2]= - { - 2,7,8,12, - 13, - 15,16 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - { - GROUP *myGroup=new GROUP; - myGroup->setName("OtherCells"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_CELL); - myGroup->setNumberOfGeometricType(2); - medGeometryElement myTypes[] = - { - MED_TETRA4,MED_PYRA5 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[] = - { - 4,1 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[2+1] = - { - 1,5,6 - }; - const int value[4+1]= - { - 3,4,5,9, - 14 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - - // Face : - { - GROUP *myGroup=new GROUP; - myGroup->setName("SomeFaces"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_FACE); - myGroup->setNumberOfGeometricType(2); - medGeometryElement myTypes[2] = - { - MED_TRIA3,MED_QUAD4 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[2] = - { - 2,3 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[2+1] = - { - 1,3,6 - }; - const int value[2+3]= - { - 2,4, - 5,6,8 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - { - GROUP *myGroup=new GROUP; - myGroup->setName("OtherFaces"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_FACE); - myGroup->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_TRIA3 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 2 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,3 - }; - const int value[2]= - { - 1,3 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - - //test Mesh(MESH &m) - { - MESH * myMesh2 = new MESH( *myMeshing ); - CPPUNIT_ASSERT(myMesh2->deepCompare(*myMeshing)); - myMeshing->removeReference(); - //cout<<*myMesh2<getName(),(string)"meshing"); - CPPUNIT_ASSERT((myMesh2->getDescription()).size() == 0); - myMesh2->setDescription("This class contains all information related to a 'meshing' mesh "); - CPPUNIT_ASSERT((myMesh2->getDescription()).size() != 0); - - CPPUNIT_ASSERT(myMesh2->getSpaceDimension() == SpaceDimension); - CPPUNIT_ASSERT(myMesh2->getMeshDimension() == meshDimension); - CPPUNIT_ASSERT(myMesh2->getNumberOfNodes() == NumberOfNodes); - - const COORDINATE* coord = myMesh2->getCoordinateptr(); - try - { - CPPUNIT_ASSERT(myMesh2->getCoordinatesSystem() != "catresian"); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const string * units; - try - { - units = myMesh2->getCoordinatesUnits(); - for (int axe = 0; axe < SpaceDimension; axe++) - { - string verif = coord->getCoordinateUnit(axe+1); - CPPUNIT_ASSERT(verif == units[axe]); - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const string * noms; - try - { - noms = myMesh2->getCoordinatesNames(); - for (int axe = 0; axe < SpaceDimension; axe++) - { - string verif = coord->getCoordinateName(axe+1); - CPPUNIT_ASSERT(verif == noms[axe]); - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - const double * coor2 = myMesh2->getCoordinates(MED_FULL_INTERLACE); - - for (int axe = 0; axe < SpaceDimension; axe++) - { - try - { - for (int num = 0; num < NumberOfNodes; num++) - { - try - { - const double d = myMesh2->getCoordinate(num + 1, axe + 1); - CPPUNIT_ASSERT(fabs(d - coor2[(num * SpaceDimension)+axe]) < 0.001); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const CONNECTIVITY * myConnectivity = myMesh2->getConnectivityptr(); - - // MED_EN::MED_CELL - MED_EN::medEntityMesh entity = myConnectivity->getEntity(); - CPPUNIT_ASSERT_EQUAL(MED_CELL, entity); - - int typesNb; - CPPUNIT_ASSERT_NO_THROW(typesNb= myConnectivity->getNumberOfTypes(entity)); - CPPUNIT_ASSERT_EQUAL(NumberOfTypes, typesNb); - - const MED_EN::medGeometryElement * Types1; - CPPUNIT_ASSERT_NO_THROW(Types1 = myMesh2->getTypes(entity)); - - medConnectivity myMedConnect; - bool existConnect = false; - if (myMesh2->existConnectivity(MED_NODAL, entity)) - { - existConnect = true; - myMedConnect = MED_NODAL; - } - else if(myMesh2->existConnectivity(MED_DESCENDING, entity)) - { - existConnect = true; - myMedConnect = MED_DESCENDING; - } - - for(int t = 0; t < NumberOfTypes; t++ ) - { - CPPUNIT_ASSERT_EQUAL(Types1[t], Types[t]); - int NumberOfElements1 = 0; - CPPUNIT_ASSERT_NO_THROW(NumberOfElements1 = myMesh2->getNumberOfElements(entity, Types1[t])); - CPPUNIT_ASSERT_EQUAL(NumberOfElements1, NumberOfElements[t]); - if(existConnect) - { - ostringstream out; - const int * connectivity; - const int * connectivity_index; - CPPUNIT_ASSERT_NO_THROW(connectivity = myMesh2->getConnectivity (myMedConnect, entity, Types1[t])); - connectivity_index = myMesh2->getConnectivityIndex(myMedConnect, entity); - for (int j = 0; j < NumberOfElements1; j++) - { - out<<"!!!!!!!!!!!!!!!"<getCellsTypes(entity); - string* TypeNames; - CPPUNIT_ASSERT_NO_THROW(TypeNames = myMesh2->getCellTypeNames(entity)); - - for(int k = 0; k < NumberOfTypes; k++ ) - { - CPPUNIT_ASSERT_EQUAL(TypeNames[k], myCellModel[k].getName()); - } - delete [] TypeNames; - - const int* myGlobalNbIdx; - CPPUNIT_ASSERT_NO_THROW(myGlobalNbIdx = myMesh2->getGlobalNumberingIndex(MED_FACE)); - for(int i = 0; i <= NumberOfFacesTypes; i++) - { - if(i == NumberOfFacesTypes) - { - CPPUNIT_ASSERT_EQUAL(myGlobalNbIdx[i],nbTria+nbQua+1); - CPPUNIT_ASSERT_THROW(myMesh2->getElementType(MED_FACE, myGlobalNbIdx[i]), MEDEXCEPTION); - break; - } - //cout<<"Global number of first element of each geom type : "<setNumberOfNodes(NumberOfNodes); - - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivity = myMesh2->getReverseConnectivity(MED_NODAL, entity)); - CPPUNIT_ASSERT_NO_THROW(myMesh2->getReverseConnectivityLength(MED_NODAL, entity)); - const int * ReverseNodalConnectivityIndex = myMesh2->getReverseConnectivityIndex(MED_NODAL, entity); - const int ReverseIdxLength = myMesh2->getReverseConnectivityIndexLength(MED_NODAL, entity); - CPPUNIT_ASSERT(ReverseIdxLength == NumberOfNodes+1); - ostringstream out; - for (int i = 0; i < NumberOfNodes; i++) - { - out << "Node "<< i+1 << " : "; - for (int j = ReverseNodalConnectivityIndex[i]; j < ReverseNodalConnectivityIndex[i+1]; j++) - out << ReverseNodalConnectivity[j-1] << " "; - out << endl; - } - - // Show Descending Connectivity - int NumberOfElements1; - const int * connectivity; - const int * connectivity_index; - myMesh2->calculateConnectivity( MED_DESCENDING, entity); - try - { - NumberOfElements1 = myMesh2->getNumberOfElements(entity, MED_ALL_ELEMENTS); - connectivity = myMesh2->getConnectivity( MED_DESCENDING, entity, MED_ALL_ELEMENTS); - connectivity_index = myMesh2->getConnectivityIndex(MED_DESCENDING, entity); - } - catch (MEDEXCEPTION m) - { - CPPUNIT_FAIL(m.what()); - } - - for (int j = 0; j < NumberOfElements1; j++) - { - out << "Element " << j+1 << " : "; - for (int k = connectivity_index[j]; k < connectivity_index[j+1]; k++) - out << connectivity[k-1] << " "; - out << endl; - } - - // getElementNumber - if (myMesh2->existConnectivity(MED_NODAL, MED_FACE)) - { - int myTr[3] = - { - 1,5,4 - }; - CPPUNIT_ASSERT_NO_THROW(myMesh2->getElementNumber(MED_NODAL,MED_FACE,MED_TRIA3,myTr)); - } - } - - //test family and group - int NumberOfGroups; - CPPUNIT_ASSERT_THROW(myMesh2->getNumberOfGroups(MED_ALL_ENTITIES), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(NumberOfGroups = myMesh2->getNumberOfGroups(MED_CELL)); - CPPUNIT_ASSERT_EQUAL(NumberOfGroups, 2); - vector groups; - CPPUNIT_ASSERT_NO_THROW(groups = myMesh2->getGroups(MED_CELL)); - CPPUNIT_ASSERT(groups.size() != 0); - for(int nb = 1; nb <= NumberOfGroups; nb++ ) - { - const GROUP* group; - CPPUNIT_ASSERT_NO_THROW(group = myMesh2->getGroup(MED_CELL, nb)); - CPPUNIT_ASSERT_EQUAL(group->getName(), groups[nb-1]->getName()); - } - - int NumberOfFamilies; - CPPUNIT_ASSERT_NO_THROW(NumberOfFamilies = myMesh2->getNumberOfFamilies(MED_CELL)); - CPPUNIT_ASSERT_MESSAGE("Current mesh hasn't Families", NumberOfFamilies == 0); - - //create families - it's not possible to create, becase not all entities are defined - // EAP: the problem has been fixed for ENSIGHT Industrialization project - CPPUNIT_ASSERT_NO_THROW( myMesh2->createFamilies() ); - - /*CPPUNIT_ASSERT_NO_THROW(NumberOfFamilies = myMesh2->getNumberOfFamilies(MED_CELL)); - CPPUNIT_ASSERT( NumberOfFamilies != 0);*/ - - myMesh2->removeReference(); - } - - ////////////////////////////////////////////////////////////// - // TEST 2: Polygon and Polyhedron(only NODAL connectivity) // - ///////////////////////////////////////////////////////////// - - double CoordinatesPoly[57] = - { - 2.0, 3.0, 2.0, - 3.0, 2.0, 2.0, - 4.0, 1.0, 2.0, - 2.0, 0.0, 2.0, - 0.0, 1.0, 2.0, - 1.0, 2.0, 2.0, - 2.0, 3.0, 1.0, - 3.0, 2.0, 0.0, - 4.0, 1.0, 0.0, - 2.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, 2.0, 0.0, - 5.0, 3.0, 2.0, - 7.0, 2.0, 2.0, - 6.0, 0.0, 2.0, - 6.0, 3.0, 0.0, - 7.0, 2.0, 0.0, - 6.0, 0.0, -1.0, - 5.0, 1.0, -3.0 - }; - - const int REFnodalConnOfFaces[91] = - { - 1, 2, 3, 4, 5, 6, -1,// Polyhedron 1 - 1, 7, 8, 2, -1, - 2, 8, 9, 3, -1, - 4, 3, 9, 10, -1, - 5, 4, 10, 11, -1, - 6, 5, 11, 12, -1, - 1, 6, 12, 7, -1, - 7, 12, 8, 10, -1, - 9, 8, 12, 11, - - 13, 14, 15, 3, 2, -1,// Polyhedron 2 - 13, 2, 8, 16, -1, - 14, 13, 16, 17, -1, - 15, 14, 17, 15, -1, - 17, 18, 15, -1, - 18, 9, 3, -1, - 15, 9, 2, -1, - 3, 9, 8, -1, - 8, 9, 17, 16, -1, - 9, 18, 17 - }; - const int NumberOfFaces = 19; - const int NumberOfPolyhedron = 2; - const int nbOfPolygons = 2; - const int REFpolyIndex[NumberOfPolyhedron+1] = - { - 1,47,92 - }; - - double PolygonCoordinates[27] = - { - 2.0, 3.0, 12.0, - 3.0, 2.0, 12.0, - 4.0, 1.0, 12.0, - 2.0, 0.0, 12.0, - 0.0, 1.0, 12.0, - 1.0, 2.0, 12.0, - 5.0, 3.0, 12.0, - 7.0, 2.0, 12.0, - 6.0, 0.0, 12.0 - }; - - const int REFpolygonFaces[11] = - { - 1, 2, 3, 4, 5, 6, // Polygon 1 - 7, 8, 9, 3, 2 // Polygon 2 - }; - - const int REFpolygonIndex[nbOfPolygons+1] = - { - 1, 7, 12 - }; - - MESHING *myMeshingPoly=new MESHING; - myMeshingPoly->setName("meshingpoly"); - - const int NbOfTypes = 2; - medGeometryElement TypesPoly[NbOfTypes] = - { - MED_TETRA4, MED_POLYHEDRA - }; - const int NbOfElements[NbOfTypes] = - { - 1,2 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setNumberOfTypes(NbOfTypes, MED_CELL)); - - CPPUNIT_ASSERT_NO_THROW - (myMeshingPoly->setCoordinates(SpaceDimension, NumberOfNodes, CoordinatesPoly, - "CARTESIAN", MED_FULL_INTERLACE)); - - //CPPUNIT_ASSERT_NO_THROW( myMeshingPoly->setSpaceDimension(SpaceDimension)); - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setTypes(TypesPoly, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setNumberOfElements(NbOfElements, MED_CELL)); - - string Unit ="cm"; - for(int i = 0; i < SpaceDimension; i++ ) - { - CPPUNIT_ASSERT_NO_THROW( myMeshingPoly->setCoordinateName(Names[i],i) ); - CPPUNIT_ASSERT_NO_THROW( myMeshingPoly->setCoordinateUnit(Unit, i) ); - } - - int ConnectivityTetraPoly[4*1]= - { - 17, 9, 18, 19 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setConnectivity(MED_CELL, MED_TETRA4,ConnectivityTetraPoly)); - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setConnectivity(MED_CELL, MED_POLYHEDRA,REFnodalConnOfFaces,REFpolyIndex)); - - bool PolyConn = false; - CPPUNIT_ASSERT_NO_THROW(PolyConn = myMeshingPoly->existConnectivity(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(PolyConn); - { - CPPUNIT_ASSERT_EQUAL(NumberOfPolyhedron, - myMeshingPoly->getNumberOfElements(MED_CELL,MED_POLYHEDRA)); - CPPUNIT_ASSERT_NO_THROW( myMeshingPoly->calculateConnectivity (MED_NODAL,MED_FACE)); - CPPUNIT_ASSERT_EQUAL(NumberOfFaces-1, myMeshingPoly->getNumberOfElements(MED_FACE,MED_POLYGON)); // -1: one face is shared with tetra - CPPUNIT_ASSERT_EQUAL(91,myMeshingPoly->getConnectivityLength(MED_NODAL,MED_CELL,MED_POLYHEDRA)); - const int * PolyConn; - const int * PolyIdx; - CPPUNIT_ASSERT_NO_THROW(PolyConn = myMeshingPoly->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_NO_THROW(PolyIdx = myMeshingPoly->getConnectivityIndex(MED_NODAL,MED_CELL)); - for(int i = NbOfElements[0], iRef=0; isetName("PolygonMeshing"); - - medGeometryElement PolygonTypes[NbOfTypes] = - { - MED_TRIA3,MED_POLYGON - }; - const int PolygonNumberOfElements[NbOfTypes] = - { - 2,nbOfPolygons - }; - - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setNumberOfTypes(NbOfTypes, MED_CELL)); - - try - { - myPolygonMeshing->setCoordinates(SpaceDimension, NumberOfNodes, PolygonCoordinates, - "CARTESIAN", MED_FULL_INTERLACE); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_EQUAL(SpaceDimension, myPolygonMeshing->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(NumberOfNodes, myPolygonMeshing->getNumberOfNodes()); - - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setTypes(PolygonTypes, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setNumberOfElements(PolygonNumberOfElements, MED_CELL)); - CPPUNIT_ASSERT_EQUAL(2, myPolygonMeshing->getMeshDimension()); - - try - { - myPolygonMeshing->setCoordinatesNames(Names); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myPolygonMeshing->setCoordinatesUnits(Units); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const int sizeTri = 3*2; - int ConnectivityTri[sizeTri]= - { - 1, 7, 2, 3, 9, 4 - }; - - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setConnectivity(MED_CELL, MED_TRIA3,ConnectivityTri)); - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setConnectivity(MED_CELL, MED_POLYGON,REFpolygonFaces, REFpolygonIndex)); - - bool PolygonConn = false; - CPPUNIT_ASSERT_NO_THROW(PolygonConn = myPolygonMeshing->existConnectivity(MED_NODAL, MED_CELL)); - if(PolygonConn) - { - int Polytypes; - CPPUNIT_ASSERT_NO_THROW(Polytypes = myPolygonMeshing->getNumberOfTypes(MED_CELL)); - CPPUNIT_ASSERT_EQUAL(NbOfTypes,Polytypes); - - const MED_EN::medGeometryElement * PolyTypes; - CPPUNIT_ASSERT_NO_THROW(PolyTypes = myPolygonMeshing->getTypes(MED_CELL)); - CPPUNIT_ASSERT_EQUAL(PolyTypes[NbOfTypes-1],MED_POLYGON); - - for(int t = 0; t < Polytypes; t++) - { - CPPUNIT_ASSERT_NO_THROW( myPolygonMeshing->getNumberOfElements(MED_CELL, PolyTypes[t])); - } - medGeometryElement geomPolyElem; - CPPUNIT_ASSERT_NO_THROW(geomPolyElem = myPolygonMeshing->getElementType(MED_CELL, 1)); - CPPUNIT_ASSERT_EQUAL(MED_TRIA3,geomPolyElem); - - CPPUNIT_ASSERT_EQUAL(myPolygonMeshing->getNumberOfElements(MED_CELL,MED_POLYGON),nbOfPolygons); - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->getConnectivityLength(MED_NODAL,MED_CELL,MED_POLYGON)); - myPolygonMeshing->removeReference(); - const int * PolygonConn; - CPPUNIT_ASSERT_THROW(PolygonConn = myMeshingPoly->getConnectivity(MED_NODAL,MED_CELL,MED_POLYGON),MEDEXCEPTION); - } - myMeshingPoly->removeReference(); - //////////////////////////////////////////////////////////// - // TEST : SUPPORT* sup = myMeshPointe->getSupportOnAll()) // - //////////////////////////////////////////////////////////// - { - MESH * myMeshPointe = new MESH(MED_DRIVER, filename, meshname); - const SUPPORT* sup = myMeshPointe->getSupportOnAll(MED_CELL); - CPPUNIT_ASSERT( sup->isOnAllElements() ); - CPPUNIT_ASSERT_EQUAL( myMeshPointe->getNumberOfTypes( sup->getEntity() ), - sup->getNumberOfTypes()); - CPPUNIT_ASSERT( sup->getNumber( MED_ALL_ELEMENTS )); - myMeshPointe->removeReference(); - } - - //////////////////////////////////////////////////////// - // TEST 3: test MESH on MEDMEMTest::createTestMesh()// - /////////////////////////////////////////////////////// - - MESH* myMesh3 = MEDMEMTest_createTestMesh(); - - int MeshDim = myMesh3->getMeshDimension(); - medEntityMesh constituentEntity; - if (MeshDim==3) - { - constituentEntity = MED_CELL; - } - if (MeshDim==2) - { - constituentEntity = MED_FACE; - } - if (MeshDim==1) - { - constituentEntity = MED_EDGE; - } - - int SpaceDim = myMesh3->getSpaceDimension(); - - // Show Reverse Nodal Connectivity - const int* ReverseNodalConnectivity; - const int* ReverseNodalConnectivityIndex; - int ReverseLength; - int ReverseIdxLength; - - CONNECTIVITY* myConnectivity3 = (CONNECTIVITY*)myMesh3->getConnectivityptr(); - myConnectivity3->setNumberOfNodes(myMesh3->getNumberOfNodes()); - - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivity= myMesh3->getReverseConnectivity(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(ReverseLength = myMesh3->getReverseConnectivityLength(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivityIndex = myMesh3->getReverseConnectivityIndex(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(ReverseIdxLength = myMesh3->getReverseConnectivityIndexLength(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(ReverseIdxLength == myMesh3->getNumberOfNodes()+1); - - ostringstream out; - for (int i = 0; i < myMesh3->getNumberOfNodes(); i++) - { - out << "Node "<< i+1 << " : "; - for (int j = ReverseNodalConnectivityIndex[i]; j < ReverseNodalConnectivityIndex[i+1]; j++) - out << ReverseNodalConnectivity[j-1] << " "; - out << endl; - } - - // Show Descending Connectivity - int NumberOfElements1; - const int * connectivity; - const int * connectivity_index; - myMesh3->calculateConnectivity(MED_DESCENDING, MED_EN::MED_CELL); - try - { - NumberOfElements1 = myMesh3->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - connectivity = myMesh3->getConnectivity( MED_DESCENDING, MED_CELL, MED_ALL_ELEMENTS); - connectivity_index = myMesh3->getConnectivityIndex(MED_DESCENDING, MED_CELL); - } - catch (MEDEXCEPTION m) - { - CPPUNIT_FAIL(m.what()); - } - - for (int j = 0; j < NumberOfElements1; j++) - { - out << "Element " << j+1 << " : "; - for (int k = connectivity_index[j]; k < connectivity_index[j+1]; k++) - out << connectivity[k-1] << " "; - out << endl; - } - - //test 3D mesh - for(int ind = SpaceDim; ind > 1; ind-- ) - { - int NumberOfElem = myMesh3->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS); - if(NumberOfElem < 1) continue; - - const SUPPORT * sup = myMesh3->getSupportOnAll( constituentEntity ); - - if (ind == 2) - { - // test of normal(for 1d or 2d elements) - FIELD* normal; - CPPUNIT_ASSERT_NO_THROW(normal = myMesh3->getNormal(sup)); - - const int nbNormVals = 47*3; - double refNormals[nbNormVals] = - { - 0, 1, 0 ,// #1 - -1, 0, 0 ,// #2 - -0, 0, 2 ,// #3 - 1, -1, -2 ,// #4 - -1, 0, 0 ,// #5 - 0, 0, 2 ,// #6 - 1, 1, -2 ,// #7 - 0, -1, 0 ,// #8 - 0, -0, 2 ,// #9 - -1, 1, -2 , // #10 - 0, 0, 2 , // #11 - -1, -1, -2 , // #12 - -1, 0, 1 , // #13 - 0, -1, 1 , // #14 - 1, 1, 0 , // #15 - 0, -1, 1 , // #16 - 1, -0, 1 , // #17 - -1, 1, 0 , // #18 - 1, 0, 1 , // #19 - 0, 1, 1 , // #20 - -1, -1, 0 , // #21 - -0, 1, 1 , // #22 - -1, 0, 1 , // #23 - 1, -1, 0 , // #24 - -1, 0, 1 , // #25 - 1, 0, 1 , // #26 - 0, -1, 1 , // #27 - -0, 1, 1 , // #28 - 1, 0, 1 , // #29 - -1, 0, 1 , // #30 - 0, 1, 1 , // #31 - 0, -1, 1 , // #32 - 1, 0, 1 , // #33 - 0, -1, 1 , // #34 - -1, 0, 1 , // #35 - -0, 1, 1 , // #36 - 0, 0, 4 , // #37 - -0, -0, -4 , // #38 - 0, 0, 4 , // #39 - 0, 2, 0 , // #40 - -2, -0, -0 , // #41 - 0, -2, 0 , // #42 - 2, -0, 0 , // #43 - 0, 2, 0 , // #44 - -2, -0, -0 , // #45 - 0, -2, 0 , // #46 - 2, -0, 0 // #47 - }; - for ( int i = 0; i < nbNormVals; ++i ) - CPPUNIT_ASSERT_DOUBLES_EQUAL( refNormals[i], normal->getValue()[i], 1e-6); - // double normal_square, norm; - // double maxnorm=0.; - // double minnorm=0.; - // double tmp_value; - // for (int i = 1; i<=NumberOfElem; i++) { - // normal_square = 0.; - // cout << "Normal " << i << " "; - // for (int j=1; j<=SpaceDim; j++) { - // tmp_value = normal->getValueIJ(i,j); - // normal_square += tmp_value*tmp_value; - // cout << tmp_value << " "; - // } - // norm = sqrt(normal_square); - // maxnorm = dmax(maxnorm,norm); - // minnorm = dmin(minnorm,norm); - // cout << ", Norm = " << norm << endl; - // } - // cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl; - delete normal; - - // test of area(for 2d elements) - FIELD* area; - CPPUNIT_ASSERT_NO_THROW(area = myMesh3->getArea(sup)); - - // double maxarea,minarea,areatot; - // maxarea = 0.; - // minarea = 0.; - // areatot = 0.0; - // for (int i = 1; i<=NumberOfElem;i++) - // { - // cout << "Area " << i << " " << area->getValueIJ(i,1) << endl; - // maxarea = dmax(maxarea,area->getValueIJ(i,1)); - // minarea = dmin(minarea,area->getValueIJ(i,1)); - // areatot = areatot + area->getValueIJ(i,1); - // } - - // cout << "Max Area " << maxarea << " Min Area " << minarea << endl; - // cout << "Support Area " << areatot << endl; - const int nbAreas = 47; - double refArea [nbAreas] = - { - 1, 1, 2, 2.44949, 1, 2, 2.44949, 1, 2, 2.44949, 2, 2.44949, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 1.41421, 4, 4, 4, 2, 2, 2, 2, 2, 2, 2, 2 - }; - for ( int i = 0; i < nbAreas; ++i ) - CPPUNIT_ASSERT_DOUBLES_EQUAL( refArea[i], area->getValue()[i], 1e-5); - delete area; - } - - // test of barycenter(for 3d and 2d elements) - FIELD* barycenter; - CPPUNIT_ASSERT_NO_THROW(barycenter = myMesh3->getBarycenter(sup)); - - CPPUNIT_ASSERT_NO_THROW(NumberOfElem = myMesh3->getNumberOfElements(constituentEntity,MED_ALL_ELEMENTS)); - if ( ind == 3 ) - { - double refBC[16*3] = - { - 0.5, -0.5, 0.75 ,// #1 - 0.5, 0.5, 0.75 ,// #2 - -0.5, 0.5, 0.75 ,// #3 - -0.5, -0.5, 0.75 ,// #4 - 0.75, 0.75, 1.25 ,// #5 - -0.75, 0.75, 1.25 ,// #6 - -0.75, -0.75, 1.25 ,// #7 - 0.75, -0.75, 1.25 ,// #8 - 1, 0, 1.5 ,// #9 - 0, 1, 1.5 , // #10 - -1, 0, 1.5 , // #11 - 0, -1, 1.5 , // #12 - 0, 0, 1.8 , // #13 - 0, 0, 4.2 , // #14 - 0, 0, 2.5 , // #15 - 0, 0, 3.5 , // #16 - }; - for ( int i = 0; i < 16*3; ++i ) - CPPUNIT_ASSERT_DOUBLES_EQUAL( refBC[i], barycenter->getValue()[i], 1e-6); - } - if ( ind == 2 ) - { - double refBC[47*3] = - { - 0.666667, 0, 0.666667 ,// #1 - 0, -0.666667, 0.666667 ,// #2 - 0.666667, -0.666667, 1 ,// #3 - 0.666667, -0.666667, 0.666667 ,// #4 - 0, 0.666667, 0.666667 ,// #5 - 0.666667, 0.666667, 1 ,// #6 - 0.666667, 0.666667, 0.666667 ,// #7 - -0.666667, 0, 0.666667 ,// #8 - -0.666667, 0.666667, 1 ,// #9 - -0.666667, 0.666667, 0.666667 , // #10 - -0.666667, -0.666667, 1 , // #11 - -0.666667, -0.666667, 0.666667, // #12 - 0.333333, 1, 1.33333 , // #13 - 1, 0.333333, 1.33333 , // #14 - 1, 1, 1.33333 , // #15 - -1, 0.333333, 1.33333 , // #16 - -0.333333, 1, 1.33333 , // #17 - -1, 1, 1.33333 , // #18 - -0.333333, -1, 1.33333 , // #19 - -1, -0.333333, 1.33333 , // #20 - -1, -1, 1.33333 , // #21 - 1, -0.333333, 1.33333 , // #22 - 0.333333, -1, 1.33333 , // #23 - 1, -1, 1.33333 , // #24 - 0.666667, 0, 1.66667 , // #25 - 1.33333, 0, 1.66667 , // #26 - 0, 0.666667, 1.66667 , // #27 - 0, 1.33333, 1.66667 , // #28 - -0.666667, 0, 1.66667 , // #29 - -1.33333, 0, 1.66667 , // #30 - 0, -0.666667, 1.66667 , // #31 - 0, -1.33333, 1.66667 , // #32 - 0.666667, 0, 4.33333 , // #33 - 0, -0.666667, 4.33333 , // #34 - -0.666667, 0, 4.33333 , // #35 - 0, 0.666667, 4.33333 , // #36 - 0, 0, 2 , // #37 - 0, 0, 4 , // #38 - 0, 0, 3 , // #39 - 0, 1, 2.5 , // #40 - -1, 0, 2.5 , // #41 - 0, -1, 2.5 , // #42 - 1, 0, 2.5 , // #43 - 0, 1, 3.5 , // #44 - -1, 0, 3.5 , // #45 - 0, -1, 3.5 , // #46 - 1, 0, 3.5 , // #47 - }; - for ( int i = 0; i < 47*3; ++i ) - { - CPPUNIT_ASSERT_DOUBLES_EQUAL( refBC[i], barycenter->getValue()[i], 1e-5); - } - } - // for (int i = 1; i<=NumberOfElem;i++) - // { - // cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) << endl; - // } - - delete barycenter; - - // test of volume(for 3d elements) - if (ind == 3) - { - FIELD* volume; - CPPUNIT_ASSERT_NO_THROW(volume= myMesh3->getVolume(sup)); - - // double maxvol,minvol,voltot; - // maxvol = 0.; - // minvol = 0.; - // voltot = 0.0; - // for (int i = 1; i<=NumberOfElem;i++) - // { - // cout << "Volume " << i << " " << volume->getValueIJ(i,1) << endl; - // maxvol = dmax(maxvol,volume->getValueIJ(i,1)); - // minvol = dmin(minvol,volume->getValueIJ(i,1)); - // voltot = voltot + volume->getValueIJ(i,1); - // } - - // cout << "Max Volume " << maxvol << " Min Volume " << minvol << endl; - // cout << "Support Volume " << voltot << endl; - - double refVol[16] = - { - 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 0.666667, 1.333333, 1.333333, 4, 4 - }; - for ( int i = 0; i < 16; ++i ) - CPPUNIT_ASSERT_DOUBLES_EQUAL( refVol[i], volume->getValue()[i], 1e-6); - - delete volume; - - // test of skin - SUPPORT *skin; - CPPUNIT_ASSERT_NO_THROW(skin = myMesh3->getSkin(sup)); - - //test mergeSupports and intersectSupports. vactor contains only 1 elements - vector myVectSup; - myVectSup.push_back(skin); - - //method return a copy of skin object - SUPPORT *copyMergeSkin; - CPPUNIT_ASSERT_NO_THROW(copyMergeSkin = myMesh3->mergeSupports(myVectSup)); - try - { - CPPUNIT_ASSERT(copyMergeSkin->deepCompare(*skin)); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //method return a copy of skin object - SUPPORT *copyIntersectSkin; - CPPUNIT_ASSERT_NO_THROW(copyIntersectSkin = myMesh3->intersectSupports(myVectSup)); - try - { - CPPUNIT_ASSERT(copyIntersectSkin->deepCompare(*skin)); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - skin->removeReference(); - copyMergeSkin->removeReference(); - copyIntersectSkin->removeReference(); - } - constituentEntity++; - } - - // 0020911: [CEA 413] getBarycenter on polygons - { - MESHING* polygonMesh = new MESHING(); - MEDMEM::AutoDeref derefMesh( polygonMesh ); - - polygonMesh->setName("polygonMesh"); - - const int spaceDim = 2, nbNodes = 6; - const double coords[spaceDim*nbNodes] = - { - 0,0, 1,0, 2,0, 0,1, 1,1, 2,1 - }; - polygonMesh->setCoordinates( spaceDim, nbNodes, coords, "CART", MED_EN::MED_FULL_INTERLACE); - - const MED_EN::medGeometryElement type = MED_EN::MED_POLYGON; - polygonMesh->setNumberOfTypes(1, MED_EN::MED_CELL); - polygonMesh->setTypes( &type, MED_EN::MED_CELL ); - - const int nbPolygons = 2; - const int conn[nbPolygons*4] = - { - 1,2,5,4, 2,3,6,5 - }; - const int index[nbPolygons+1] = - { - 1,5,9 - }; - polygonMesh->setNumberOfElements( &nbPolygons, MED_EN::MED_CELL ); - polygonMesh->setConnectivity( MED_EN::MED_CELL, type, conn, index ); - - FIELD* barycenter; - const SUPPORT* sup = polygonMesh->getSupportOnAll(MED_CELL); - CPPUNIT_ASSERT_NO_THROW(barycenter = polygonMesh->getBarycenter(sup)); - CPPUNIT_ASSERT_EQUAL( 2, barycenter->getNumberOfValues() ); - CPPUNIT_ASSERT_EQUAL( 2, barycenter->getNumberOfComponents() ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, barycenter->getValueIJ(1,1), 1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, barycenter->getValueIJ(1,2), 1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 1.5, barycenter->getValueIJ(2,1), 1e-10); - CPPUNIT_ASSERT_DOUBLES_EQUAL( 0.5, barycenter->getValueIJ(2,2), 1e-10); - barycenter->removeReference(); - } - - - // Testing length and normal vectors on 1d elements - { - // coordinates - int NumberOfNodes3 = 4; - - string Names3[3] = - { - "X","Y","Z" - }; - string Units3[3] = - { - "cm","cm","cm" - }; - - double Coordinates3[4*2] = - { - 0.0, 0.0, // n1 - 1.0, 1.0, // n2 - 0.0, 1.0, // n3 - 1.0, 0.0 - }; // n4 - - const int NumberOfEdgeTypes = 1; - MED_EN::medGeometryElement EdgeTypes[NumberOfEdgeTypes] = - { - MED_SEG2 - }; - const int NumberOfEdges[NumberOfEdgeTypes] = - { - 4 - }; - int ConnectivityEdge[4*2] = - { - 1,2, 2,3, 3,4, 4,1 - }; - - // CREATE THE MESH - MEDMEM::MESHING* myMeshing3 = new MEDMEM::MESHING; - myMeshing3->setName("meshing3"); - myMeshing3->setCoordinates(/*SpaceDimension*/2, NumberOfNodes3, Coordinates3, - "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - myMeshing3->setCoordinatesNames(Names3); - myMeshing3->setCoordinatesUnits(Units3); - - // define connectivities - // cell part - const int NumberOfTypes3 = 1; - medGeometryElement Types3[NumberOfTypes3] = - { - MED_QUAD4 - }; - const int NumberOfElements3[NumberOfTypes3] = - { - 1 - }; - - myMeshing3->setNumberOfTypes(NumberOfTypes3,MED_CELL); - myMeshing3->setTypes(Types3,MED_CELL); - myMeshing3->setNumberOfElements(NumberOfElements3,MED_CELL); - - int Connectivityquad[1*4] = - { - 1,2,3,4 - }; - - myMeshing3->setConnectivity(MED_CELL,MED_QUAD4,Connectivityquad); - - myMeshing3->setNumberOfTypes(NumberOfEdgeTypes, MED_EDGE); - myMeshing3->setTypes(EdgeTypes, MED_EDGE); - myMeshing3->setNumberOfElements(NumberOfEdges, MED_EDGE); - - myMeshing3->setConnectivity( MED_EDGE, MED_SEG2,ConnectivityEdge); - - //test 2D mesh - //int NumberOfElem = myMeshing3->getNumberOfElements (MED_EDGE, MED_ALL_ELEMENTS); - - const SUPPORT * sup = myMeshing3->getSupportOnAll( MED_EDGE ); - - // test of normal(for 1d or 2d elements) - FIELD* normal; - CPPUNIT_ASSERT_NO_THROW(normal = myMeshing3->getNormal(sup)); - - // double normal_square, norm; - // double maxnorm=0.; - // double minnorm=0.; - // double tmp_value; - // for (int i = 1; i<=NumberOfElem; i++) { - // normal_square = 0.; - // cout << "Normal " << i << " "; - // for (int j=1; j<=/*SpaceDimension*/2; j++) { - // tmp_value = normal->getValueIJ(i,j); - // normal_square += tmp_value*tmp_value; - // cout << tmp_value << " "; - // } - // norm = sqrt(normal_square); - // maxnorm = dmax(maxnorm,norm); - // minnorm = dmin(minnorm,norm); - // cout << ", Norm = " << norm << endl; - // } - // cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl; - { - double refNormals[8] = - { - -1, 1 , - -0, -1, - 1, 1 , - -0, -1 - }; - for ( int i = 0; i < 8; ++i ) - CPPUNIT_ASSERT_DOUBLES_EQUAL( refNormals[i], normal->getValue()[i], 1e-6); - } - // test of length(for 1d elements) - FIELD* length; - CPPUNIT_ASSERT_NO_THROW(length = myMeshing3->getLength(sup)); - - // double length_value,maxlength,minlength; - // maxlength = 0; - // minlength = 0; - // for (int i = 1; i<=NumberOfElem;i++) { - // length_value = length->getValueIJ(i,1); - // cout << "Length " << i << " " << length_value << endl; - // maxlength = dmax(maxlength,length_value); - // minlength = dmin(minlength,length_value); - // } - // cout << "Max Length " << maxlength << " Min Length " << minlength << endl; - double refLen[4] = - { - 1.41421,1,1.41421,1 - }; - for ( int i = 0; i < 4; ++i ) - CPPUNIT_ASSERT_DOUBLES_EQUAL( refLen[i], length->getValue()[i], 1e-5); - - vector< FIELD *> myVectField1; - myVectField1.push_back(normal); - myVectField1.push_back(length); - CPPUNIT_ASSERT_NO_THROW(myMeshing3->mergeFields(myVectField1)->removeReference()); - - normal->removeReference(); - length->removeReference(); - { - vector myVectSupEmpty; - CPPUNIT_ASSERT_THROW(myMesh3->mergeSupports(myVectSupEmpty), MEDEXCEPTION); - } - - // test mergeFields method: Fields have the same value type - //intersectSupports and mergeSupports methods - { - SUPPORT * sup1 = new SUPPORT; - sup1->setMesh( myMeshing3 ); - sup1->setEntity( MED_EDGE ); - SUPPORT * sup2 = new SUPPORT; - sup2->setMesh( myMeshing3 ); - sup2->setEntity( MED_EDGE ); - MED_EN::medGeometryElement gtEdges[1] = - { - MED_SEG2 - }; - int nbEdges1[1] = - { - 1 - }; - int edges1[1] = - { - 1 - }; - int nbEdges2[1] = - { - 2 - }; - int edges2[2] = - { - 2,3 - }; - sup1->setpartial("description 1", 1, 1, gtEdges, nbEdges1, edges1); - sup2->setpartial("description 1", 1, 2, gtEdges, nbEdges2, edges2); - - vector myVectSup3; - myVectSup3.push_back(sup1); - myVectSup3.push_back(sup2); - //method return a MergeSup on the union of all SUPPORTs in Supports. - SUPPORT *MergeSup; - CPPUNIT_ASSERT_NO_THROW(MergeSup = myMesh3->mergeSupports(myVectSup3)); - { - ostringstream out; - out << *MergeSup << endl; - } - MergeSup->removeReference(); - - //method return a intersection of all SUPPORTs in IntersectSup - SUPPORT *IntersectSup; - CPPUNIT_ASSERT_NO_THROW(IntersectSup = myMesh3->intersectSupports(myVectSup3)); - { - ostringstream out; - if (IntersectSup != NULL) out<< *IntersectSup <removeReference(); - - FIELD * length1 = myMeshing3->getLength(sup1); - FIELD * length2 = myMeshing3->getLength(sup2); - - vector< FIELD *> myVect12; - myVect12.push_back(length1); - myVect12.push_back(length2); - - FIELD * length12; - CPPUNIT_ASSERT_NO_THROW(length12 = myMeshing3->mergeFields(myVect12)); - length12->removeReference(); - - sup1->removeReference(); - sup2->removeReference(); - length1->removeReference(); - length2->removeReference(); - } - myMeshing3->removeReference(); - } - myMesh3->removeReference(); - - ///////////////////////////////////////////////////////// - // TEST 4: test MESH constructed from file pointe.med // - //////////////////////////////////////////////////////// - MESH * myMesh4 = new MESH(); - myMesh4->setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver (filename, myMesh4); - myMeshDriver.setMeshName(meshname); - - //Mesh has no driver->segmentation violation - CPPUNIT_ASSERT_THROW(myMesh4->read(), MEDEXCEPTION); - - //Add an existing MESH driver. - int myDriver4; - CPPUNIT_ASSERT_NO_THROW(myDriver4 = myMesh4->addDriver(myMeshDriver)); - - //read all objects in the file - CPPUNIT_ASSERT_NO_THROW(myMesh4->read(myDriver4)); - - if (myMesh4->getIsAGrid()) - { - GRID* myGrid = dynamic_cast(myMesh4); - CPPUNIT_ASSERT(myGrid); - } - - //myDriver4->DRONLY->can't write - CPPUNIT_ASSERT_THROW(myMesh4->write(myDriver4), MEDEXCEPTION); - - // add new driver - int idMeshV21; - CPPUNIT_ASSERT_NO_THROW(idMeshV21 = myMesh4->addDriver(MED_DRIVER,filenameout21)); - - //Write all the content of the MESH using driver referenced by the integer handler index. - CPPUNIT_ASSERT_NO_THROW(myMesh4->write(idMeshV21)); - - // remove driver from mesh - CPPUNIT_ASSERT_NO_THROW(myMesh4->rmDriver(myDriver4)); - - // ensure exception is raised on second attempt to remove driver - CPPUNIT_ASSERT_THROW(myMesh4->rmDriver(myDriver4),MEDEXCEPTION); - - // Create a MESH object using a MESH driver of type MED_DRIVER associated with file fileName. - MESH* myMesh5; - CPPUNIT_ASSERT_NO_THROW(myMesh5 = new MESH(MED_DRIVER, filename, meshname)); - if(myMesh5->getIsAGrid()) - { - GRID* myGrid = dynamic_cast(myMesh4); - CPPUNIT_ASSERT(myGrid); - } - - //ensure two meshes constructed from one file in two different ways are equal - CPPUNIT_ASSERT(myMesh5->deepCompare(*myMesh4)); - - // test other variants of read() and write() - { - const string otherName1("otherName1"), otherName2("otherName2"); - MESH mesh1, mesh2, mesh3; - - //myMesh5 -> filenameout21 - // GMESH::write(driverTypes driverType, const string& filename,const string& meshname) - myMesh5->write( MED_DRIVER, filenameout21, otherName1); - CPPUNIT_ASSERT_THROW( myMesh5->write(myMeshDriver), MEDEXCEPTION); // write with RDONLY driver - - //filenameout21 -> mesh1 - // GMESH::read(driverTypes driverType, const string& filename, const string& meshname); - CPPUNIT_ASSERT_THROW( mesh1.read(VTK_DRIVER,filenameout21,otherName1), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW( mesh1.read(MED_DRIVER, filenameout21,otherName2), MEDEXCEPTION); - mesh1.read(MED_DRIVER,filenameout21,otherName1); - CPPUNIT_ASSERT(myMesh5->deepCompare(mesh1)); - - MED_MESH_RDWR_DRIVER driver; - driver.setFileName( filenameout21 ); - driver.setMeshName( otherName2 ); - - // mesh1 -> filenameout21 - // GMESH::write( const GENDRIVER& ) - mesh1.write( driver ); - - // filenameout21 -> mesh2 - // GMESH::read( const GENDRIVER& ) - mesh2.read( driver ); - CPPUNIT_ASSERT(myMesh5->deepCompare(mesh2)); - // check that GMESH::write() clears the file by default - CPPUNIT_ASSERT_THROW( mesh3.read( MED_DRIVER, filenameout21,otherName1), MEDEXCEPTION); - // write by adding a mesh - myMesh5->write( MED_DRIVER, filenameout21, otherName1, MED_EN::RDWR ); - CPPUNIT_ASSERT_NO_THROW( mesh3.read( MED_DRIVER, filenameout21,otherName1)); - } - - int myDriver6; - MESH* myMesh6 = new MESH(); - myDriver6 = myMesh6->addDriver(MED_DRIVER, filename, meshname, RDONLY); - - myMesh6->read(myDriver6); - - //ensure two meshes constracted from one file in two different ways are equal - CPPUNIT_ASSERT(myMesh6->deepCompare(*myMesh4)); - - //test FAMILY - int NumberOfFamilies4; - CPPUNIT_ASSERT_NO_THROW(NumberOfFamilies4 = myMesh6->getNumberOfFamilies(MED_CELL)); - CPPUNIT_ASSERT_MESSAGE("Current mesh hasn't Families", NumberOfFamilies4 != 0); - - vector families4; - CPPUNIT_ASSERT_NO_THROW(families4 = myMesh6->getFamilies(MED_CELL)); - CPPUNIT_ASSERT((int)families4.size() == NumberOfFamilies4); - for(int nb = 1; nb <= NumberOfFamilies4; nb++ ) - { - const FAMILY* family; - CPPUNIT_ASSERT_NO_THROW(family = myMesh6->getFamily(MED_CELL, nb)); - CPPUNIT_ASSERT_EQUAL(family->getName(), families4[nb-1]->getName()); - } - - //get support which reference all elements on the boundary of mesh. - SUPPORT*myBndSup; - CPPUNIT_ASSERT_THROW(myMesh6->getBoundaryElements(MED_CELL), MEDEXCEPTION); - //get only face in 3D. - CPPUNIT_ASSERT_NO_THROW(myBndSup = myMesh6->getBoundaryElements(MED_FACE)); - - //test buildSupportOnElementsFromElementList and buildSupportOnNodeFromElementList - const int * myConnectivityValue6; - CPPUNIT_ASSERT_NO_THROW(myConnectivityValue6 = myMesh6->getReverseConnectivity(MED_DESCENDING)); - const int * myConnectivityIndex6; - CPPUNIT_ASSERT_NO_THROW(myConnectivityIndex6 = myMesh6->getReverseConnectivityIndex(MED_DESCENDING)); - int numberOfElem6; - CPPUNIT_ASSERT_NO_THROW(numberOfElem6 = myMesh6->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)); - list myElementsList6; - - for (int i=0; ibuildSupportOnElementsFromElementList(myElementsList6,MED_FACE)); - CPPUNIT_ASSERT(mySupportOnElem->deepCompare(*myBndSup)); - myBndSup->removeReference(); - CPPUNIT_ASSERT_EQUAL(MED_FACE, mySupportOnElem->getEntity()); - - list::const_iterator iteronelem = myElementsList6.begin(); - for (int i = 1; i <= 3; i++, iteronelem++) - { - CPPUNIT_ASSERT_EQUAL(i, mySupportOnElem->getValIndFromGlobalNumber(*iteronelem)); - } - mySupportOnElem->removeReference(); - CPPUNIT_ASSERT_NO_THROW(mySupportOnNode = myMesh6->buildSupportOnNodeFromElementList(myElementsList6,MED_FACE)); - SUPPORT *suppp=myMesh6->getBoundaryElements(MED_NODE); - CPPUNIT_ASSERT(mySupportOnNode->deepCompare( *(suppp))); - suppp->removeReference(); - mySupportOnNode->removeReference(); - - //sets mesh fields to initial values - myMesh6->init(); - - //ensure two meshes constracted from one file in two different ways are equal - CPPUNIT_ASSERT(!myMesh6->deepCompare(*myMesh4)); - - //ensure mesh is empty - CPPUNIT_ASSERT(myMesh6->getSpaceDimension() == MED_INVALID); - CPPUNIT_ASSERT(myMesh6->getNumberOfNodes() == MED_INVALID); - CPPUNIT_ASSERT(myMesh6->getCoordinateptr() == NULL); - - myMesh4->removeReference(); - myMesh5->removeReference(); - myMesh6->removeReference(); - - MESH* myMesh7 = MEDMEMTest_createTestMesh(); - vector< vector > myBndBox; - try - { - myBndBox = myMesh7->getBoundingBox(); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //cout<<"Bounding box for createTestMesh()"<getElementContainingPoint(CoorPoint); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT(idxElem != -1); - - double CoorNoPoint[3] = - { - 5.0, 0.0, -5.0 - }; //there is no such point - int idxNoElem; - try - { - idxNoElem = myMesh7->getElementContainingPoint(CoorNoPoint); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - myMesh7->removeReference(); - CPPUNIT_ASSERT(idxNoElem == -1); - - /////////////////////////////////////////////////////// - // TEST 5: test desactivateFacesComputation() method // - // of driver: NPAL17670 // - /////////////////////////////////////////////////////// - double coords[54] = - { - -0.215040, -0.107520, +0.000000, - +0.000000, -0.107520, +0.000000, - +0.000000, +0.107520, +0.000000, - -0.215040, +0.107520, +0.000000, - +0.215040, -0.107520, +0.000000, - +0.215040, +0.107520, +0.000000, - -0.215040, -0.107520, +1.500000, - -0.215040, -0.107520, +4.080623, - +0.000000, -0.107520, +1.500000, - +0.000000, -0.107520, +4.080623, - +0.000000, +0.107520, +1.500000, - +0.000000, +0.107520, +4.080623, - -0.215040, +0.107520, +1.500000, - -0.215040, +0.107520, +4.080623, - +0.215040, -0.107520, +1.500000, - +0.215040, -0.107520, +4.080623, - +0.215040, +0.107520, +1.500000, - +0.215040, +0.107520, +4.080623 - }; - - int connQuad4[] = - { - 2 , 5 , 15 , 9 , - 10, 16 , 18 , 12, - 11 , 13 , 14 , 12, - 7 , 9 , 11 , 13, - 3 , 4 , 13 , 11, - 1 , 2 , 9 , 7, - 1 , 2 , 3 , 4, - 15 , 17 , 18 , 16 , - 5 , 6 , 17 , 15, - 9 , 15 , 17 , 11 , - 13 , 7 , 8 , 14, - 4 , 1 , 7 , 13, - 9 , 11 , 12 , 10, - 8 , 10 , 12 , 14, - 2 , 5 , 6 , 3, - 17 , 11, 12 , 18 , - 2 , 3 , 11 , 9, - 6 , 3 , 11 , 17, - 7 , 9 , 10 , 8, - 9 , 15 , 16 , 10 - }; - - int connHexa8[] = - { - 3 , 2 , 1 , 4 , 11 , 9 , 7 , 13, - 17 , 15 , 9 , 11 , 18 , 16 , 10 , 12, - 11 , 9 , 7 , 13 , 12 , 10 , 8 , 14 , - 6 , 5 , 2 , 3 , 17 , 15 , 9 , 11 - }; - - int bottom[2] = - { - 7,15 - }; - MED_EN::medGeometryElement bottomTypes[1] = - { - MED_EN::MED_QUAD4 - }; - int bottomIndex[2] = - { - 1,3 - }; - int bottomNbOfElts[1] = - { - 2 - }; - - MESHING* meshing = new MESHING(); - meshing->setName( "TESTMESH" ); - const int nFaces=20; - const int nNodes=18; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - string coordname[3] = - { - "x", "y", "z" - }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]= - { - MED_EN::MED_HEXA8 - }; - const int nbOfCellElts[1]= - { - 4 - }; - meshing->setNumberOfTypes(1,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //Face connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesFace[1]= - { - MED_EN::MED_QUAD4 - }; - const int nbOfFaceElts[1]= - { - nFaces - }; - meshing->setNumberOfTypes(1,MED_EN::MED_FACE); - meshing->setTypes(classicalTypesFace,MED_EN::MED_FACE); - meshing->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_HEXA8,connHexa8); - //All face conn - meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_QUAD4,connQuad4); - //Adding some groups on faces - addMedFacesGroup( *meshing, 4, bottom, "BottomFaces",bottomTypes,bottomIndex,bottomNbOfElts,1) ; - //addMedFacesGroupAll( *meshing, "AllFaces"); - //writing... - int id=meshing->addDriver(MED_DRIVER,filenameout,meshing->getName()); - meshing->write(id); - // Field writing - const SUPPORT *sup=meshing->getSupportOnAll( MED_FACE ); - FIELD * field = new FIELD(sup, 1); - field->setName("temperature"); - field->setComponentName(1,"T"); field->setMEDComponentUnit(1,"K"); - double *tab=(double *)field->getValue(); - for(int i=0;isetIterationNumber(0); - field->setOrderNumber(-1); - field->setTime(12.); - id=field->addDriver(MED_DRIVER,filenameout,field->getName()); - field->write(id); - field->removeReference(); - meshing->removeReference(); - // - MESH mesh; - MED_MESH_RDONLY_DRIVER drv(filenameout,&mesh); - drv.desactivateFacesComputation(); - drv.setMeshName("TESTMESH"); - mesh.addDriver(drv); - mesh.read(); - const int *conn=mesh.getConnectivity(MED_NODAL,MED_FACE,MED_ALL_ELEMENTS); - for (int j = 0; j < nFaces; j++) - { - for (int k = 0; k < 4; k++) - CPPUNIT_ASSERT_EQUAL(conn[4*j+k], connQuad4[4*j+k]); - } - FIELD f; - f.addDriver(MED_DRIVER,filenameout,"temperature"); - f.setIterationNumber(0); - f.setOrderNumber(-1); - CPPUNIT_ASSERT_NO_THROW( f.read() ); - - ////////////////////////////////////////////////////////// - // TEST 6: Test Reading of a Field with given Mesh. // - // Group from the Mesh must be taken for Field Support. // - ////////////////////////////////////////////////////////// - { - // mesh creation - MESHING* mesh_prof = new MESHING(); - mesh_prof->setName("TESTMESH"); - mesh_prof->setCoordinates(3, nNodes, coords, "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - mesh_prof->setCoordinatesNames(coordname); - mesh_prof->setCoordinatesUnits(coordunit); - - //Cell connectivity info for classical elts - //mesh_prof->setNumberOfTypes(1,MED_EN::MED_CELL); - //mesh_prof->setTypes(classicalTypesCell,MED_EN::MED_CELL); - //mesh_prof->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //mesh_prof->setConnectivity(connHexa8,MED_EN::MED_CELL,MED_EN::MED_HEXA8); - - //Face connectivity info for classical elts - //mesh_prof->setNumberOfTypes(1,MED_EN::MED_FACE); - //mesh_prof->setTypes(classicalTypesFace,MED_EN::MED_FACE); - //mesh_prof->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE); - //mesh_prof->setConnectivity(connQuad4,MED_EN::MED_FACE,MED_EN::MED_QUAD4); - mesh_prof->setNumberOfTypes(1,MED_EN::MED_CELL); - mesh_prof->setTypes(classicalTypesFace,MED_EN::MED_CELL); - mesh_prof->setNumberOfElements(nbOfFaceElts,MED_EN::MED_CELL); - mesh_prof->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_QUAD4,connQuad4); - - //Adding some groups on faces - GROUP *faces_prof=new GROUP; - faces_prof->setName("BottomFaces"); - faces_prof->setMesh(mesh_prof); - //faces_prof->setEntity(MED_EN::MED_FACE); - faces_prof->setEntity(MED_EN::MED_CELL); - faces_prof->setNumberOfGeometricType(1); - faces_prof->setGeometricType(bottomTypes); - faces_prof->setNumberOfElements(bottomNbOfElts); - faces_prof->setNumber(bottomIndex, bottom); - mesh_prof->addGroup(*faces_prof); - - // Field creation - FIELD * field_prof = new FIELD(faces_prof, 1); - faces_prof->removeReference(); - field_prof->setName("temperature"); - field_prof->setComponentName(1,"T"); - field_prof->setMEDComponentUnit(1,"K"); - double *tab = (double *)field_prof->getValue(); - for (int i = 0; i < 2; i++) - tab[i] = i*(1.22); - field_prof->setTime(12.); - - // Writing... - int id_prof = mesh_prof->addDriver(MED_DRIVER, filename_profiles_wr, mesh_prof->getName()); - mesh_prof->write(id_prof); - mesh_prof->rmDriver(id_prof); - - // Field writing - id_prof = field_prof->addDriver(MED_DRIVER, filename_profiles_wr, field_prof->getName()); - field_prof->write(id_prof); - - field_prof->removeReference(); - mesh_prof->removeReference(); - - // Reading... - MESH *mesh_rd=new MESH(MED_DRIVER, filename_profiles_wr, "TESTMESH"); - FIELD *field_rd=new FIELD(MED_DRIVER, filename_profiles_wr, "temperature", -1, -1, mesh_rd); - //const vector groups_rd = mesh_rd.getGroups(MED_EN::MED_FACE); - vector groups_rd = mesh_rd->getGroups(MED_EN::MED_CELL); - vector supports_rd(groups_rd.size());//Because virtual inheritance - int iii=0; - for(vector ::iterator iter=groups_rd.begin();iter!=groups_rd.end();iter++,iii++) - supports_rd[iii]=dynamic_cast(*iter); - CPPUNIT_ASSERT(find(supports_rd.begin(),supports_rd.end(),field_rd->getSupport()) != supports_rd.end()); - field_rd->removeReference(); - mesh_rd->removeReference(); - } -} - diff --git a/src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing_fault.cxx deleted file mode 100644 index 256a131eb..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_MeshAndMeshing_fault.cxx +++ /dev/null @@ -1,1832 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_Grid.hxx" - -#include -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -double dmax(double x, double y) -{ -return (x>y)?x:y; -} - -double dmin(double x, double y) -{ -return (x>y)?y:x; -} - -/*! - * Check methods (18), defined in MEDMEM_Meshing.hxx: - * class MESHING: public MESH -{ - * (+) MESHING(); - * (+) ~MESHING(); - * (+) void setSpaceDimension (const int SpaceDimension); - * (+) void setMeshDimension (const int MeshDimension); - * (+) void setNumberOfNodes (const int NumberOfNodes); - * (+) void setCoordinates (const int SpaceDimension, const int NumberOfNodes, - * const double * Coordinates, - * const string System, const MED_EN::medModeSwitch Mode); - * (+) void setCoordinatesSystem(const string System) throw (MEDEXCEPTION); - * (+) void setCoordinatesNames (const string * names); - * (+) void setCoordinateName (const string name, const int i); - * (+) void setCoordinatesUnits (const string * units); - * (+) void setCoordinateUnit (const string unit, const int i); - * (+) void setNumberOfTypes (const int NumberOfTypes, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setTypes (const MED_EN::medGeometryElement * Types, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setNumberOfElements (const int * NumberOfElements, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setConnectivity (const int * Connectivity, const MED_EN::medEntityMesh Entity, - * const MED_EN::medGeometryElement Type) throw (MEDEXCEPTION); - * (+) void setPolygonsConnectivity (const int * ConnectivityIndex, const int * ConnectivityValue, - * int nbOfPolygons, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void setPolyhedraConnectivity (const int * PolyhedronIndex, const int * FacesIndex, - * const int * Nodes, int nbOfPolyhedra, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (NOT YET IMPLEMENTED!!!) void setConnectivities (const int * ConnectivityIndex, - * const int * ConnectivityValue, - * const MED_EN::medConnectivity ConnectivityType, - * const MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) void addGroup (const GROUP & Group) throw (MEDEXCEPTION); - * -} - */ - -/*! - * Check methods (87), defined in MEDMEM_Mesh.hxx: - * class MESH : public RCBASE -{ - * (+) void init(); - * (+) MESH(); - * (+) MESH(MESH &m); - * (+) MESH & operator=(const MESH &m); - * (+) virtual bool operator==(const MESH& other) const; - * (+) virtual bool deepCompare(const MESH& other) const; - * (+) MESH(driverTypes driverType, const string & fileName="", - * const string & meshName="") throw (MEDEXCEPTION); - * (+) virtual ~MESH(); - * (+) friend ostream & operator<<(ostream &os, const MESH &my); - * (+) int addDriver(driverTypes driverType, - * const string & fileName="Default File Name.med", - * const string & driverName="Default Mesh Name", - * MED_EN::med_mode_acces access=MED_EN::MED_REMP); - * (+) int addDriver(GENDRIVER & driver); - * (+) void rmDriver(int index=0); - * (+) virtual void read(int index=0); - * (must be private) inline void read(const GENDRIVER & genDriver); - * (+) inline void write(int index=0, const string & driverName = ""); - * (must be private) inline void write(const GENDRIVER & genDriver); - * (+) inline void setName(string name); - * (+) inline void setDescription(string description); - * (+) inline string getName() const; - * (+) inline string getDescription() const; - * (+) inline int getSpaceDimension() const; - * (+) inline int getMeshDimension() const; - * (+) inline bool getIsAGrid(); - * (+) inline int getNumberOfNodes() const; - * (+) virtual inline const COORDINATE * getCoordinateptr() const; - * (+) inline string getCoordinatesSystem() const; - * (+) virtual inline const double * getCoordinates(MED_EN::medModeSwitch Mode) const; - * (+) virtual inline const double getCoordinate(int Number,int Axis) const; - * (+) inline const string * getCoordinatesNames() const; - * (+) inline const string * getCoordinatesUnits() const; - * (+) virtual inline int getNumberOfTypes(MED_EN::medEntityMesh Entity) const; - * (+) virtual int getNumberOfTypesWithPoly(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const MED_EN::medGeometryElement * getTypes(MED_EN::medEntityMesh Entity) const; - * (+) virtual MED_EN::medGeometryElement * getTypesWithPoly(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const CELLMODEL * getCellsTypes(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline string * getCellTypeNames(MED_EN::medEntityMesh Entity) const; - * (+) virtual const int * getGlobalNumberingIndex(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline int getNumberOfElements(MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type) const; - * (+) virtual int getNumberOfElementsWithPoly(MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type) const; - * (+) virtual inline bool existConnectivity(MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity) const; - * (+) inline bool existPolygonsConnectivity(MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity) const; - * (+) inline bool existPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity) const; - * (+) virtual inline MED_EN::medGeometryElement getElementType - * (MED_EN::medEntityMesh Entity, int Number) const; - * (+) virtual inline MED_EN::medGeometryElement getElementTypeWithPoly - * (MED_EN::medEntityMesh Entity, int Number) const; - * (+) virtual inline void calculateConnectivity(MED_EN::medModeSwitch Mode, - * MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity) const; - * (+) virtual inline int getConnectivityLength(MED_EN::medModeSwitch Mode, - * MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type) const; - * (+) virtual inline const int * getConnectivity(MED_EN::medModeSwitch Mode, - * MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, - * MED_EN::medGeometryElement Type) const; - * (+) virtual inline const int * getConnectivityIndex - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity) const; - * (+) inline int getPolygonsConnectivityLength - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity) const; - * (+) inline const int * getPolygonsConnectivity - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity) const; - * (+) inline const int * getPolygonsConnectivityIndex - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity) const; - * (+) inline int getNumberOfPolygons(MED_EN::medEntityMesh Entity=MED_EN::MED_ALL_ENTITIES) const; - * (+) inline int getPolyhedronConnectivityLength(MED_EN::medConnectivity ConnectivityType) const; - * (+) inline const int * getPolyhedronConnectivity(MED_EN::medConnectivity ConnectivityType) const; - * (+) inline const int * getPolyhedronFacesIndex() const; - * (+) inline const int * getPolyhedronIndex(MED_EN::medConnectivity ConnectivityType) const; - * (+) inline int getNumberOfPolyhedronFaces() const; - * (+) inline int getNumberOfPolyhedron() const; - * (+) virtual int getElementNumber(MED_EN::medConnectivity ConnectivityType, - * MED_EN::medEntityMesh Entity, MED_EN::medGeometryElement Type, - * int * connectivity) const; - * (+) virtual inline int getReverseConnectivityLength - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual inline const int * getReverseConnectivity - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual inline int getReverseConnectivityIndexLength - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual inline const int * getReverseConnectivityIndex - * (MED_EN::medConnectivity ConnectivityType, MED_EN::medEntityMesh Entity=MED_EN::MED_CELL) const; - * (+) virtual int getNumberOfFamilies(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const vector getFamilies(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const FAMILY* getFamily(MED_EN::medEntityMesh Entity,int i) const; - * (+) virtual int getNumberOfGroups(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const vector getGroups(MED_EN::medEntityMesh Entity) const; - * (+) virtual inline const GROUP* getGroup(MED_EN::medEntityMesh Entity,int i) const; - * (+) virtual inline const CONNECTIVITY* getConnectivityptr() const; - * (+) virtual SUPPORT * getBoundaryElements(MED_EN::medEntityMesh Entity) throw (MEDEXCEPTION); - * (+) SUPPORT * getSkin(const SUPPORT * Support3D) throw (MEDEXCEPTION); - * (+) virtual FIELD* getVolume (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getArea (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getLength (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getNormal (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) virtual FIELD* getBarycenter (const SUPPORT * Support) const throw (MEDEXCEPTION); - * (+) static SUPPORT * mergeSupports(const vector Supports) throw (MEDEXCEPTION); - * (+) static SUPPORT * intersectSupports(const vector Supports) throw (MEDEXCEPTION); - * (+) void createFamilies(); - * (+) SUPPORT *buildSupportOnNodeFromElementList - * (const list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); - * (do the same thing as buildSupportOnNodeFromElementList except that a SUPPORT is not created) void fillSupportOnNodeFromElementList - * (const list& listOfElt, SUPPORT *supportToFill) const throw (MEDEXCEPTION); - * (+) SUPPORT *buildSupportOnElementsFromElementList - * (const list& listOfElt, MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION); - * (+) int getElementContainingPoint(const double *coord); - * (+) vector< vector > getBoundingBox() const; - * (+) template static - * FIELD * mergeFields(const vector< FIELD * > & others, bool meshCompare=false); - * (Presently disconnected in C++) virtual void addReference() const; - * (Presently disconnected in C++) virtual void removeReference() const; - * -} - */ -void MEDMEMTest_testMeshAndMeshing() -{ - string filename = getResourceFile("pointe.med"); - string meshname = "maa1"; - string filenameout21 = makeTmpFile("myMeshWrite4_pointe21.med"); - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filenameout21); - - //////////// - // TEST 1 // - //////////// - - MESH * myMesh= new MESH(); - myMesh->setName("FIRST_MESH"); - CPPUNIT_ASSERT(myMesh != NULL); - - //test operator << - //#ifdef ENABLE_FAULTS - //CPPUNIT_ASSERT_NO_THROW(cout << *myMesh << endl); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("ERROR: operator << : if mesh is empty then attempt" - // " to get values from null object causes error"); - //#endif - - //test operator = - MESH myMesh1 = *myMesh; - - //deepCompare - //#ifdef ENABLE_FAULTS - bool isEqual = false; - CPPUNIT_ASSERT_NO_THROW(isEqual = myMesh1.deepCompare(*myMesh)); - CPPUNIT_ASSERT(isEqual); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("ERROR: deepCompare(...) fails if mesh is empty"); - //#endif - - //ensure it imposible to compare meshes - MESH *myMeshPointer = myMesh; - //test operator == - CPPUNIT_ASSERT(*myMeshPointer == *myMesh); - - delete myMesh; - - //set a MESH object - MESHING *myMeshing=new MESHING; - myMeshing->setName("meshing"); - // define coordinates - - int SpaceDimension = 3; - int NumberOfNodes = 19; - double Coordinates[57] = - { - 0.0, 0.0, 0.0, - 0.0, 0.0, 1.0, - 2.0, 0.0, 1.0, - 0.0, 2.0, 1.0, - -2.0, 0.0, 1.0, - 0.0, -2.0, 1.0, - 1.0, 1.0, 2.0, - -1.0, 1.0, 2.0, - -1.0, -1.0, 2.0, - 1.0, -1.0, 2.0, - 1.0, 1.0, 3.0, - -1.0, 1.0, 3.0, - -1.0, -1.0, 3.0, - 1.0, -1.0, 3.0, - 1.0, 1.0, 4.0, - -1.0, 1.0, 4.0, - -1.0, -1.0, 4.0, - 1.0, -1.0, 4.0, - 0.0, 0.0, 5.0 - }; - try - { - myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - string Names[3] = - { - "X","Y","Z" - }; - try - { - myMeshing->setCoordinatesNames(Names); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - string Units[3] = - { - "cm","cm","cm" - }; - try - { - myMeshing->setCoordinatesUnits(Units); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - // define conectivities - - // cell part - - const int NumberOfTypes = 3; - medGeometryElement Types[NumberOfTypes] = - { - MED_TETRA4,MED_PYRA5,MED_HEXA8 - }; - const int NumberOfElements[NumberOfTypes] = - { - 12,2,2 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL)); - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setTypes(Types,MED_CELL)); - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfElements(NumberOfElements,MED_CELL)); - - const int sizeTetra = 12*4; - int ConnectivityTetra[sizeTetra]= - { - 1,2,3,6, - 1,2,4,3, - 1,2,5,4, - 1,2,6,5, - 2,7,4,3, - 2,8,5,4, - 2,9,6,5, - 2,10,3,6, - 2,7,3,10, - 2,8,4,7, - 2,9,5,8, - 2,10,6,9 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity( MED_CELL, MED_TETRA4, ConnectivityTetra )); - - int ConnectivityPyra[2*5]= - { - 7,8,9,10,2, - 15,18,17,16,19 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity( MED_CELL, MED_PYRA5, ConnectivityPyra )); - - int ConnectivityHexa[2*8]= - { - 11,12,13,14,7,8,9,10, - 15,16,17,18,11,12,13,14 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity( MED_CELL, MED_HEXA8, ConnectivityHexa )); - - // face part - const int NumberOfFacesTypes = 2; - medGeometryElement FacesTypes[NumberOfFacesTypes] = - { - MED_TRIA3,MED_QUAD4 - }; - const int NumberOfFacesElements[NumberOfFacesTypes] = - { - 4,4 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfTypes(NumberOfFacesTypes,MED_FACE)); - CPPUNIT_ASSERT_NO_THROW(myMeshing->setTypes(FacesTypes,MED_FACE)); - CPPUNIT_ASSERT_NO_THROW(myMeshing->setNumberOfElements(NumberOfFacesElements,MED_FACE)); - const int nbTria = 4; - const int sizeTria = nbTria*3; - int ConnectivityTria[sizeTria]= - { - 1,4,3, - 1,5,4, - 1,6,5, - 1,3,6 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity( MED_FACE, MED_TRIA3, ConnectivityTria )); - const int nbQua = 4; - int ConnectivityQua[nbQua*4]= - { - 7,8,9,10, - 11,12,13,14, - 11,7,8,12, - 12,8,9,13 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshing->setConnectivity( MED_FACE, MED_QUAD4, ConnectivityQua )); - - int meshDimension = SpaceDimension; // because there 3D cells in the mesh - - // edge part - - // not yet implemented : if set, results are unpredictable. - - // Some groups : - - // Node : - { - GROUP *myGroup=new GROUP; - myGroup->setName("SomeNodes"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_NODE); - myGroup->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_NONE - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 4 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,5 - }; - const int value[4]= - { - 1,4,5,7 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - { - GROUP *myGroup=new GROUP; - myGroup->setName("OtherNodes"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_NODE); - myGroup->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_NONE - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 3 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,4 - }; - const int value[3]= - { - 2,3,6 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - - // Cell : - { - GROUP *myGroup=new GROUP; - myGroup->setName("SomeCells"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_CELL); - myGroup->setNumberOfGeometricType(3); - medGeometryElement myTypes[3] = - { - MED_TETRA4,MED_PYRA5,MED_HEXA8 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[3] = - { - 4,1,2 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[3+1] = - { - 1,5,6,8 - }; - const int value[4+1+2]= - { - 2,7,8,12, - 13, - 15,16 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - { - GROUP *myGroup=new GROUP; - myGroup->setName("OtherCells"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_CELL); - myGroup->setNumberOfGeometricType(2); - medGeometryElement myTypes[] = - { - MED_TETRA4,MED_PYRA5 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[] = - { - 4,1 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[2+1] = - { - 1,5,6 - }; - const int value[4+1]= - { - 3,4,5,9, - 14 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - - // Face : - { - GROUP *myGroup=new GROUP; - myGroup->setName("SomeFaces"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_FACE); - myGroup->setNumberOfGeometricType(2); - medGeometryElement myTypes[2] = - { - MED_TRIA3,MED_QUAD4 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[2] = - { - 2,3 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[2+1] = - { - 1,3,6 - }; - const int value[2+3]= - { - 2,4, - 5,6,8 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - { - GROUP *myGroup=new GROUP; - myGroup->setName("OtherFaces"); - myGroup->setMesh(myMeshing); - myGroup->setEntity(MED_FACE); - myGroup->setNumberOfGeometricType(1); - medGeometryElement myTypes[1] = - { - MED_TRIA3 - }; - myGroup->setGeometricType(myTypes); - const int myNumberOfElements[1] = - { - 2 - }; - myGroup->setNumberOfElements(myNumberOfElements); - const int index[1+1] = - { - 1,3 - }; - const int value[2]= - { - 1,3 - }; - myGroup->setNumber(index,value); - CPPUNIT_ASSERT_NO_THROW(myMeshing->addGroup(*myGroup)); - myGroup->removeReference(); - } - - //test Mesh(MESH &m) - { - MESH * myMesh2 = new MESH( *myMeshing ); - CPPUNIT_ASSERT(myMesh2->deepCompare(*myMeshing)); - - cout<<*myMesh2<getName(),(string)"meshing"); - CPPUNIT_ASSERT((myMesh2->getDescription()).size() == 0); - myMesh2->setDescription("This class contains all information related to a 'meshing' mesh "); - CPPUNIT_ASSERT((myMesh2->getDescription()).size() != 0); - - CPPUNIT_ASSERT(myMesh2->getSpaceDimension() == SpaceDimension); - CPPUNIT_ASSERT(myMesh2->getMeshDimension() == meshDimension); - CPPUNIT_ASSERT(myMesh2->getNumberOfNodes() == NumberOfNodes); - - const COORDINATE* coord = myMesh2->getCoordinateptr(); - try - { - CPPUNIT_ASSERT(myMesh2->getCoordinatesSystem() != "catresian"); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const string * units; - try - { - units = myMesh2->getCoordinatesUnits(); - for (int axe = 0; axe < SpaceDimension; axe++) - { - string verif = coord->getCoordinateUnit(axe+1); - CPPUNIT_ASSERT(verif == units[axe]); - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const string * noms; - try - { - noms = myMesh2->getCoordinatesNames(); - for (int axe = 0; axe < SpaceDimension; axe++) - { - string verif = coord->getCoordinateName(axe+1); - CPPUNIT_ASSERT(verif == noms[axe]); - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - const double * coor2 = myMesh2->getCoordinates(MED_FULL_INTERLACE); - - for (int axe = 0; axe < SpaceDimension; axe++) - { - try - { - for (int num = 0; num < NumberOfNodes; num++) - { - try - { - const double d = myMesh2->getCoordinate(num + 1, axe + 1); - CPPUNIT_ASSERT(fabs(d - coor2[(num * SpaceDimension)+axe]) < 0.001); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const CONNECTIVITY * myConnectivity = myMesh2->getConnectivityptr(); - - // MED_EN::MED_CELL - MED_EN::medEntityMesh entity = myConnectivity->getEntity(); - CPPUNIT_ASSERT_EQUAL(MED_CELL, entity); - - int typesNb; - CPPUNIT_ASSERT_NO_THROW(typesNb= myConnectivity->getNumberOfTypes(entity)); - CPPUNIT_ASSERT_EQUAL(NumberOfTypes, typesNb); - - const MED_EN::medGeometryElement * Types1; - CPPUNIT_ASSERT_NO_THROW(Types1 = myMesh2->getTypes(entity)); - - medConnectivity myMedConnect; - bool existConnect = false; - if (myMesh2->existConnectivity(MED_NODAL, entity)) - { - existConnect = true; - myMedConnect = MED_NODAL; - } - else if(myMesh2->existConnectivity(MED_DESCENDING, entity)) - { - existConnect = true; - myMedConnect = MED_DESCENDING; - } - - for(int t = 0; t < NumberOfTypes; t++ ) - { - CPPUNIT_ASSERT_EQUAL(Types1[t], Types[t]); - int NumberOfElements1 = 0; - CPPUNIT_ASSERT_NO_THROW(NumberOfElements1 = myMesh2->getNumberOfElements(entity, Types1[t])); - CPPUNIT_ASSERT_EQUAL(NumberOfElements1, NumberOfElements[t]); - if(existConnect) - { - const int * connectivity; - const int * connectivity_index; - CPPUNIT_ASSERT_NO_THROW(connectivity = myMesh2->getConnectivity - (myMedConnect, entity, Types1[t])); - connectivity_index = myMesh2->getConnectivityIndex(myMedConnect, entity); - for (int j = 0; j < NumberOfElements1; j++) - { - cout<<"!!!!!!!!!!!!!!!"<getCellsTypes(entity); - string* TypeNames; - CPPUNIT_ASSERT_NO_THROW(TypeNames = myMesh2->getCellTypeNames(entity)); - - for(int k = 0; k < NumberOfTypes; k++ ) - { - CPPUNIT_ASSERT_EQUAL(TypeNames[k], myCellModel[k].getName()); - } - delete [] TypeNames; - - const int* myGlobalNbIdx; - CPPUNIT_ASSERT_NO_THROW(myGlobalNbIdx = myMesh2->getGlobalNumberingIndex(MED_FACE)); - for(int i = 0; i <= NumberOfFacesTypes; i++) - { - if(i == NumberOfFacesTypes) - { - CPPUNIT_ASSERT_EQUAL(myGlobalNbIdx[i],nbTria+nbQua+1); - CPPUNIT_ASSERT_THROW(myMesh2->getElementType(MED_FACE, myGlobalNbIdx[i]), MEDEXCEPTION); - break; - } - cout<<"Global number of first element of each geom type : "<setNumberOfNodes(NumberOfNodes); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("ERROR in CONNECTIVITY::calculateReverseNodalConnectivity()" - // " because myMesh2->_connectivity->_numberOfNodes is not set"); - //#endif - - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivity = myMesh2->getReverseConnectivity(MED_NODAL, entity)); - CPPUNIT_ASSERT_NO_THROW(myMesh2->getReverseConnectivityLength(MED_NODAL, entity)); - const int * ReverseNodalConnectivityIndex = myMesh2->getReverseConnectivityIndex(MED_NODAL, entity); - const int ReverseIdxLength = myMesh2->getReverseConnectivityIndexLength(MED_NODAL, entity); - CPPUNIT_ASSERT(ReverseIdxLength == NumberOfNodes+1); - for (int i = 0; i < NumberOfNodes; i++) - { - cout << "Node "<< i+1 << " : "; - for (int j = ReverseNodalConnectivityIndex[i]; j < ReverseNodalConnectivityIndex[i+1]; j++) - cout << ReverseNodalConnectivity[j-1] << " "; - cout << endl; - } - - // Show Descending Connectivity - int NumberOfElements1; - const int * connectivity; - const int * connectivity_index; - myMesh2->calculateConnectivity(MED_DESCENDING, entity); - try - { - NumberOfElements1 = myMesh2->getNumberOfElements(entity, MED_ALL_ELEMENTS); - connectivity = myMesh2->getConnectivity( MED_DESCENDING, entity, MED_ALL_ELEMENTS); - connectivity_index = myMesh2->getConnectivityIndex(MED_DESCENDING, entity); - } - catch (MEDEXCEPTION m) - { - CPPUNIT_FAIL(m.what()); - } - - for (int j = 0; j < NumberOfElements1; j++) - { - cout << "Element " << j+1 << " : "; - for (int k = connectivity_index[j]; k < connectivity_index[j+1]; k++) - cout << connectivity[k-1] << " "; - cout << endl; - } - - // getElementNumber - if (myMesh2->existConnectivity(MED_NODAL, MED_FACE)) - { - int myTr[3] = - { - 1,5,4 - }; - CPPUNIT_ASSERT_NO_THROW(myMesh2->getElementNumber(MED_NODAL,MED_FACE,MED_TRIA3,myTr)); - } - } - - //test family and group - int NumberOfGroups; - CPPUNIT_ASSERT_THROW(myMesh2->getNumberOfGroups(MED_ALL_ENTITIES), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(NumberOfGroups = myMesh2->getNumberOfGroups(MED_CELL)); - CPPUNIT_ASSERT_EQUAL(NumberOfGroups, 2); - vector groups; - CPPUNIT_ASSERT_NO_THROW(groups = myMesh2->getGroups(MED_CELL)); - CPPUNIT_ASSERT(groups.size() != 0); - for(int nb = 1; nb <= NumberOfGroups; nb++ ) - { - const GROUP* group; - CPPUNIT_ASSERT_NO_THROW(group = myMesh2->getGroup(MED_CELL, nb)); - CPPUNIT_ASSERT_EQUAL(group->getName(), groups[nb-1]->getName()); - } - - int NumberOfFamilies; - CPPUNIT_ASSERT_NO_THROW(NumberOfFamilies = myMesh2->getNumberOfFamilies(MED_CELL)); - CPPUNIT_ASSERT_MESSAGE("Current mesh hasn't Families", NumberOfFamilies == 0); - - //create families - it's not possible to create, becase not all entities are defined - CPPUNIT_ASSERT_THROW( myMesh2->createFamilies(),MEDEXCEPTION); - - /*CPPUNIT_ASSERT_NO_THROW(NumberOfFamilies = myMesh2->getNumberOfFamilies(MED_CELL)); - CPPUNIT_ASSERT( NumberOfFamilies != 0);*/ - - delete myMesh2; - } - - ////////////////////////////////////////////////////////////// - // TEST 2: Polygon and Polyhedron(only NODAL connectivity) // - ///////////////////////////////////////////////////////////// - - double CoordinatesPoly[57] = - { - 2.0, 3.0, 2.0, - 3.0, 2.0, 2.0, - 4.0, 1.0, 2.0, - 2.0, 0.0, 2.0, - 0.0, 1.0, 2.0, - 1.0, 2.0, 2.0, - 2.0, 3.0, 1.0, - 3.0, 2.0, 0.0, - 4.0, 1.0, 0.0, - 2.0, 0.0, 0.0, - 0.0, 1.0, 0.0, - 1.0, 2.0, 0.0, - 5.0, 3.0, 2.0, - 7.0, 2.0, 2.0, - 6.0, 0.0, 2.0, - 6.0, 3.0, 0.0, - 7.0, 2.0, 0.0, - 6.0, 0.0, -1.0, - 5.0, 1.0, -3.0 - }; - - const int REFnodalConnOfFaces[91] = - { - 1, 2, 3, 4, 5, 6, -1,// Polyhedron 1 - 1, 7, 8, 2, -1, - 2, 8, 9, 3, -1, - 4, 3, 9, 10, -1, - 5, 4, 10, 11, -1, - 6, 5, 11, 12, -1, - 1, 6, 12, 7, -1, - 7, 12, 8, 10, -1, - 9, 8, 12, 11, - - 13, 14, 15, 3, 2, -1,// Polyhedron 2 - 13, 2, 8, 16, -1, - 14, 13, 16, 17, -1, - 15, 14, 17, 15, -1, - 17, 18, 15, -1, - 18, 9, 3, -1, - 15, 9, 2, -1, - 3, 9, 8, -1, - 8, 9, 17, 16, -1, - 9, 18, 17 - }; - const int NumberOfFaces = 19; - const int NumberOfPolyhedron = 2; - const int nbOfPolygons = 2; - - const int REFpolyIndex[NumberOfPolyhedron+1] = - { - 1,47,92 - }; - - double PolygonCoordinates[27] = - { - 2.0, 3.0, 12.0, - 3.0, 2.0, 12.0, - 4.0, 1.0, 12.0, - 2.0, 0.0, 12.0, - 0.0, 1.0, 12.0, - 1.0, 2.0, 12.0, - 5.0, 3.0, 12.0, - 7.0, 2.0, 12.0, - 6.0, 0.0, 12.0 - }; - - const int REFpolygonFaces[11] = - { - 1, 2, 3, 4, 5, 6, // Polygon 1 - 7, 8, 9, 3, 2 - }; // Polygon 2 - - const int REFpolygonIndex[nbOfPolygons+1] = - { - 1, 7, 12 - }; - - MESHING *myMeshingPoly=new MESHING; - myMeshingPoly->setName("meshingpoly"); - - const int NbOfTypes = 1; - medGeometryElement TypesPoly[NbOfTypes] = - { - MED_TETRA4 - }; - const int NbOfElements[NbOfTypes] = - { - 1 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setNumberOfTypes(NbOfTypes, MED_CELL)); - - try - { - myMeshingPoly->setCoordinates(SpaceDimension, NumberOfNodes, CoordinatesPoly, - "CARTESIAN", MED_FULL_INTERLACE); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setTypes(TypesPoly, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setNumberOfElements(NbOfElements, MED_CELL)); - - string Unit ="cm"; - for(int i = 0; i < SpaceDimension; i++ ) - { - try - { - myMeshingPoly->setCoordinateName(Names[i],i); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - try - { - myMeshingPoly->setCoordinateUnit(Unit, i); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - - int ConnectivityTetraPoly[4*1]= - { - 17, 9, 18, 19 - }; - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setConnectivity( MED_CELL, MED_TETRA4, ConnectivityTetraPoly )); - - CPPUNIT_ASSERT_NO_THROW(myMeshingPoly->setConnectivity(MED_CELL, MED_POLYHEDRA,REFnodalConnOfFaces,REFpolyIndex)); - - bool PolyConn = false; - CPPUNIT_ASSERT_NO_THROW(PolyConn = myMeshingPoly->existConnectivity(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(PolyConn); - { - CPPUNIT_ASSERT_EQUAL(NumberOfPolyhedron, - myMeshingPoly->getNumberOfElements(MED_CELL,MED_POLYHEDRA)); - CPPUNIT_ASSERT_NO_THROW( myMeshingPoly->calculateConnectivity (MED_NODAL,MED_FACE)); - CPPUNIT_ASSERT_EQUAL(NumberOfFaces-1, myMeshingPoly->getNumberOfElements(MED_FACE,MED_POLYGON)); // -1: one face is shared with tetra - CPPUNIT_ASSERT_EQUAL(91,myMeshingPoly->getConnectivityLength(MED_NODAL,MED_CELL,MED_POLYHEDRA)); - const int * PolyConn; - const int * PolyIdx; - CPPUNIT_ASSERT_NO_THROW(PolyConn = myMeshingPoly->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_NO_THROW(PolyIdx = myMeshingPoly->getConnectivityIndex(MED_NODAL,MED_CELL)); - for(int i = NbOfElements[0], iRef=0; isetName("PolygonMeshing"); - - medGeometryElement PolygonTypes[NbOfTypes] = - { - MED_TRIA3 - }; - const int PolygonNumberOfElements[NbOfTypes] = - { - 2 - }; - - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setNumberOfTypes(NbOfTypes, MED_CELL)); - - try - { - myPolygonMeshing->setCoordinates(SpaceDimension, NumberOfNodes, PolygonCoordinates, - "CARTESIAN", MED_FULL_INTERLACE); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_EQUAL(SpaceDimension, myPolygonMeshing->getSpaceDimension()); - CPPUNIT_ASSERT_EQUAL(NumberOfNodes, myPolygonMeshing->getNumberOfNodes()); - - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setTypes(PolygonTypes, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setNumberOfElements(PolygonNumberOfElements, MED_CELL)); - CPPUNIT_ASSERT_EQUAL(2, myPolygonMeshing->getMeshDimension()); - - try - { - myPolygonMeshing->setCoordinatesNames(Names); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myPolygonMeshing->setCoordinatesUnits(Units); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const int sizeTri = 3*2; - int ConnectivityTri[sizeTri]= - { - 1, 7, 2, 3, 9, 4 - }; - - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setConnectivity( MED_CELL, MED_TRIA3, ConnectivityTri )); - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->setConnectivity( MED_CELL, MED_POLYGON, REFpolygonFaces, REFpolygonIndex )); - - bool PolygonConn = false; - CPPUNIT_ASSERT_NO_THROW(PolygonConn = myPolygonMeshing->existConnectivity(MED_NODAL, MED_CELL)); - if(PolygonConn) - { - int Polytypes; - CPPUNIT_ASSERT_NO_THROW(Polytypes = myPolygonMeshing->getNumberOfTypes(MED_CELL)); - CPPUNIT_ASSERT_EQUAL(NbOfTypes,Polytypes); - - const MED_EN::medGeometryElement * PolyTypes; - CPPUNIT_ASSERT_NO_THROW(PolyTypes = myPolygonMeshing->getTypes(MED_CELL)); - CPPUNIT_ASSERT_EQUAL(PolyTypes[NbOfTypes-1],MED_POLYGON); - - for(int t = 0; t < Polytypes; t++) - { - CPPUNIT_ASSERT_NO_THROW( myPolygonMeshing->getNumberOfElements(MED_CELL, PolyTypes[t])); - } - - medGeometryElement geomPolyElem; - CPPUNIT_ASSERT_NO_THROW(geomPolyElem = myPolygonMeshing->getElementType(MED_CELL, 1)); - CPPUNIT_ASSERT_EQUAL(geomPolyElem, MED_TRIA3); - - CPPUNIT_ASSERT_EQUAL(myPolygonMeshing->getNumberOfElements(MED_CELL,MED_POLYGON),nbOfPolygons); - CPPUNIT_ASSERT_NO_THROW(myPolygonMeshing->getConnectivityLength(MED_NODAL,MED_CELL,MED_POLYGON)); - myPolygonMeshing->removeReference(); - const int * PolygonConn; - CPPUNIT_ASSERT_THROW(PolygonConn = myMeshingPoly->getConnectivity(MED_NODAL,MED_CELL,MED_POLYGON),MEDEXCEPTION); - } - - //////////////////////////////////////////////////////////// - // TEST : SUPPORT* sup = myMeshPointe->getSupportOnAll()) // - //////////////////////////////////////////////////////////// - - //#ifdef ENABLE_FAULTS - { - MESH * myMeshPointe = new MESH(MED_DRIVER, filename, meshname); - const SUPPORT* sup = myMeshPointe->getSupportOnAll(MED_CELL); - CPPUNIT_ASSERT( sup->isOnAllElements() ); - CPPUNIT_ASSERT_EQUAL( myMeshPointe->getNumberOfTypes( sup->getEntity() ), - sup->getNumberOfTypes()); - CPPUNIT_ASSERT( sup->getNumber( MED_ALL_ELEMENTS )); - myMeshPointe->removeReference(); - } - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("ERROR: can not create SUPPORT on mesh, read from pointe.med"); - //#endif - - //////////////////////////////////////////////////////// - // TEST 3: test MESH on MEDMEMTest::createTestMesh()// - /////////////////////////////////////////////////////// - - MESH* myMesh3 = MEDMEMTest_createTestMesh(); - - int MeshDim = myMesh3->getMeshDimension(); - medEntityMesh constituentEntity; - if (MeshDim==3) - { - constituentEntity = MED_CELL; - } - if (MeshDim==2) - { - constituentEntity = MED_FACE; - } - if (MeshDim==1) - { - constituentEntity = MED_EDGE; - } - - int SpaceDim = myMesh3->getSpaceDimension(); - - // Show Reverse Nodal Connectivity - const int* ReverseNodalConnectivity; - const int* ReverseNodalConnectivityIndex; - int ReverseLength; - int ReverseIdxLength; - - CONNECTIVITY* myConnectivity3 = (CONNECTIVITY*)myMesh3->getConnectivityptr(); - myConnectivity3->setNumberOfNodes(myMesh3->getNumberOfNodes()); - - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivity= myMesh3->getReverseConnectivity(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(ReverseLength = myMesh3->getReverseConnectivityLength(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(ReverseNodalConnectivityIndex = myMesh3->getReverseConnectivityIndex(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT_NO_THROW(ReverseIdxLength = myMesh3->getReverseConnectivityIndexLength(MED_NODAL, MED_CELL)); - CPPUNIT_ASSERT(ReverseIdxLength == myMesh3->getNumberOfNodes()+1); - - for (int i = 0; i < myMesh3->getNumberOfNodes(); i++) - { - cout << "Node "<< i+1 << " : "; - for (int j = ReverseNodalConnectivityIndex[i]; j < ReverseNodalConnectivityIndex[i+1]; j++) - cout << ReverseNodalConnectivity[j-1] << " "; - cout << endl; - } - - // Show Descending Connectivity - int NumberOfElements1; - const int * connectivity; - const int * connectivity_index; - myMesh3->calculateConnectivity(MED_DESCENDING, MED_EN::MED_CELL); - try - { - NumberOfElements1 = myMesh3->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - connectivity = myMesh3->getConnectivity( MED_DESCENDING, MED_CELL, MED_ALL_ELEMENTS); - connectivity_index = myMesh3->getConnectivityIndex(MED_DESCENDING, MED_CELL); - } - catch (MEDEXCEPTION m) - { - CPPUNIT_FAIL(m.what()); - } - - for (int j = 0; j < NumberOfElements1; j++) - { - cout << "Element " << j+1 << " : "; - for (int k = connectivity_index[j]; k < connectivity_index[j+1]; k++) - cout << connectivity[k-1] << " "; - cout << endl; - } - - //test 3D mesh - for(int ind = SpaceDim; ind > 1; ind-- ) - { - int NumberOfElem = myMesh3->getNumberOfElements (constituentEntity,MED_ALL_ELEMENTS); - if(NumberOfElem < 1) continue; - - const SUPPORT * sup = myMesh3->getSupportOnAll( constituentEntity ); - - if (ind == 2) - { - // test of normal(for 1d or 2d elements) - FIELD* normal; - CPPUNIT_ASSERT_NO_THROW(normal = myMesh3->getNormal(sup)); - - double normal_square, norm; - double maxnorm=0.; - double minnorm=0.; - double tmp_value; - for (int i = 1; i<=NumberOfElem; i++) - { - normal_square = 0.; - cout << "Normal " << i << " "; - for (int j=1; j<=SpaceDim; j++) - { - tmp_value = normal->getValueIJ(i,j); - normal_square += tmp_value*tmp_value; - cout << tmp_value << " "; - } - norm = sqrt(normal_square); - maxnorm = dmax(maxnorm,norm); - minnorm = dmin(minnorm,norm); - cout << ", Norm = " << norm << endl; - } - cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl; - delete normal; - - // test of area(for 2d elements) - FIELD* area; - CPPUNIT_ASSERT_NO_THROW(area = myMesh3->getArea(sup)); - - double maxarea,minarea,areatot; - maxarea = 0.; - minarea = 0.; - areatot = 0.0; - for (int i = 1; i<=NumberOfElem;i++) - { - cout << "Area " << i << " " << area->getValueIJ(i,1) << endl; - maxarea = dmax(maxarea,area->getValueIJ(i,1)); - minarea = dmin(minarea,area->getValueIJ(i,1)); - areatot = areatot + area->getValueIJ(i,1); - } - - cout << "Max Area " << maxarea << " Min Area " << minarea << endl; - cout << "Support Area " << areatot << endl; - - delete area; - } - - // test of barycenter(for 3d and 2d elements) - FIELD* barycenter; - CPPUNIT_ASSERT_NO_THROW(barycenter = myMesh3->getBarycenter(sup)); - - CPPUNIT_ASSERT_NO_THROW(NumberOfElem = myMesh3->getNumberOfElements(constituentEntity,MED_ALL_ELEMENTS)); - - for (int i = 1; i<=NumberOfElem;i++) - { - if (ind == 3) - cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << " " << barycenter->getValueIJ(i,3) << endl; - - if (ind == 2) - cout << "Barycenter " << i << " " << barycenter->getValueIJ(i,1) << " " << barycenter->getValueIJ(i,2) << endl; - } - delete barycenter; - - // test of volume(for 3d elements) - if (ind == 3) - { - FIELD* volume; - CPPUNIT_ASSERT_NO_THROW(volume= myMesh3->getVolume(sup)); - - double maxvol,minvol,voltot; - maxvol = 0.; - minvol = 0.; - voltot = 0.0; - for (int i = 1; i<=NumberOfElem;i++) - { - cout << "Volume " << i << " " << volume->getValueIJ(i,1) << endl; - maxvol = dmax(maxvol,volume->getValueIJ(i,1)); - minvol = dmin(minvol,volume->getValueIJ(i,1)); - voltot = voltot + volume->getValueIJ(i,1); - } - - cout << "Max Volume " << maxvol << " Min Volume " << minvol << endl; - cout << "Support Volume " << voltot << endl; - - delete volume; - - // test of skin - SUPPORT *skin; - CPPUNIT_ASSERT_NO_THROW(skin = myMesh3->getSkin(sup)); - - //test mergeSupports and intersectSupports. vactor contains only 1 elements - vector myVectSup; - myVectSup.push_back(skin); - - //method return a copy of skin object - SUPPORT *copyMergeSkin; - CPPUNIT_ASSERT_NO_THROW(copyMergeSkin = myMesh3->mergeSupports(myVectSup)); - try - { - CPPUNIT_ASSERT(copyMergeSkin->deepCompare(*skin)); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //method return a copy of skin object - SUPPORT *copyIntersectSkin; - CPPUNIT_ASSERT_NO_THROW(copyIntersectSkin = myMesh3->intersectSupports(myVectSup)); - try - { - CPPUNIT_ASSERT(copyIntersectSkin->deepCompare(*skin)); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - skin->removeReference(); - copyMergeSkin->removeReference(); - copyIntersectSkin->removeReference(); - } - - constituentEntity++; - } - - - // Testing length and normal vectors on 1d elements - { - // coordinates - int NumberOfNodes3 = 4; - - string Names3[3] = - { - "X","Y","Z" - }; - string Units3[3] = - { - "cm","cm","cm" - }; - - double Coordinates3[4*2] = - { - 0.0, 0.0, // n1 - 1.0, 1.0, // n2 - 0.0, 1.0, // n3 - 1.0, 0.0 - }; // n4 - - const int NumberOfEdgeTypes = 1; - MED_EN::medGeometryElement EdgeTypes[NumberOfEdgeTypes] = - { - MED_SEG2 - }; - const int NumberOfEdges[NumberOfEdgeTypes] = - { - 4 - }; - int ConnectivityEdge[4*2] = - { - 1,2, 2,3, 3,4, 4,1 - }; - - // CREATE THE MESH - MEDMEM::MESHING* myMeshing3 = new MEDMEM::MESHING; - myMeshing3->setName("meshing3"); - myMeshing3->setCoordinates(/*SpaceDimension*/2, NumberOfNodes3, Coordinates3, - "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - myMeshing3->setCoordinatesNames(Names3); - myMeshing3->setCoordinatesUnits(Units3); - - // define connectivities - // cell part - const int NumberOfTypes3 = 1; - medGeometryElement Types3[NumberOfTypes3] = - { - MED_QUAD4 - }; - const int NumberOfElements3[NumberOfTypes3] = - { - 1 - }; - - myMeshing3->setNumberOfTypes(NumberOfTypes3,MED_CELL); - myMeshing3->setTypes(Types3,MED_CELL); - myMeshing3->setNumberOfElements(NumberOfElements3,MED_CELL); - - int Connectivityquad[1*4] = - { - 1,2,3,4 - }; - - myMeshing3->setConnectivity( MED_CELL, MED_QUAD4, Connectivityquad ); - - myMeshing3->setNumberOfTypes(NumberOfEdgeTypes, MED_EDGE); - myMeshing3->setTypes(EdgeTypes, MED_EDGE); - myMeshing3->setNumberOfElements(NumberOfEdges, MED_EDGE); - - myMeshing3->setConnectivity( MED_EDGE, MED_SEG2, ConnectivityEdge ); - - //test 2D mesh - int NumberOfElem = myMeshing3->getNumberOfElements (MED_EDGE, MED_ALL_ELEMENTS); - - const SUPPORT * sup = myMeshing3->getSupportOnAll( MED_EDGE ); - - // test of normal(for 1d or 2d elements) - FIELD* normal; - CPPUNIT_ASSERT_NO_THROW(normal = myMeshing3->getNormal(sup)); - - double normal_square, norm; - double maxnorm=0.; - double minnorm=0.; - double tmp_value; - for (int i = 1; i<=NumberOfElem; i++) - { - normal_square = 0.; - cout << "Normal " << i << " "; - for (int j=1; j<=/*SpaceDimension*/2; j++) - { - tmp_value = normal->getValueIJ(i,j); - normal_square += tmp_value*tmp_value; - cout << tmp_value << " "; - } - norm = sqrt(normal_square); - maxnorm = dmax(maxnorm,norm); - minnorm = dmin(minnorm,norm); - cout << ", Norm = " << norm << endl; - } - cout << "Max Norm " << maxnorm << " Min Norm " << minnorm << endl; - - // test of length(for 1d elements) - FIELD* length; - CPPUNIT_ASSERT_NO_THROW(length = myMeshing3->getLength(sup)); - - double length_value,maxlength,minlength; - maxlength = 0; - minlength = 0; - for (int i = 1; i<=NumberOfElem;i++) - { - length_value = length->getValueIJ(i,1); - cout << "Length " << i << " " << length_value << endl; - maxlength = dmax(maxlength,length_value); - minlength = dmin(minlength,length_value); - } - cout << "Max Length " << maxlength << " Min Length " << minlength << endl; - - vector< FIELD *> myVectField1; - myVectField1.push_back(normal); - myVectField1.push_back(length); - CPPUNIT_ASSERT_NO_THROW(myMeshing3->mergeFields(myVectField1)); - - delete normal; - delete length; - - //#ifdef ENABLE_FAULTS - { - // (BUG) Segmentation fault if vector is empty - vector myVectSupEmpty; - CPPUNIT_ASSERT_THROW(myMesh3->mergeSupports(myVectSupEmpty), MEDEXCEPTION); - } - //#endif - - // test mergeFields method: Fields have the same value type - //intersectSupports and mergeSupports methods - { - SUPPORT * sup1 = new SUPPORT; - sup1->setMesh( myMeshing3 ); - sup1->setEntity( MED_EDGE ); - SUPPORT * sup2 = new SUPPORT; - sup2->setMesh( myMeshing3 ); - sup2->setEntity( MED_EDGE ); - MED_EN::medGeometryElement gtEdges[1] = - { - MED_SEG2 - }; - int nbEdges1[1] = - { - 1 - }; - int edges1[1] = - { - 1 - }; - int nbEdges2[1] = - { - 2 - }; - int edges2[2] = - { - 2,3 - }; - sup1->setpartial("description 1", 1, 1, gtEdges, nbEdges1, edges1); - sup2->setpartial("description 1", 1, 2, gtEdges, nbEdges2, edges2); - - vector myVectSup3; - myVectSup3.push_back(sup1); - myVectSup3.push_back(sup2); - //method return a MergeSup on the union of all SUPPORTs in Supports. - SUPPORT *MergeSup; - CPPUNIT_ASSERT_NO_THROW(MergeSup = myMesh3->mergeSupports(myVectSup3)); - cout << *MergeSup << endl; - MergeSup->removeReference(); - - //method return a intersection of all SUPPORTs in IntersectSup - SUPPORT *IntersectSup; - CPPUNIT_ASSERT_NO_THROW(IntersectSup = myMesh3->intersectSupports(myVectSup3)); - if (IntersectSup != NULL) cout<< *IntersectSup <removeReference(); - - FIELD * length1 = myMeshing3->getLength(sup1); - FIELD * length2 = myMeshing3->getLength(sup2); - - vector< FIELD *> myVect12; - myVect12.push_back(length1); - myVect12.push_back(length2); - - FIELD * length12; - CPPUNIT_ASSERT_NO_THROW(length12 = myMeshing3->mergeFields(myVect12)); - delete length12; - - sup1->removeReference(); - sup2->removeReference(); - delete length1; - delete length2; - } - } - - ///////////////////////////////////////////////////////// - // TEST 4: test MESH constructed from file pointe.med // - //////////////////////////////////////////////////////// - MESH * myMesh4 = new MESH(); - myMesh4->setName(meshname); - MED_MESH_RDONLY_DRIVER myMeshDriver (filename, myMesh4); - myMeshDriver.setMeshName(meshname); - - //Mesh has no driver->segmentation violation - //CPPUNIT_ASSERT_THROW(myMesh4->read(), MEDEXCEPTION); - - //Add an existing MESH driver. - int myDriver4; - CPPUNIT_ASSERT_NO_THROW(myDriver4 = myMesh4->addDriver(myMeshDriver)); - - //read all objects in the file - CPPUNIT_ASSERT_NO_THROW(myMesh4->read(myDriver4)); - - if (myMesh4->getIsAGrid()) - { - GRID* myGrid = dynamic_cast(myMesh4); - CPPUNIT_ASSERT(myGrid); - } - - //myDriver4->DRONLY->can't write - CPPUNIT_ASSERT_THROW(myMesh4->write(myDriver4), MEDEXCEPTION); - - // add new driver - int idMeshV21; - CPPUNIT_ASSERT_NO_THROW(idMeshV21 = myMesh4->addDriver(MED_DRIVER,filenameout21)); - - //Write all the content of the MESH using driver referenced by the integer handler index. - CPPUNIT_ASSERT_NO_THROW(myMesh4->write(idMeshV21)); - - // remove driver from mesh - CPPUNIT_ASSERT_NO_THROW(myMesh4->rmDriver(myDriver4)); - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("ERROR: driver with index idMedV21 has not been removed"); - //#endif - // ensure exception is raised on second attempt to remove driver - //CPPUNIT_ASSERT_THROW(myMesh4->rmDriver(myDriver4),MEDEXCEPTION); - - // Create a MESH object using a MESH driver of type MED_DRIVER associated with file fileName. - MESH* myMesh5; - CPPUNIT_ASSERT_NO_THROW(myMesh5 = new MESH(MED_DRIVER, filename, meshname)); - if(myMesh5->getIsAGrid()) - { - GRID* myGrid = dynamic_cast(myMesh4); - CPPUNIT_ASSERT(myGrid); - } - - //ensure two meshes constracted from one file in two different ways are equal - CPPUNIT_ASSERT(myMesh5->deepCompare(*myMesh4)); - - int myDriver6; - MESH* myMesh6 = new MESH(); - try - { - myDriver6 = myMesh6->addDriver(MED_DRIVER, filename, meshname, RDONLY); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myMesh6->read(myDriver6); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //ensure two meshes constracted from one file in two different ways are equal - CPPUNIT_ASSERT(myMesh6->deepCompare(*myMesh4)); - - //test FAMILY - int NumberOfFamilies4; - CPPUNIT_ASSERT_NO_THROW(NumberOfFamilies4 = myMesh6->getNumberOfFamilies(MED_CELL)); - CPPUNIT_ASSERT_MESSAGE("Current mesh hasn't Families", NumberOfFamilies4 != 0); - - vector families4; - CPPUNIT_ASSERT_NO_THROW(families4 = myMesh6->getFamilies(MED_CELL)); - CPPUNIT_ASSERT(families4.size() == NumberOfFamilies4); - for(int nb = 1; nb <= NumberOfFamilies4; nb++ ) - { - const FAMILY* family; - CPPUNIT_ASSERT_NO_THROW(family = myMesh6->getFamily(MED_CELL, nb)); - CPPUNIT_ASSERT_EQUAL(family->getName(), families4[nb-1]->getName()); - } - - //get support which reference all elements on the boundary of mesh. - SUPPORT*myBndSup; - CPPUNIT_ASSERT_THROW(myMesh6->getBoundaryElements(MED_CELL), MEDEXCEPTION); - //get only face in 3D. - CPPUNIT_ASSERT_NO_THROW(myBndSup = myMesh6->getBoundaryElements(MED_FACE)); - - //test buildSupportOnElementsFromElementList and buildSupportOnNodeFromElementList - const int * myConnectivityValue6; - CPPUNIT_ASSERT_NO_THROW(myConnectivityValue6 = myMesh6->getReverseConnectivity(MED_DESCENDING)); - const int * myConnectivityIndex6; - CPPUNIT_ASSERT_NO_THROW(myConnectivityIndex6 = myMesh6->getReverseConnectivityIndex(MED_DESCENDING)); - int numberOfElem6; - CPPUNIT_ASSERT_NO_THROW(numberOfElem6 = myMesh6->getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS)); - list myElementsList6; - - for (int i=0; ibuildSupportOnElementsFromElementList(myElementsList6,MED_FACE)); - CPPUNIT_ASSERT(mySupportOnElem->deepCompare(*myBndSup)); - CPPUNIT_ASSERT_EQUAL(MED_FACE, mySupportOnElem->getEntity()); - - list::const_iterator iteronelem = myElementsList6.begin(); - for (int i = 1; i <= 3; i++, iteronelem++) - { - CPPUNIT_ASSERT_EQUAL(i, mySupportOnElem->getValIndFromGlobalNumber(*iteronelem)); - } - - CPPUNIT_ASSERT_NO_THROW(mySupportOnNode = myMesh6->buildSupportOnNodeFromElementList(myElementsList6,MED_FACE)); - CPPUNIT_ASSERT(mySupportOnNode->deepCompare( *(myMesh6->getBoundaryElements(MED_NODE)))); - - //sets mesh fields to initial values - try - { - myMesh6->init(); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //ensure two meshes constracted from one file in two different ways are equal - CPPUNIT_ASSERT(!myMesh6->deepCompare(*myMesh4)); - - //ensure mesh is empty - CPPUNIT_ASSERT(myMesh6->getSpaceDimension() == MED_INVALID); - CPPUNIT_ASSERT(myMesh6->getNumberOfNodes() == MED_INVALID); - CPPUNIT_ASSERT(myMesh6->getCoordinateptr() == NULL); - - delete myMesh4; - delete myMesh5; - delete myMesh6; - - MESH* myMesh7 = MEDMEMTest_createTestMesh(); - vector< vector > myBndBox; - try - { - myBndBox = myMesh7->getBoundingBox(); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - cout<<"Bounding box for createTestMesh()"<getElementContainingPoint(CoorPoint); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT(idxElem != -1); - - double CoorNoPoint[3] = - { - 5.0, 0.0, -5.0 - }; //there is no such point - int idxNoElem; - try - { - idxNoElem = myMesh7->getElementContainingPoint(CoorNoPoint); - } - catch (const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT(idxNoElem == -1); -} - -int main (int argc, char** argv) -{ - MEDMEMTest_testMeshAndMeshing(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_MeshFuse.cxx b/src/MEDMEMCppTest/MEDMEMTest_MeshFuse.cxx deleted file mode 100644 index e667a48da..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_MeshFuse.cxx +++ /dev/null @@ -1,329 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// -// File : MEDMEMTest_MeshFuse.cxx -// Created : Mon Jul 13 10:35:22 2009 -// Author : Edward AGAPOV (eap) -// -#include "MEDMEMTest.hxx" -#include -#include - -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_MeshFuse.hxx" -#include "MEDMEM_DriverFactory.hxx" - -#include -#include -#include - -using namespace MEDMEM; -using namespace MED_EN; -using namespace std; - -namespace -{ - const char* bnd_elem_name = "Bnd elems"; - - /*! - * \brief Class allowing to add groups to GRID - */ - struct _GRID : public GRID - { - _GRID(const vector >& xyz_array, - const vector& coord_name, - const vector& coord_unit): - GRID( xyz_array, coord_name, coord_unit ) {} - - void addGroup(GROUP* g) - { - switch ( g->getEntity() ) { - case MED_CELL: _groupCell.push_back( g ); break; - case MED_FACE: _groupFace.push_back( g ); break; - case MED_EDGE: _groupEdge.push_back( g ); break; - case MED_NODE: _groupNode.push_back( g ); break; - default :throw MEDEXCEPTION(LOCALIZED("Bad Entity !")); - } - removeReference(); - } - }; -} - -GRID* makeGrid(double step, double x0, double y0, int nb_x, int nb_y, int nb_z = 0, double z0=0.) -{ - // make grid - int dim = nb_z ? 3 : 2; - vector > xyz_array(dim); - vector coord_name(dim); - vector unit(dim); - - double origin[] = { x0, y0, z0 }; - int size [] = { nb_x, nb_y, nb_z }; - char name = 'X'; - for ( int d = 0; d < dim; ++d, ++name ) - { - vector& coords = xyz_array[d]; - coords.reserve( size[d]+1 ); - coords.push_back( origin[d] ); - for ( int i = 0; i < size[d]; ++i ) - coords.push_back( coords.back() + step ); - - coord_name.push_back(string(1,name)); - unit.push_back("m"); - } - _GRID* grid = new _GRID( xyz_array, coord_name, unit ); - - - // make group of boundary elements - SUPPORT* boundary = grid->getBoundaryElements( dim == 3 ? MED_FACE : MED_EDGE ); - - GROUP* bnd_group = new GROUP; - bnd_group->setMesh( grid ); - bnd_group->setEntity( boundary->getEntity() ); - bnd_group->setName(bnd_elem_name); - bnd_group->setpartial("Bnd", - boundary->getNumberOfTypes(), - boundary->getNumberOfElements(MED_ALL_ELEMENTS), - boundary->getTypes(), - boundary->getNumberOfElements(), - boundary->getNumber(MED_ALL_ELEMENTS)); - grid->addGroup( bnd_group ); - - // make group on all bnd_entity's - GROUP* all_bnd = new GROUP; - all_bnd->setMesh( grid ); - all_bnd->setEntity( boundary->getEntity() ); - all_bnd->setName(STRING("all bnd #")<setAll( true ); - all_bnd->update(); - grid->addGroup( all_bnd ); - - boundary->removeReference(); - - - return grid; -} - -void MEDMEMTest::testMeshFuse() -{ - // fuse two grids: - // first | second - // - // 5 6 - // *---* - // 3| 4| 10 - // *---*---* - // 1| 2| 9| - // *---*---* - // 7| 8| - // *---* - - int gnl [] = {1,2,3,4,5,6 }; - int gnr [] = {7,8,2,9,4,10}; - const int nb_x = 1, nb_y = 2, nb_z = 3; - - // make grids - const double step = 10; - const GRID* grid_left = makeGrid(step, 0,0, nb_x,nb_y); - const GRID* grid_right = makeGrid(step, step,-step,nb_x,nb_y); - const MESH* mesh_left = grid_left->convertInMESH(); - const MESH* mesh_right = grid_right->convertInMESH(); - - // compute families - const_cast( mesh_left )->createFamilies(); - const_cast( mesh_right )->createFamilies(); - - // global node numbers - vector glob_nb_left ( gnl, ((int*)gnl) + 6 ); - vector glob_nb_right( gnr, ((int*)gnr) + 6 ); - - // fuse two 2D grids - { - MeshFuse fusion; - fusion.concatenate(mesh_left, glob_nb_left); - fusion.concatenate(mesh_right, glob_nb_right); - - const medEntityMesh sub_entity = MED_EDGE; - - // check number of nodes and elements - const int nb_common_nodes = 2; - const int expect_nb_nodes = 2 * grid_left->getNumberOfNodes() - nb_common_nodes; - CPPUNIT_ASSERT_EQUAL( expect_nb_nodes, fusion.getNumberOfNodes()); - - const int expect_nb_cells = 2 * grid_left->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT_EQUAL( expect_nb_cells, fusion.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS)); - - CPPUNIT_ASSERT_EQUAL( 7, grid_left->getNumberOfElements( sub_entity, MED_ALL_ELEMENTS )); - - const int nb_common_edges = 1; - const int expect_nb_edges = - 2 * grid_left->getNumberOfElements(sub_entity, MED_ALL_ELEMENTS) - nb_common_edges; - CPPUNIT_ASSERT_EQUAL( expect_nb_edges, fusion.getNumberOfElements(sub_entity, MED_ALL_ELEMENTS)); - - // check groups - const GROUP* bnd_edges = 0; - CPPUNIT_ASSERT_NO_THROW( bnd_edges = fusion.getGroup( bnd_elem_name )); - CPPUNIT_ASSERT( !bnd_edges->isOnAllElements() ); - - const int nb_bnd_edges = - grid_left->getGroup( bnd_elem_name )->getNumberOfElements(MED_ALL_ELEMENTS); - const int expect_nb_bnd = 2 * nb_bnd_edges - nb_common_edges; - CPPUNIT_ASSERT_EQUAL( expect_nb_bnd, bnd_edges->getNumberOfElements(MED_ALL_ELEMENTS)); - - // check families - set oldFamNames; - vector fams = mesh_left->getFamilies(sub_entity); - for (int i = 0; i< fams.size(); ++i ) oldFamNames.insert( fams[i]->getName()); - fams = mesh_right->getFamilies(sub_entity); - for (int i = 0; i< fams.size(); ++i ) oldFamNames.insert( fams[i]->getName()); - CPPUNIT_ASSERT_EQUAL( int(oldFamNames.size()), fusion.getNumberOfFamilies( sub_entity )); - } - grid_left->removeReference(); - grid_right->removeReference(); - mesh_left->removeReference(); - mesh_right->removeReference(); - - - // Fuse two 3D grids - - // both grids are 1x2x3 cells, - // the 2nd one is shifted by 1 cell along X, by -1 cell along Y and by 1 cell along Z - // so they shares 2 faces - grid_left = makeGrid(step, 0, 0, nb_x,nb_y,nb_z, 0.); - grid_right = makeGrid(step, step,-step,nb_x,nb_y,nb_z, step); - mesh_left = grid_left->convertInMESH(); - mesh_right = grid_right->convertInMESH(); - - // compute families - const_cast( mesh_left )->createFamilies(); - const_cast( mesh_right )->createFamilies(); - { - // global node numbers - int nb_nodes = grid_left->getNumberOfNodes(); - glob_nb_left.resize( nb_nodes ); - glob_nb_right.resize( nb_nodes ); - for ( int n = 0; n < nb_nodes; ++n ) - { - glob_nb_left[ n ] = n; - glob_nb_right[ n ] = n + nb_nodes; - } - for ( int z = 0; z < nb_z; ++z ) - for ( int y = 1; y <= nb_y; ++y ) - glob_nb_right[ grid_right->getNodeNumber(0,y,z)-1 ] = - glob_nb_left[ grid_left->getNodeNumber(1,y-1,z+1)-1 ]; - - MeshFuse fusion; - fusion.concatenate(mesh_left, glob_nb_left); - fusion.concatenate(mesh_right, glob_nb_right); - - const medEntityMesh sub_entity = MED_FACE; - - // check number of nodes and elements - const int nb_common_nodes = 6; - const int expect_nb_nodes = 2 * grid_left->getNumberOfNodes() - nb_common_nodes; - CPPUNIT_ASSERT_EQUAL( expect_nb_nodes, fusion.getNumberOfNodes()); - - const int expect_nb_cells = 2 * grid_left->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT_EQUAL( expect_nb_cells, fusion.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS)); - - const int grid_nb_faces = - nb_x * nb_y * (nb_z+1)+ - nb_x * (nb_y+1) * nb_z + - (nb_x+1) * nb_y * nb_z; - CPPUNIT_ASSERT_EQUAL( grid_nb_faces, - grid_left->getNumberOfElements( sub_entity, MED_ALL_ELEMENTS )); - - const int nb_common_faces = 2; - const int expect_nb_faces = - 2 * grid_left->getNumberOfElements(sub_entity, MED_ALL_ELEMENTS) - nb_common_faces; - CPPUNIT_ASSERT_EQUAL( expect_nb_faces, - fusion.getNumberOfElements(sub_entity, MED_ALL_ELEMENTS)); - - // check groups - const GROUP* bnd_faces = 0; - CPPUNIT_ASSERT_NO_THROW( bnd_faces = fusion.getGroup( bnd_elem_name )); - CPPUNIT_ASSERT( !bnd_faces->isOnAllElements() ); - - const int nb_bnd_faces = - grid_left->getGroup( bnd_elem_name )->getNumberOfElements(MED_ALL_ELEMENTS); - const int expect_nb_bnd = 2 * nb_bnd_faces - nb_common_faces; - CPPUNIT_ASSERT_EQUAL( expect_nb_bnd, bnd_faces->getNumberOfElements(MED_ALL_ELEMENTS)); - - // check families - CPPUNIT_ASSERT_EQUAL( 4, fusion.getNumberOfFamilies( sub_entity )); - } - - - - // Fuse one 3D grid and another converted to polygons - - const_cast(mesh_right)->convertToPoly(); - CPPUNIT_ASSERT_EQUAL( 0, grid_right->getNumberOfElements(MED_CELL, MED_QUAD4)); - { - MeshFuse fusion; - fusion.concatenate(mesh_left, glob_nb_left); - fusion.concatenate(mesh_right, glob_nb_right); - - const medEntityMesh sub_entity = MED_FACE; - - // check number of nodes and elements - const int nb_common_nodes = 6; - const int expect_nb_nodes = 2 * grid_left->getNumberOfNodes() - nb_common_nodes; - CPPUNIT_ASSERT_EQUAL( expect_nb_nodes, fusion.getNumberOfNodes()); - - const int expect_nb_cells = 2 * grid_left->getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS); - CPPUNIT_ASSERT_EQUAL( expect_nb_cells, - fusion.getNumberOfElements(MED_CELL, MED_ALL_ELEMENTS)); - - const int grid_nb_faces = - nb_x * nb_y * (nb_z+1)+ - nb_x * (nb_y+1) * nb_z + - (nb_x+1) * nb_y * nb_z; - CPPUNIT_ASSERT_EQUAL( grid_nb_faces, - grid_left->getNumberOfElements( sub_entity, MED_ALL_ELEMENTS )); - - const int nb_common_faces = 2; - const int expect_nb_faces = - 2 * grid_left->getNumberOfElements(sub_entity, MED_ALL_ELEMENTS) - nb_common_faces; - CPPUNIT_ASSERT_EQUAL( expect_nb_faces, - fusion.getNumberOfElements(sub_entity, MED_ALL_ELEMENTS)); - - // check groups - const GROUP* bnd_faces = 0; - CPPUNIT_ASSERT_NO_THROW( bnd_faces = fusion.getGroup( bnd_elem_name )); - CPPUNIT_ASSERT( !bnd_faces->isOnAllElements() ); - - const int nb_bnd_faces = - grid_left->getGroup( bnd_elem_name )->getNumberOfElements(MED_ALL_ELEMENTS); - // convertToPoly does not convert groups and families - const int expect_nb_bnd = 2 * nb_bnd_faces/* - nb_common_faces*/; - CPPUNIT_ASSERT_EQUAL( expect_nb_bnd, bnd_faces->getNumberOfElements(MED_ALL_ELEMENTS)); - - // check families - CPPUNIT_ASSERT_EQUAL( 4, fusion.getNumberOfFamilies( sub_entity )); - } - - grid_left->removeReference(); - grid_right->removeReference(); - mesh_left->removeReference(); - mesh_right->removeReference(); - -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_ModulusArray.cxx b/src/MEDMEMCppTest/MEDMEMTest_ModulusArray.cxx deleted file mode 100644 index 26b75db13..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_ModulusArray.cxx +++ /dev/null @@ -1,181 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include - -#include "MEDMEM_ModulusArray.hxx" -#include "MEDMEM_define.hxx" - -#include -#include - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (4), defined in MEDMEM_ModulusArray.hxx: - * class MEDMODULUSARRAY { - * (+) MEDMODULUSARRAY(int length, const int * array); - * (+) MEDMODULUSARRAY(int vertexLength, int totalLength, const int * array); - * (+) ~MEDMODULUSARRAY(); - * (+) const int operator[](const int &i) const; - * (+) int compare(const MEDMODULUSARRAY &modulusArray) const; - * } - */ -void MEDMEMTest::testModulusArray() -{ - - int array[5]={0,1,2,1,4} ; - MEDMODULUSARRAY modulusArray(5,array); - - for(int i=-10, j=0; i<15; i++, j++) - CPPUNIT_ASSERT_EQUAL( array[ j%5 ], modulusArray[i] ); - - // test compare - int ret ; - - int array2[5]={1,4,0,1,2} ; - MEDMODULUSARRAY modulusArray2(5,array2); - - ret=modulusArray2.compare(modulusArray); - - CPPUNIT_ASSERT_MESSAGE("Two identical arrays - KO", ret == 1); - - int array3[5]={1,2,1,0,4} ; - MEDMODULUSARRAY modulusArray3(5,array3) ; - ret=modulusArray3.compare(modulusArray); - - CPPUNIT_ASSERT_MESSAGE("Two arrays are in reverse order - KO",ret == -1); - - int array4[6]={1,2,1,0} ; - MEDMODULUSARRAY modulusArray4(4,array4) ; - ret=modulusArray4.compare(modulusArray); - - CPPUNIT_ASSERT_MESSAGE("Two arrays are have different size - KO",ret == 0); - - int array5[5]={1,2,1,0,1} ; - MEDMODULUSARRAY modulusArray5(5,array5) ; - - ret=modulusArray5.compare(modulusArray); - - CPPUNIT_ASSERT_MESSAGE("Two different arrays, same size - KO",ret == 0); - - // test small array : - - // 1 - int array6[1]={1} ; - MEDMODULUSARRAY modulusArray6(1,array6); - - for(int i=-10;i<15;i++) - CPPUNIT_ASSERT_EQUAL( 1, modulusArray6[i] ); - - - int array7[1]={1} ; - MEDMODULUSARRAY modulusArray7(1,array7); - ret=modulusArray6.compare(modulusArray7); - - CPPUNIT_ASSERT_MESSAGE("Two identical arrays - KO", ret == 1); - - int array8[1]={2} ; - MEDMODULUSARRAY modulusArray8(1,array8); - ret=modulusArray6.compare(modulusArray8); - - CPPUNIT_ASSERT_MESSAGE("Two different arrays - KO",ret == 0); - - // 2 - int array60[2]={1,2} ; - MEDMODULUSARRAY modulusArray60(2,array60); - - for(int i=-10, j = 0;i<15;i++,j++) - CPPUNIT_ASSERT_EQUAL( array60[ j%2 ], modulusArray60[i] ); - - int array70[2]={1,2} ; - MEDMODULUSARRAY modulusArray70(2,array70); - - ret=modulusArray60.compare(modulusArray70); - - CPPUNIT_ASSERT_MESSAGE("Same arrays, same order - KO",ret == 1); - - int array80[2]={2,2} ; - MEDMODULUSARRAY modulusArray80(2,array80); - ret=modulusArray60.compare(modulusArray80); - - CPPUNIT_ASSERT_MESSAGE("Different arrays - KO",ret == 0); - - int array90[2]={2,1} ; - MEDMODULUSARRAY modulusArray90(2,array90); - - ret=modulusArray60.compare(modulusArray90); - - CPPUNIT_ASSERT_MESSAGE("Two arrays are in reverse order - KO",ret == -1); - - //test not vertex nodes - int array100[2]={1,2} ; - MEDMODULUSARRAY modulusArray100(2,2,array100); // == MEDMODULUSARRAY(2,array100); - - ret = modulusArray60.compare(modulusArray100); - - CPPUNIT_ASSERT_MESSAGE("Same arrays, same order - KO", ret == 1); - - // check comparison of equal arrays, containing non-vertex nodes - - int array110[4] = {1,2,4,3}; - MEDMODULUSARRAY modulusArray110(2,4,array110); - - int array120[4] = {1,2,4,3}; - MEDMODULUSARRAY modulusArray120(2,4,array120); - - int array130[4] = {1,2,3,4}; - MEDMODULUSARRAY modulusArray130(2,4,array130); - - // same order of non-vertex nodes - CPPUNIT_ASSERT_NO_THROW(ret = modulusArray120.compare(modulusArray110)); - CPPUNIT_ASSERT_MESSAGE("Same arrays, same order - KO", ret == 1); - - // different order of non-vertex nodes - CPPUNIT_ASSERT_NO_THROW(ret = modulusArray130.compare(modulusArray110)); - CPPUNIT_ASSERT_MESSAGE("Same arrays, same order - KO", ret == 1); - - // check comparison of different arrays, containing non-vertex nodes - - // difference is in vertex nodes - int array140[4] = {1,5,4,3}; - MEDMODULUSARRAY modulusArray140 (2,4,array140); - - CPPUNIT_ASSERT_NO_THROW(ret = modulusArray120.compare(modulusArray140)); - CPPUNIT_ASSERT_MESSAGE("Different arrays - KO", ret == 0); - - // difference is in non-vertex nodes - int array150[4] = {1,2,4,5}; - MEDMODULUSARRAY modulusArray150 (2,4,array150); - - CPPUNIT_ASSERT_NO_THROW(ret = modulusArray120.compare(modulusArray150)); - CPPUNIT_ASSERT_MESSAGE("Different arrays - KO", ret == 0); - - // check that operator[] returns only vertex nodes - CPPUNIT_ASSERT_EQUAL(1, modulusArray120[0]); - CPPUNIT_ASSERT_EQUAL(2, modulusArray120[1]); - CPPUNIT_ASSERT_EQUAL(1, modulusArray120[2]); - CPPUNIT_ASSERT_EQUAL(2, modulusArray120[3]); - CPPUNIT_ASSERT_EQUAL(1, modulusArray120[4]); - CPPUNIT_ASSERT_EQUAL(2, modulusArray120[5]); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_PartialDescendingConnectivity.cxx b/src/MEDMEMCppTest/MEDMEMTest_PartialDescendingConnectivity.cxx deleted file mode 100644 index ac90bdb16..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_PartialDescendingConnectivity.cxx +++ /dev/null @@ -1,100 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" - -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Field.hxx" - -#include - -void MEDMEMTest::testPartialDescendingConnectivity() -{ - double coords[24]= {0., 0., 3., 0., 0., 0., 0., 3., 3., 0., 3., 0., 3., 0., 3., 3., 0., 0., 3., 3., 3., 3., 3., 0.}; - - const int connNodalCellClassical[8]={2, 6, 5, 1, 4, 8, 7, 3}; - - const int connNodalFaceClassical[24]={3, 1, 5, 7, 5, 6, 8, 7, 2, 1, 3, 4, 2, 4, 8, 6, 8, 4, 3, 7, 2, 6, 5, 1}; - - const int connNodalEdgeClassical[24]={4,8,8,7,2,1,1,3,5,7,2,6,1,5,6,8,6,5,4,3,3,7,2,4}; - // - - MESHING* myMesh = new MESHING; - myMesh->setName( "TESTMESH" ); - const int nNodes=8; - myMesh->setCoordinates(3, nNodes, coords, "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - myMesh->setCoordinatesNames(coordname); - string coordunit[3] = { "m", "m", "m" }; - myMesh->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]={MED_EN::MED_HEXA8}; - const int nbOfCellElts[1]={1}; - myMesh->setNumberOfTypes(1,MED_EN::MED_CELL); - myMesh->setTypes(classicalTypesCell,MED_EN::MED_CELL); - myMesh->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //Face connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesFace[1]={MED_EN::MED_QUAD4}; - const int nbOfFaceElts[1]={6}; - myMesh->setNumberOfTypes(1,MED_EN::MED_FACE); - myMesh->setTypes(classicalTypesFace,MED_EN::MED_FACE); - myMesh->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE); - // - const MED_EN::medGeometryElement classicalTypesEdge[1]={MED_EN::MED_SEG2}; - const int nbOfEdgeElts[1]={12}; - myMesh->setNumberOfTypes(1,MED_EN::MED_EDGE); - myMesh->setTypes(classicalTypesEdge,MED_EN::MED_EDGE); - myMesh->setNumberOfElements(nbOfEdgeElts,MED_EN::MED_EDGE); - //All cell conn - myMesh->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_HEXA8,connNodalCellClassical); - //All face conn - myMesh->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_QUAD4,connNodalFaceClassical); - //All edge conn - myMesh->setConnectivity(MED_EN::MED_EDGE,MED_EN::MED_SEG2,connNodalEdgeClassical); - // - /*const int *ConnNodal = */myMesh->getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS); - /*const int *ConnNodalIndex = */myMesh->getConnectivityIndex(MED_NODAL,MED_CELL); - - const int *Conn = myMesh->getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS); - const int *ConnIndex = myMesh->getConnectivityIndex(MED_DESCENDING,MED_CELL); - int lgth=myMesh->getConnectivityLength(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS); - CPPUNIT_ASSERT_EQUAL(6,lgth); - CPPUNIT_ASSERT_EQUAL(1,ConnIndex[0]); - CPPUNIT_ASSERT_EQUAL(7,ConnIndex[1]); - int ConnTmp[6]; - copy(Conn,Conn+6,ConnTmp); - for(int i=0;i<6;i++) - ConnTmp[i]=abs(ConnTmp[i]); - int sum=accumulate(ConnTmp,ConnTmp+6,0); - CPPUNIT_ASSERT_EQUAL(21,sum);//1+2+3+4+5+6 - CPPUNIT_ASSERT_EQUAL(6, *max_element(ConnTmp,ConnTmp+6)); - CPPUNIT_ASSERT_EQUAL(1, *min_element(ConnTmp,ConnTmp+6)); - // - const int *ConnFaceNodal = myMesh->getConnectivity(MED_NODAL,MED_FACE,MED_ALL_ELEMENTS); - const int *ConnFaceNodalIndex = myMesh->getConnectivityIndex(MED_NODAL,MED_FACE); - const int expected3[7]={1,5,9,13,17,21,25}; - int i; - for(i=0;i<24;i++) - CPPUNIT_ASSERT_EQUAL(connNodalFaceClassical[i],ConnFaceNodal[i]); - for(i=0;i<7;i++) - CPPUNIT_ASSERT_EQUAL(expected3[i],ConnFaceNodalIndex[i]); - // - myMesh->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_PointerOf.cxx b/src/MEDMEMCppTest/MEDMEMTest_PointerOf.cxx deleted file mode 100644 index 3564e8d95..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_PointerOf.cxx +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include "MEDMEM_PointerOf.hxx" -#include "MEDMEM_define.hxx" - -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -/*! - * Check methods (12), defined in MEDMEM_PointerOf.hxx: - * template class PointerOf { - * (+) PointerOf(); - * (+) ~PointerOf(); - * (+) PointerOf(const int &size); - * (+) PointerOf(const T *pointer); - * (+) PointerOf(const int &size, const T *pointer); - * (+) PointerOf(const PointerOf & pointerOf); - * (NOT COMPILABLE!!!) PointerOf(const int &size, const PointerOf & pointerOf); - * (+) operator T*(); - * (+) operator const T*() const; - * (+) 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); - * } - * - */ -void MEDMEMTest::testPointerOf() -{ - const int size=10; - PointerOf P; - - try - { - P.set(0); - CPPUNIT_ASSERT((int *)P == NULL); - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - - try - { - P.set(-1 * size); - CPPUNIT_ASSERT((int *)P == NULL); - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - - try - { - P.set(size); - CPPUNIT_ASSERT((int *)P != NULL); - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - - for (int i=0; i < size; i++) - { - P[i]=i; - } - - PointerOf P2(10); - - P2=P; - for (int i=0; i < size; i++) - { - SCRUTE_MED(P2[i]); - } - - int * p=new int [size]; - for (int i=0; i < size; i++) - { - p[i]=i*10; - } - - P2.set(p); - PointerOf P3(p); - - for (int i=0; i < size; i++) - { - CPPUNIT_ASSERT_EQUAL(P2[i],P3[i]); - } - - const PointerOf P4(p); - for (int i=0; i < size; i++) - { - CPPUNIT_ASSERT_EQUAL(P4[i],p[i]); - } - - const PointerOf P5(P4); - CPPUNIT_ASSERT((const int*)P5 != NULL); - - const PointerOf P7(10, p); - - //{ - //#ifdef ENABLE_COMPILATION_ERRORS - //PointerOf PP1 (10, p); - //PointerOf PP2 (10, PP1); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_FAIL("Can not create: PointerOf(const int &size, const PointerOf & pointerOf)"); - //#endif - //} - - //CPPUNIT_ASSERT_THROW(P3.set(0, p),MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(P3.set(0, p)); - - P.setShallowAndOwnership( p ); - for (int i=0; i < size; i++) - { - CPPUNIT_ASSERT_EQUAL(P[i],p[i]); - } - - //delete [] p; not needed - P already owns p and will delete it when the scope is over -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_PorflowMeshDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_PorflowMeshDriver.cxx deleted file mode 100644 index f9811124e..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_PorflowMeshDriver.cxx +++ /dev/null @@ -1,311 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -/*! - * Check methods (18), defined in MEDMEM_PorflowMeshDriver.hxx: - * class PORFLOW_MESH_DRIVER : public GENDRIVER { - * (+) PORFLOW_MESH_DRIVER(); - * (+) PORFLOW_MESH_DRIVER(const string & fileName, MESH * ptrMesh, MED_EN::med_mode_acces accessMode); - * (+) PORFLOW_MESH_DRIVER(const PORFLOW_MESH_DRIVER & driver); - * (+) virtual ~PORFLOW_MESH_DRIVER(); - * (+) void open() throw (MEDEXCEPTION); - * (+) void close() throw (MEDEXCEPTION); - * (-) virtual void write(void) const = 0; - * (+) virtual void read (void) = 0; - * (+) void setMeshName(const string & meshName); - * (+) string getMeshName() const; - * } - * class PORFLOW_MESH_RDONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER { - * (+) PORFLOW_MESH_RDONLY_DRIVER(); - * (+) PORFLOW_MESH_RDONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver); - * (+) virtual ~PORFLOW_MESH_RDONLY_DRIVER(); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * } - * class PORFLOW_MESH_WRONLY_DRIVER : public virtual PORFLOW_MESH_DRIVER { - * (+) PORFLOW_MESH_WRONLY_DRIVER(); - * (+) PORFLOW_MESH_WRONLY_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver); - * (+) virtual ~PORFLOW_MESH_WRONLY_DRIVER(); - * (NOT IMPLEMENTED!!!) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * } - * class PORFLOW_MESH_RDWR_DRIVER : public PORFLOW_MESH_RDONLY_DRIVER, public PORFLOW_MESH_WRONLY_DRIVER { - * (+) PORFLOW_MESH_RDWR_DRIVER(); - * (+) PORFLOW_MESH_RDWR_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver); - * (+) ~PORFLOW_MESH_RDWR_DRIVER(); - * (CALLS PORFLOW_MESH_WRONLY_DRIVER::write()) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * } - */ -void MEDMEMTest::testPorflowMeshDriver() -{ - MESH *aMesh = new MESH; - MESH *aMesh_1 = new MESH; - - string filename_rd = getResourceFile("Case1.inp"); - string filename_wr = makeTmpFile("myWr_Case1.inp"); - string meshname = "Case1"; - string newmeshname = "new" + meshname; - string fileNotExistsName_rd = "notExists.inp"; - string fileNotExistsName_wr = "/path_not_exists/file_not_exists.inp"; - string filename_rdwr = makeTmpFile("myRdWr_Case1.inp", filename_rd); - string res_file1 = makeTmpFile("Case1.xyz", getResourceFile("Case1.xyz")); - string res_file2 = makeTmpFile("Case1.cnc", getResourceFile("Case1.cnc")); - - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - aRemover.Register(filename_rdwr); - aRemover.Register(res_file1); - aRemover.Register(res_file2); - - //-----------------------------Test READ ONLY part---------------------------------------// - { - { - //Creation a incorrect Porflow read only driver - PORFLOW_MESH_RDONLY_DRIVER *aInvalidPorflowRdDriver = - new PORFLOW_MESH_RDONLY_DRIVER(fileNotExistsName_rd, aMesh); - - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidPorflowRdDriver->open(), MEDEXCEPTION); - - delete aInvalidPorflowRdDriver; - } - - //Creation a correct Porflow read only driver (normal constructor) - PORFLOW_MESH_RDONLY_DRIVER *aPorflowRdDriver = new PORFLOW_MESH_RDONLY_DRIVER(filename_rd, aMesh); - - //Check driver - CPPUNIT_ASSERT(aPorflowRdDriver); - - //Trying read mesh from file, if file is not open - CPPUNIT_ASSERT_THROW(aPorflowRdDriver->read(), MEDEXCEPTION); - - //Test open() method - // commented by skl - must be exception since thid file is - // opened yet and such case is tested below - //CPPUNIT_ASSERT_NO_THROW(aPorflowRdDriver->open()); - - //#ifdef ENABLE_FORCED_FAILURES - //Trying open file secondary - //CPPUNIT_ASSERT_THROW(aPorflowRdDriver->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_NO_THROW(aPorflowRdDriver->open()); - //This case work, but it corrypt driver - //#endif - - //Test read() method - CPPUNIT_ASSERT_NO_THROW(aPorflowRdDriver->read()); - - //Check Mesh - CPPUNIT_ASSERT(aMesh); - - //Trying fill not empty mesh - CPPUNIT_ASSERT_THROW(aPorflowRdDriver->read(), MEDEXCEPTION); - - //Test write() method for Porflow RDONLY Driver - CPPUNIT_ASSERT_THROW(aPorflowRdDriver->write(), MEDEXCEPTION); - - //Test setMeshName() and getMeshName() - CPPUNIT_ASSERT_NO_THROW(aPorflowRdDriver->setMeshName(meshname)); - CPPUNIT_ASSERT_EQUAL(meshname, aPorflowRdDriver->getMeshName()); - - //Test close() method - CPPUNIT_ASSERT_NO_THROW(aPorflowRdDriver->close()); - - //Default constructor - PORFLOW_MESH_RDONLY_DRIVER aPorflowRdDriverCpy_1; - // TO DO - - //Test copy constructor - PORFLOW_MESH_RDONLY_DRIVER aPorflowRdDriverCpy_2 (*aPorflowRdDriver); - - //Test (bool operator ==) defined GENDRIVER class in MEDMEM_GenDriver.hxx - CPPUNIT_ASSERT(aPorflowRdDriverCpy_2.GENDRIVER::operator==(*aPorflowRdDriver)); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream rostr1, rostr2; - rostr1 << *aPorflowRdDriver; - rostr2 << aPorflowRdDriverCpy_2; - CPPUNIT_ASSERT(rostr1.str() != ""); - CPPUNIT_ASSERT_EQUAL(rostr1.str() , rostr2.str()); - - delete aPorflowRdDriver; - } - - //---------------------------Test WRITE ONLY part-------------------------------------// - { - { - //Creation a incorrect Porflow write only driver - PORFLOW_MESH_WRONLY_DRIVER *aInvalidPorflowWrDriver = - new PORFLOW_MESH_WRONLY_DRIVER(fileNotExistsName_wr, aMesh); - - //Test case: trying open non existing file - CPPUNIT_ASSERT_THROW(aInvalidPorflowWrDriver->open(), MEDEXCEPTION); - - delete aInvalidPorflowWrDriver; - } - - //Creation a correct write only driver - PORFLOW_MESH_WRONLY_DRIVER *aPorflowWrDriver = new PORFLOW_MESH_WRONLY_DRIVER(filename_wr, aMesh); - - //Check driver - CPPUNIT_ASSERT(aPorflowWrDriver); - - //Test case: trying write mesh to file, if file is not open - CPPUNIT_ASSERT_THROW(aPorflowWrDriver->write(), MEDEXCEPTION); - - //Test open() method - //#ifndef ENABLE_FORCED_FAILURES - FILE *tmpFile = fopen(filename_wr.data(), "w"); - if ( tmpFile ) - fclose(tmpFile); - //#endif - CPPUNIT_ASSERT_NO_THROW(aPorflowWrDriver->open()); - - //Test case: trying open file secondary. - CPPUNIT_ASSERT_THROW(aPorflowWrDriver->open(), MEDEXCEPTION); - - //Test write() method - //#ifdef ENABLE_FORCED_FAILURES - //Write method is not implemented - //CPPUNIT_ASSERT_NO_THROW(aPorflowWrDriver->write()); - CPPUNIT_ASSERT_THROW(aPorflowWrDriver->write(), MEDEXCEPTION); - //#endif - - //Test read() method for WRITE ONLY driver - CPPUNIT_ASSERT_THROW(aPorflowWrDriver->read(), MEDEXCEPTION); - - //Test setMeshName() and getMeshName() - CPPUNIT_ASSERT_NO_THROW(aPorflowWrDriver->setMeshName(newmeshname)); - CPPUNIT_ASSERT_EQUAL(newmeshname, aPorflowWrDriver->getMeshName()); - - CPPUNIT_ASSERT_NO_THROW(aPorflowWrDriver->close()); - - //Default constructor - PORFLOW_MESH_WRONLY_DRIVER aPorflowWrDriverCpy_1; - - //Test copy constructor - PORFLOW_MESH_WRONLY_DRIVER aPorflowWrDriverCpy_2 (*aPorflowWrDriver); - - //Test (bool operator ==) defined in GENDRIVER class - CPPUNIT_ASSERT(aPorflowWrDriverCpy_2.GENDRIVER::operator==(*aPorflowWrDriver)); - - //Test (friend ostream & operator <<) defined in GENDRIVER class - ostringstream wostr1, wostr2; - wostr1 << *aPorflowWrDriver; - wostr2 << aPorflowWrDriverCpy_2; - CPPUNIT_ASSERT(wostr1.str() != ""); - CPPUNIT_ASSERT(wostr1.str() == wostr2.str()); - - delete aPorflowWrDriver; - } - - //------------------------Test READ / WRITE part------------------------------------// - { - { - //Creation a incorrect read/write driver - PORFLOW_MESH_RDWR_DRIVER *aInvalidPorflowRdWrDriver = - new PORFLOW_MESH_RDWR_DRIVER(fileNotExistsName_wr, aMesh_1); - - //Test case: trying open non existing file - CPPUNIT_ASSERT_THROW(aInvalidPorflowRdWrDriver->open(), MEDEXCEPTION); - - delete aInvalidPorflowRdWrDriver; - } - - //Creation a correct read/write driver - PORFLOW_MESH_RDWR_DRIVER *aPorflowRdWrDriver = new PORFLOW_MESH_RDWR_DRIVER(filename_rdwr, aMesh_1); - - //Check driver - CPPUNIT_ASSERT(aPorflowRdWrDriver); - - //Test case: trying write mesh to file, if file is not open - CPPUNIT_ASSERT_THROW(aPorflowRdWrDriver->write(), MEDEXCEPTION); - - //Test case: trying read mesh from file, if file is not open - CPPUNIT_ASSERT_THROW(aPorflowRdWrDriver->read(), MEDEXCEPTION); - - //Test open() method - CPPUNIT_ASSERT_NO_THROW(aPorflowRdWrDriver->open()); - - //Test case: trying open file secondary. - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) This case work, but corrupt driver - CPPUNIT_ASSERT_THROW(aPorflowRdWrDriver->open(), MEDEXCEPTION); - //#endif - - //Test read() method - CPPUNIT_ASSERT_NO_THROW(); - CPPUNIT_ASSERT_NO_THROW(aPorflowRdWrDriver->read()); - - //Test write() method - //aPorflowRdWrDriver->setMeshName(newmeshname); - //aMesh->setName(newmeshname); - //CPPUNIT_ASSERT_NO_THROW(aPorflowRdWrDriver->write()); - //Write method is not implemented - //#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_FAIL("PORFLOW_MESH_RDWR_DRIVER::write() method not implemented"); - //#endif - - //Check Mesh - CPPUNIT_ASSERT(aMesh); - - CPPUNIT_ASSERT_NO_THROW(aPorflowRdWrDriver->close()); - - //Default constructor - PORFLOW_MESH_RDWR_DRIVER aPorflowRdWrDriverCpy_1; - // TO DO - - //Test copy constructor - PORFLOW_MESH_RDWR_DRIVER aPorflowRdWrDriverCpy_2 (*aPorflowRdWrDriver); - - //Test (bool operator ==) defined in GENDRIVER class - CPPUNIT_ASSERT(aPorflowRdWrDriverCpy_2.GENDRIVER::operator==(*aPorflowRdWrDriver)); - - //Test (friend ostream & operator <<) defined in GENDRIVER class - ostringstream rwostr1, rwostr2; - rwostr1 << *aPorflowRdWrDriver; - rwostr2 << aPorflowRdWrDriverCpy_2; - CPPUNIT_ASSERT(rwostr1.str() != ""); - CPPUNIT_ASSERT(rwostr1.str() == rwostr2.str()); - - delete aPorflowRdWrDriver; - } - - //Delete all objects - aMesh->removeReference(); - aMesh_1->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Remapper.cxx b/src/MEDMEMCppTest/MEDMEMTest_Remapper.cxx deleted file mode 100644 index d7adcd6bb..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Remapper.cxx +++ /dev/null @@ -1,806 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" - -#include "MEDMEM_Remapper.hxx" -#include "MEDMEM_Meshing.hxx" - -#include "MEDNormalizedUnstructuredMesh.txx" -#include "Interpolation3D.txx" - -#include -#include -//#include - -// namespace MEDMEMTest -// { -void MEDMEMTest::test_RemapperP0P0() -{ - std::string sourcename=getResourceFile("square1.med"); - MEDMEM::MESH *source_mesh=new MEDMEM::MESH (MED_DRIVER,sourcename,"Mesh_2"); - - std::string targetname=getResourceFile("square2.med"); - MEDMEM::MESH *target_mesh=new MEDMEM::MESH (MED_DRIVER,targetname,"Mesh_3"); - - int nbcomp=3; - - const MEDMEM::SUPPORT *source_support=source_mesh->getSupportOnAll( MED_EN::MED_CELL ); - MEDMEM::FIELD *source_field=new MEDMEM::FIELD(source_support,nbcomp); - double* sourcevalue=const_cast(source_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - sourcevalue[i]=1.0; - - const MEDMEM::SUPPORT *target_support=target_mesh->getSupportOnAll( MED_EN::MED_CELL ); - MEDMEM::FIELD *target_field=new MEDMEM::FIELD(target_support,nbcomp); - double* targetvalue=const_cast(target_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - targetvalue[i]=0.0; - - - MEDMEM_REMAPPER remapper; - const std::string intersectiontype = "IntersectionType"; - std::string convex = "Convex"; - remapper.setOptionDouble("Precision",1.e-8); - remapper.setOptionString(intersectiontype,convex); - remapper.setOptionInt("PrintLevel",1); - remapper.prepare(*source_mesh,*target_mesh,"P0P0"); - remapper.transfer(*source_field,*target_field); - - //MN: Old tests - MEDMEM::FIELD *source_areas=source_mesh->getArea(source_support); - MEDMEM::FIELD *target_areas=target_mesh->getArea(target_support); - //MEDMEMTest::absField(*source_areas); //absolute value - //MEDMEMTest::absField(*target_areas); //absolute value - - //target square is in reverse order as compared to initial square - double source_integral=source_field->normL2(nbcomp,source_areas); - double target_integral=target_field->normL2(nbcomp,target_areas); - - CPPUNIT_ASSERT_DOUBLES_EQUAL(source_integral,target_integral,1e-10); - - //MN: Transfer test - double max = -2; - double min = 2; - for(int i = 0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( targetvalue[i] >max) max = targetvalue[i]; - if( targetvalue[i] getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( sourcevalue[i] >max) max = sourcevalue[i]; - if( sourcevalue[i] *newTargetField =remapper.transferField(*source_field); - MEDMEM::FIELD *newSourceField =remapper.reverseTransferField(*target_field); - sourcevalue=const_cast((*newSourceField).getValue()); - targetvalue=const_cast((*newTargetField).getValue()); - max = -2; - min = 2; - for(int i = 0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( sourcevalue[i] >max) max = sourcevalue[i]; - if( sourcevalue[i] getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( targetvalue[i] >max) max = targetvalue[i]; - if( targetvalue[i] removeReference(); - newSourceField->removeReference(); - newTargetField->removeReference(); - target_mesh->removeReference(); - source_areas->removeReference(); - target_areas->removeReference(); - target_field->removeReference(); - source_mesh->removeReference(); -} - -void MEDMEMTest::test_RemapperP1P1() -{ - std::string sourcename=getResourceFile("square1.med"); - MEDMEM::MESH *source_mesh=new MEDMEM::MESH (MED_DRIVER,sourcename,"Mesh_2"); - - std::string targetname=getResourceFile("square2.med"); - MEDMEM::MESH *target_mesh=new MEDMEM::MESH (MED_DRIVER,targetname,"Mesh_3"); - - int nbcomp=2; - - const MEDMEM::SUPPORT *source_support=source_mesh->getSupportOnAll( MED_EN::MED_NODE ); - MEDMEM::FIELD *source_field=new MEDMEM::FIELD(source_support,nbcomp); - double* sourcevalue=const_cast(source_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - sourcevalue[i]=1.0; - - const MEDMEM::SUPPORT *target_support=target_mesh->getSupportOnAll( MED_EN::MED_NODE ); - MEDMEM::FIELD *target_field=new MEDMEM::FIELD(target_support,nbcomp); - double* targetvalue=const_cast(target_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - targetvalue[i]=-0.0001; - - - MEDMEM_REMAPPER remapper; - remapper.prepare(*source_mesh,*target_mesh,"P1P1"); - remapper.transfer(*source_field,*target_field); - - double max = -2; - double min = 2; - for(int i = 0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( targetvalue[i] >max) max = targetvalue[i]; - if( targetvalue[i] getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( sourcevalue[i] >max) max = sourcevalue[i]; - if( sourcevalue[i] removeReference(); - source_mesh->removeReference(); - target_field->removeReference(); - target_mesh->removeReference(); -} - - -void MEDMEMTest::test_RemapperP1P0() -{ - std::string sourcename=getResourceFile("square1.med"); - MEDMEM::MESH *source_mesh=new MEDMEM::MESH (MED_DRIVER,sourcename,"Mesh_2"); - - std::string targetname=getResourceFile("square2.med"); - MEDMEM::MESH *target_mesh=new MEDMEM::MESH (MED_DRIVER,targetname,"Mesh_3"); - - int nbcomp=3; - const MEDMEM::SUPPORT *source_support=source_mesh->getSupportOnAll( MED_EN::MED_NODE ); - MEDMEM::FIELD *source_field=new MEDMEM::FIELD(source_support,nbcomp); - double* sourcevalue=const_cast(source_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - sourcevalue[i]=1.0; - - const MEDMEM::SUPPORT *target_support=target_mesh->getSupportOnAll( MED_EN::MED_CELL ); - MEDMEM::FIELD *target_field=new MEDMEM::FIELD(target_support,nbcomp); - double* targetvalue=const_cast(target_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - targetvalue[i]=0.0; - - - MEDMEM_REMAPPER remapper; - remapper.prepare(*source_mesh,*target_mesh,"P1P0"); - target_mesh->removeReference(); - source_mesh->removeReference(); - remapper.transfer(*source_field,*target_field); - - double max = -2; - double min = 2; - for(int i = 0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( targetvalue[i] >max) max = targetvalue[i]; - if( targetvalue[i] getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( sourcevalue[i] >max) max = sourcevalue[i]; - if( sourcevalue[i] removeReference(); - target_field->removeReference(); -} - -void MEDMEMTest::test_RemapperP0P1() -{ - std::string sourcename=getResourceFile("square1.med"); - MEDMEM::MESH *source_mesh=new MEDMEM::MESH (MED_DRIVER,sourcename,"Mesh_2"); - - std::string targetname=getResourceFile("square2.med"); - MEDMEM::MESH *target_mesh=new MEDMEM::MESH (MED_DRIVER,targetname,"Mesh_3"); - - int nbcomp=4; - const MEDMEM::SUPPORT *source_support=source_mesh->getSupportOnAll( MED_EN::MED_CELL ); - MEDMEM::FIELD *source_field=new MEDMEM::FIELD(source_support,nbcomp); - double* sourcevalue=const_cast(source_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - sourcevalue[i]=1.0; - - const MEDMEM::SUPPORT *target_support=target_mesh->getSupportOnAll( MED_EN::MED_NODE ); - MEDMEM::FIELD *target_field=new MEDMEM::FIELD(target_support,nbcomp); - double* targetvalue=const_cast(target_field->getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - targetvalue[i]=0.0; - - - MEDMEM_REMAPPER remapper; - remapper.prepare(*source_mesh,*target_mesh,"P0P1"); - remapper.transfer(*source_field,*target_field); - - double max = -2; - double min = 2; - for(int i = 0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( targetvalue[i] >max) max = targetvalue[i]; - if( targetvalue[i] getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)*nbcomp; i++) - { - if( sourcevalue[i] >max) max = sourcevalue[i]; - if( sourcevalue[i] removeReference(); - target_field->removeReference(); - target_mesh->removeReference(); - source_mesh->removeReference(); -} - -namespace -{ - MESH * build3DSourceMesh1() - { - const double coords[84]= - { - 100.0, 100.0, 0.0, 100.0, 100.0, 100.0, 100.0, 0.0, 100.0, 100.0, 0.0, 0.0, 0.0, 100.0, 0.0, - 0.0, 100.0, 100.0, 0.0, 0.0, 100.0, 0.0, 0.0, 0.0, 100.0, 100.0, 200.0, 100.0, 0.0, 200.0, - 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0, 0.0, 100.0, 200.0, 100.0, 0.0, 200.0, 0.0, - 0.0, 200.0, 100.0, 100.0, 200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 100.0, 0.0, 200.0, 100.00000000833332, - 100.00000000833332, 200.0, 0.0, 100.0, 200.0, 0.0, 0.0, 200.0, 100.0, 200.0, 200.0, 0.0, 200.0, 200.0, - 200.0, 0.0, 200.0, 200.0, 100.0, 200.0, 200.0, 200.0, 149.999999970343, 149.9999999874621, 49.999999881628682 - }; - - const int conn[212]= - { - 26, 28, 14, 20, 19, 4, 21, 22, 6, 11, 18, 2, 2, 4, 1, 8, 19, 2, 1, 28, 13, 28, 14, 25, - 26, 20, 17, 27, 2, 3, 7, 9, 16, 14, 13, 6, 25, 14, 26, 28, 11, 12, 10, 7, 20, 9, 24, 2, - 23, 9, 24, 20, 17, 14, 18, 2, 7, 10, 11, 9, 14, 18, 6, 16, 6, 5, 2, 13, 19, 1, 25, 28, - 20, 21, 19, 2, 8, 7, 6, 2, 5, 13, 16, 15, 26, 28, 20, 19, 2, 20, 17, 14, 21, 20, 24, 2, - 28, 13, 2, 1, 7, 6, 2, 11, 5, 6, 2, 8, 13, 28, 2, 14, 6, 16, 5, 13, 20, 17, 27, 23, 14, - 6, 18, 2, 2, 4, 8, 3, 14, 6, 2, 13, 19, 2, 4, 1, 9, 24, 3, 10, 4, 2, 19, 21, 2, 28, 20, - 14, 25, 26, 19, 28, 26, 17, 20, 14, 8, 2, 3, 7, 4, 2, 21, 3, 9, 17, 18, 2, 8, 5, 1, 2, 19, - 20, 2, 28, 28, 13, 1, 25, 10, 7, 3, 9, 2, 5, 1, 13, 20, 17, 23, 9, 9, 3, 24, 2, 2, 17, 20, - 9, 21, 3, 2, 24, 11, 2, 7, 9, 11, 9, 18, 2 - }; - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=28; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN", MED_EN::MED_FULL_INTERLACE); - std::string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - std::string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]={MED_EN::MED_TETRA4}; - const int nbOfCellElts[1]={53}; - meshing->setNumberOfTypes(1,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_TETRA4,conn); - return meshing; - } - - MESH * build3DTargetMesh1() - { - const double coords[24]= - { - 200.0, 200.0, 0.0, 200.0, 200.0, 200.0, 200.0, 0.0, 0.0, 200.0, 0.0, 200.0, - 0.0, 200.0, 0.0, 0.0, 200.0, 200.0, 0.0, 0.0, 0.0, 0.0, 0.0, 200.0 - }; - - const int conn[20]= - { - 6, 7, 4, 1, 2, 4, 1, 6, 4, 7, 6, 8, 7, 5, 1, 6, 7, 4, 1, 3 - }; - - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=8; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",MED_EN::MED_FULL_INTERLACE); - std::string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - std::string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]={MED_EN::MED_TETRA4}; - const int nbOfCellElts[1]={5}; - meshing->setNumberOfTypes(1,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_TETRA4,conn); - return meshing; - } - - MESH * build1DTargetMesh1() - { - double coords[36]= - { - 25.,25.,0., 25.,25.,50., 25.,25.,200., 75.,25.,0., 75.,25.,50., 75.,25.,200., - 25.,125.,0., 25.,125.,50., 25.,125.,200., 125.,125.,0., 125.,125.,50., 125.,125.,200. - }; - const int conn[16]= - { - 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 8, 9, 10, 11, 11, 12 - }; - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=12; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",MED_EN::MED_FULL_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]={MED_EN::MED_SEG2}; - const int nbOfCellElts[1]={8}; - meshing->setNumberOfTypes(1,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_SEG2,conn); - return meshing; - } - - MESH * build3DSourceMesh2() - { - double coords[27]= - { - 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0, - 200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0 - }; - int conn[48]= - { - 9, 2, 8, 4, 7, 1, 9, 3, 8, 5, 6, 9, 7, 9, 5, 8, 7, 9, 1, 5, 7, 9, 8, 4, 9, 2, 4, 1, 5, 2, 6, 9, 2, 8, 6, 9, 1, 4, 9, 3, 9, 2, 1, 5, 4, 7, 9, 3 - }; - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=9; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",MED_EN::MED_FULL_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]={MED_EN::MED_TETRA4}; - const int nbOfCellElts[1]={12}; - meshing->setNumberOfTypes(1,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - // - const MED_EN::medGeometryElement classicalTypesFace[1]={MED_EN::MED_TRIA3}; - const int nbOfFaceElts[1]={1}; - meshing->setNumberOfTypes(1,MED_EN::MED_FACE); - meshing->setTypes(classicalTypesFace,MED_EN::MED_FACE); - meshing->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_TETRA4,conn); - meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_TRIA3,conn); - return meshing; - } - - MESH * build3DTargetMesh2() - { - double coords[81]= - { - 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. , - 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. - }; - int conn[64]= - { - 1, 2, 5, 4, 10, 11, 14, 13, 2, 3, 6, 5, 11, 12, 15, 14, 4, 5, 8, 7, 13, 14, 17, 16, 5, 6, 9, 8, 14, 15, 18, - 17, 10, 11, 14, 13, 19, 20, 23, 22, 11, 12, 15, 14, 20, 21, 24, 23, 13, 14, 17, 16, 22, 23, 26, 25, 14, 15, 18, 17, 23, 24, 27, 26 - }; - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=27; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",MED_EN::MED_FULL_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement classicalTypesCell[1]={MED_EN::MED_HEXA8}; - const int nbOfCellElts[1]={8}; - meshing->setNumberOfTypes(1,MED_EN::MED_CELL); - meshing->setTypes(classicalTypesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - // - const MED_EN::medGeometryElement classicalTypesFace[1]={MED_EN::MED_QUAD4}; - const int nbOfFaceElts[1]={1}; - meshing->setNumberOfTypes(1,MED_EN::MED_FACE); - meshing->setTypes(classicalTypesFace,MED_EN::MED_FACE); - meshing->setNumberOfElements(nbOfFaceElts,MED_EN::MED_FACE); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_HEXA8,conn); - meshing->setConnectivity(MED_EN::MED_FACE,MED_EN::MED_QUAD4,conn); - return meshing; - } - - MESH * build3DSourceMesh2Poly() - { - double coords[27]={ 0.0, 0.0, 200.0, 0.0, 0.0, 0.0, 0.0, 200.0, 200.0, 0.0, 200.0, 0.0, 200.0, 0.0, 200.0, - 200.0, 0.0, 0.0, 200.0, 200.0, 200.0, 200.0, 200.0, 0.0, 100.0, 100.0, 100.0 }; - int conn[40]={9, 2, 8, 4, 7, 1, 9, 3, 8, 5, 6, 9, 7, 9, 5, 8, 7, 9, 1, 5, 7, 9, 8, 4, 9, 2, 4, 1, 5, 2, 6, 9, 2, 8, 6, 9, 1, 4, 9, 3}; - int connPoly1[3]={1,16,31}; - int connPoly2[30]={9, 2, 1, -1, 9, 5, 2, -1, 2, 5, 1, -1, 1, 5, 9, - 4, 7, 9, -1, 4, 3, 7, -1, 7, 3, 9, -1, 9, 3, 4}; - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=9; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",MED_EN::MED_FULL_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement typesCell[2]={MED_EN::MED_TETRA4,MED_EN::MED_POLYHEDRA}; - const int nbOfCellElts[2]={10,2}; - meshing->setNumberOfTypes(2,MED_EN::MED_CELL); - meshing->setTypes(typesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_TETRA4,conn); - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA,connPoly2,connPoly1); - return meshing; - } - - MESH * build3DTargetMesh2Poly() - { - double coords[81]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0. , 0., 50., 0., 50., 50., 0. , 200., 50., 0., 0., 200., 0., 50., 200., 0. , 200., 200., 0. , - 0., 0., 50., 50., 0., 50. , 200., 0., 50. , 0., 50., 50., 50., 50., 50. , 200., 50., 50., 0., 200., 50., 50., 200., 50. , 200., 200., 50. , - 0., 0., 200., 50., 0., 200. , 200., 0., 200. , 0., 50., 200., 50., 50., 200. , 200., 50., 200., 0., 200., 200., 50., 200., 200. , 200., 200., 200. }; - int conn[56]={1, 2, 5, 4, 10, 11, 14, 13, 2, 3, 6, 5, 11, 12, 15, 14, 4, 5, 8, 7, 13, 14, 17, 16, 5, 6, 9, 8, 14, 15, 18, - 17, 10, 11, 14, 13, 19, 20, 23, 22, 11, 12, 15, 14, 20, 21, 24, 23, 13, 14, 17, 16, 22, 23, 26, 25}; - int connPoly1[2]={1,30}; - int connPoly3[29]={ 14, 15, 18, 17, -1, 23, 26, 27, 24, -1, 14, 23, 24, 15, -1, 15, 24, 27, 18, -1, 18, 27, 26, 17, -1, 17, 26, 23, 14}; - MESHING* meshing = new MESHING; - meshing->setName( "TESTMESH" ); - const int nNodes=27; - meshing->setCoordinates(3, nNodes, coords, "CARTESIAN",MED_EN::MED_FULL_INTERLACE); - string coordname[3] = { "x", "y", "z" }; - meshing->setCoordinatesNames(coordname); - string coordunit[3] = - { - "m", "m", "m" - }; - meshing->setCoordinatesUnits(coordunit); - //Cell connectivity info for classical elts - const MED_EN::medGeometryElement typesCell[2]={MED_EN::MED_HEXA8,MED_EN::MED_POLYHEDRA}; - const int nbOfCellElts[2]={7,1}; - meshing->setNumberOfTypes(2,MED_EN::MED_CELL); - meshing->setTypes(typesCell,MED_EN::MED_CELL); - meshing->setNumberOfElements(nbOfCellElts,MED_EN::MED_CELL); - //All cell conn - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_HEXA8,conn); - meshing->setConnectivity(MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA,connPoly3,connPoly1); - return meshing; - } -} // noname namespace - -void MEDMEMTest::test_remapper4() -{ - const double valsSrc[28]= - { - 1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.,12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.,26.,27.,28. - }; - const double targetExpected[8]= - { - 16.2061111122415724, 21.8916666665293072, 15.5833333333333321, 13.1613888888184309, 11.8583333333333361, 10.6969444444233712, 4.48388888888888815, 9.42500000000000071 - }; - - MESH *source=build3DSourceMesh1(); - MESH *target=build3DTargetMesh1(); - const SUPPORT *supSrc=source->getSupportOnAll( MED_EN::MED_NODE ); - FIELD *f1=new MEDMEM::FIELD(supSrc,1); - double *val=(double *)f1->getValue(); - std::copy(valsSrc,valsSrc+28,val); - const SUPPORT *supTrg=target->getSupportOnAll( MED_EN::MED_NODE ); - FIELD *f2=new FIELD(supTrg,1); - // - MEDMEM_REMAPPER remap; - remap.prepare(*source,*target,"P1P1"); - remap.transfer(*f1,*f2); - const double *tmp=f2->getValue(); - for(int i=0;i<8;i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(targetExpected[i],tmp[i],1e-12); - // - source->removeReference(); - target->removeReference(); - f1->removeReference(); - f2->removeReference(); -} - -void MEDMEMTest::test_remapper5() -{ - MESH *sourceMesh=build3DSourceMesh2(); - MESH *targetMesh=build3DTargetMesh2(); - MEDNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][12],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - res.clear(); - // - MEDNormalizedUnstructuredMesh<3,3> sourceWrapper2(targetMesh); - MEDNormalizedUnstructuredMesh<3,3> targetWrapper2(sourceMesh); - INTERP_KERNEL::Interpolation3D myInterpolator2; - myInterpolator2.setPrecision(1e-12); - myInterpolator2.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator2.interpolateMeshes(sourceWrapper2,targetWrapper2,res,"P0P1"); - CPPUNIT_ASSERT_EQUAL(9,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[8][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(9.,sumAll(res),1e-12); - res.clear(); - // - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[0][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[0][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[1][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[2][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[3][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[4][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.5,res[5][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(0.25,res[6][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.25,res[7][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(3.75,res[7][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - // - targetMesh->removeReference(); - sourceMesh->removeReference(); -} - -void MEDMEMTest::test_remapper6() -{ - MESH *sourceMesh=build3DSourceMesh2Poly(); - MESH *targetMesh=build3DTargetMesh2Poly(); - MEDNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][12],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - targetMesh->removeReference(); - sourceMesh->removeReference(); -} - -void MEDMEMTest::test_remapper7() -{ - MESH *sourceMesh=build3DSourceMesh2(); - MESH *targetMesh=build3DTargetMesh2(); - sourceMesh->convertToPoly(); - targetMesh->convertToPoly(); - MEDNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][9],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][11],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][10],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][12],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(21.,sumAll(res),1e-12); - targetMesh->removeReference(); - sourceMesh->removeReference(); -} - -void MEDMEMTest::test_remapper3DTo1D() -{ - MESH *sourceMesh=build3DTargetMesh2(); - MESH *targetMesh=build1DTargetMesh1(); - MEDNormalizedUnstructuredMesh<3,3> sourceWrapper(sourceMesh); - MEDNormalizedUnstructuredMesh<3,3> targetWrapper(targetMesh); - INTERP_KERNEL::Interpolation3D myInterpolator; - vector > res; - myInterpolator.setPrecision(1e-12); - myInterpolator.setIntersectionType(INTERP_KERNEL::PointLocator); - myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P0P0"); - CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[0][1],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[1][5],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[2][2],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[3][6],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[4][3],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[5][7],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[6][4],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(1.,res[7][8],1e-12); - CPPUNIT_ASSERT_DOUBLES_EQUAL(8.,sumAll(res),1e-12); - targetMesh->removeReference(); - sourceMesh->removeReference(); -} - -double MEDMEMTest::sumAll(const std::vector< std::map >& matrix) -{ - double ret=0.; - for(std::vector< std::map >::const_iterator iter=matrix.begin();iter!=matrix.end();iter++) - for(std::map::const_iterator iter2=(*iter).begin();iter2!=(*iter).end();iter2++) - ret+=(*iter2).second; - return ret; -} - -void MEDMEMTest::absField(MEDMEM::FIELD& field) -{ - double* areas=const_cast(field.getValue()); - for (int i=0; i< field.getNumberOfValues();i++) - { - areas[i]=fabs(areas[i]); - } -} - -// } diff --git a/src/MEDMEMCppTest/MEDMEMTest_SkyLineArray.cxx b/src/MEDMEMCppTest/MEDMEMTest_SkyLineArray.cxx deleted file mode 100644 index 64fa684b2..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_SkyLineArray.cxx +++ /dev/null @@ -1,200 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_define.hxx" - -#include -#include - -using namespace std; -using namespace MEDMEM; - -/*! - * Check methods (17), defined in MEDMEM_SkyLineArray.hxx: - * class MEDSKYLINEARRAY { - * (+) MEDSKYLINEARRAY(); - * (+) MEDSKYLINEARRAY(const MEDSKYLINEARRAY &myArray); - * (+) MEDSKYLINEARRAY(const int count, const int length); - * (+) MEDSKYLINEARRAY(const int count, const int length, - * const int* index, const int* value, bool shallowCopy=false); - * (+) ~MEDSKYLINEARRAY(); - * (+) inline int getNumberOf() const; - * (+) inline int getLength() const; - * (+) inline const int* getIndex() const; - * (+) inline const int* getValue() const; - * (+) inline int getNumberOfI(int i) const throw (MEDEXCEPTION); - * (+) inline const int* getI(int i) const throw (MEDEXCEPTION); - * (+) inline int getIJ(int i, int j) const throw (MEDEXCEPTION); - * (+) inline int getIndexValue(int i) const throw (MEDEXCEPTION); - * (+) inline void setIndex(const int* index); - * (+) inline void setI(const int i, const int* values) throw (MEDEXCEPTION); - * (+) inline void setIJ(int i, int j, int value) throw (MEDEXCEPTION); - * (+) inline void setIndexValue(int i, int value) throw (MEDEXCEPTION); - * (+) friend ostream& operator<<(ostream &os, const MEDSKYLINEARRAY &sky); - * } - * - */ -void MEDMEMTest::testSkyLineArray() -{ - int NumberOfCell = 3 ; // 1 triangle,1 quadrangle,1 triangle - int Size = 10 ; // 10 nodes - - int * index = new int[NumberOfCell+1] ; - index[0]=1; - index[1]=4; - index[2]=8; - index[3]=11; - int * value = new int[Size] ; - value[0]=1; // first - value[1]=2; - value[2]=5; - value[3]=2; // second - value[4]=3; - value[5]=5; - value[6]=6; - value[7]=3; // thirst - value[8]=4; - value[9]=6; - // value[]=; // forth - - MEDSKYLINEARRAY * myArray = new MEDSKYLINEARRAY(NumberOfCell,Size,index,value) ; - const int * ArrayIndex ; - try - { - ArrayIndex = myArray->getIndex() ; - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - const int * ArrayValue ; - try - { - ArrayValue = myArray->getValue() ; - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - - try - { - CPPUNIT_ASSERT(myArray->getNumberOf()==NumberOfCell); - - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT(myArray->getLength()==Size); - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - for (int i=1; i< NumberOfCell+1 ; i++) - { - const int * cell; - CPPUNIT_ASSERT_NO_THROW(cell = myArray->getI(i)); - int numberof; - CPPUNIT_ASSERT_NO_THROW(numberof= myArray->getNumberOfI(i)); - CPPUNIT_ASSERT(numberof==index[i]-index[i-1]); - int verif; - for (int j=0;jgetIJ(i,j+1)); - CPPUNIT_ASSERT(verif == cell[j]); - } - } - - MEDSKYLINEARRAY * myArray2 = new MEDSKYLINEARRAY(*myArray) ; - delete myArray ; - - const int * index2 = myArray2->getIndex() ; - for (int i=1; i<=NumberOfCell ; i++) { - for (int j=index2[i-1];jgetIndexValue(j)); - } - - delete myArray2 ; - - MEDSKYLINEARRAY myArray3(NumberOfCell,Size); - try - { - myArray3.setIndex(index); - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - CPPUNIT_ASSERT_THROW(myArray3.setI(0, 0),MEDEXCEPTION); - - for (int i=1; i -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #52: MEDMEM_Support.hxx } MEDMEMTest_Support.cxx - -/*! - * Check methods (48), defined in MEDMEM_Support.hxx: - * class SUPPORT : public RCBASE -{ - * (+) SUPPORT(); - * (+) SUPPORT(MESH* Mesh, string Name="", MED_EN::medEntityMesh Entity=MED_EN::MED_CELL); - * (+) SUPPORT(const SUPPORT & m); - * (+) virtual ~SUPPORT(); - * - * (+) friend ostream & operator<<(ostream &os,const SUPPORT &my); - * (+) SUPPORT& operator=(const SUPPORT &support); - * (+) bool operator == (const SUPPORT &support) const; - * (+) bool deepCompare(const SUPPORT &support) const; - * - * (+) void update(); - * - * (+) inline void setName(string Name); - * (+) inline void setDescription(string Description); - * (+) void setMesh(MESH *Mesh) const; - * (+) inline void setMeshName(const string & meshName); - * (+) inline void setAll(bool All); - * (+) inline void setEntity(MED_EN::medEntityMesh Entity); - * - * (+) inline void setNumberOfGeometricType(int NumberOfGeometricType); - * (+) inline void setGeometricType(const MED_EN::medGeometryElement *GeometricType); - * (+) inline void setNumberOfElements(const int *NumberOfElements); - * (+) inline void setTotalNumberOfElements(int TotalNumberOfElements); - * (+) inline void setNumber(MEDSKYLINEARRAY * Number); - * (+) inline void setNumber(const int * index, const int* value, bool shallowCopy=false); - * - * (+) inline string getName() const; - * (+) inline string getDescription() const; - * (+) virtual inline MESH * getMesh() const; - * (+) string getMeshName() const; - * (+) inline MED_EN::medEntityMesh getEntity() const; - * (+) inline bool isOnAllElements() const; - * - * (+) inline int getNumberOfTypes() const; - * (+) inline const MED_EN::medGeometryElement* getTypes() const; - * (+) inline int getNumberOfElements - * (MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - * (+) inline const int * getNumberOfElements() const throw (MEDEXCEPTION); - * (+) virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION); - * (NO METHOD IN THIS BRANCH) virtual inline MEDSKYLINEARRAY * getnumberFromFile() const throw (MEDEXCEPTION); - * (+) virtual inline const int * getNumber - * (MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - * (NO METHOD IN THIS BRANCH) virtual inline const int * getNumberFromFile - * (MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - * (+) virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION); - * (+) virtual int getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION); - * - * (+) void blending(SUPPORT * mySupport) throw (MEDEXCEPTION); - * - * (+) void setpartial(string Description, int NumberOfGeometricType, - * int TotalNumberOfEntity, MED_EN::medGeometryElement *GeometricType, - * int *NumberOfEntity, int *NumberValue); - * (+) void setpartial(MEDSKYLINEARRAY * number, bool shallowCopy=false) throw (MEDEXCEPTION); - * (NO METHOD IN THIS BRANCH) void setpartial_fromfile(MEDSKYLINEARRAY * number, bool shallowCopy=false) throw (MEDEXCEPTION); - * - * (+) void setProfilNames(vector profilNames) throw (MEDEXCEPTION); - * (+) vector getProfilNames() const throw (MEDEXCEPTION); - * - * (+) void getBoundaryElements() throw (MEDEXCEPTION); - * - * (+) void changeElementsNbs(MED_EN::medEntityMesh entity, const int *renumberingFromOldToNew, - * int limitNbClassicPoly, const int *renumberingFromOldToNewPoly=0); - * (+) void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION); - * (+) bool belongsTo(const SUPPORT& other, bool deepCompare=false) const; - * - * (+) SUPPORT *getComplement() const; - * (+) SUPPORT *substract(const SUPPORT& other) const throw (MEDEXCEPTION); - * - * (+) SUPPORT *getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - * - * (+) void fillFromNodeList(const list& listOfNode) throw (MEDEXCEPTION); - * (+) void fillFromElementList(const list& listOfElt) throw (MEDEXCEPTION); - * - * (+) void clearDataOnNumbers(); - * - * (reference counter presently disconnected in C++) virtual void addReference() const; - * (reference counter presently disconnected in C++) virtual void removeReference() const; - * -} - */ -void MEDMEMTest::testSupport() -{ - MESH * aMesh = MEDMEMTest_createTestMesh(); - MESH * aMeshOneMore = MEDMEMTest_createTestMesh(); - - //////////// - // TEST 1 // - //////////// - - SUPPORT *aSupportOnFaces1 = new SUPPORT; - aSupportOnFaces1->setMesh( aMesh ); - aSupportOnFaces1->setEntity( MED_EN::MED_FACE ); - aSupportOnFaces1->setAll( true ); - aSupportOnFaces1->update(); - - SUPPORT *aSupportOnCells1 = new SUPPORT; - aSupportOnCells1->setMesh( aMesh ); - aSupportOnCells1->setAll( true ); - aSupportOnCells1->update(); - - SUPPORT *aSupportOnFaces2=new SUPPORT; - SUPPORT *aSupportOnCells2=new SUPPORT; - - SUPPORT *aSupportOnFaces3 = new SUPPORT; - aSupportOnFaces3->setMesh( aMeshOneMore ); - aSupportOnFaces3->setName( "Support On Faces 3" ); - aSupportOnFaces3->setEntity( MED_EN::MED_FACE ); - aSupportOnFaces3->setAll( true ); - aSupportOnFaces3->update(); - // entity - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aSupportOnFaces1->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnCells1->getEntity()); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnFaces2->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnCells2->getEntity()); - - aSupportOnFaces2->setEntity(MED_EN::MED_FACE); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aSupportOnFaces2->getEntity()); - - // isOnAllElements - CPPUNIT_ASSERT(aSupportOnFaces1->isOnAllElements()); - CPPUNIT_ASSERT(aSupportOnCells1->isOnAllElements()); - - CPPUNIT_ASSERT(!aSupportOnFaces2->isOnAllElements()); - CPPUNIT_ASSERT(!aSupportOnCells2->isOnAllElements()); - - // mesh and mesh name - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->setMeshName("Mesh 1"), MEDEXCEPTION); - - aSupportOnFaces2->setMeshName("Mesh 1"); - aSupportOnCells2->setMeshName("Mesh 1"); - CPPUNIT_ASSERT(aSupportOnFaces2->getMeshName() == "Mesh 1"); - CPPUNIT_ASSERT(aSupportOnCells2->getMeshName() == "Mesh 1"); - - aSupportOnFaces2->setMesh(aMesh); - CPPUNIT_ASSERT_THROW(aSupportOnFaces2->setMeshName("Mesh 1"), MEDEXCEPTION); - - aSupportOnCells1->setMesh(NULL); - aSupportOnCells1->setMeshName("Mesh 1"); - - CPPUNIT_ASSERT(aSupportOnFaces1->getMeshName() == "meshing"); - CPPUNIT_ASSERT(aSupportOnFaces2->getMeshName() == "meshing"); - CPPUNIT_ASSERT(aSupportOnCells1->getMeshName() == "Mesh 1"); - CPPUNIT_ASSERT(aSupportOnCells2->getMeshName() == "Mesh 1"); - - CPPUNIT_ASSERT(aSupportOnFaces1->getMesh() == aMesh); - CPPUNIT_ASSERT(aSupportOnFaces2->getMesh() == aMesh); - CPPUNIT_ASSERT(aSupportOnCells1->getMesh() == NULL); - CPPUNIT_ASSERT(aSupportOnCells2->getMesh() == NULL); - - // _number - { - int iElem = 1, nbTypes = aSupportOnFaces1->getNumberOfTypes(); - const MED_EN::medGeometryElement* types = aSupportOnFaces1->getTypes(); - for ( int iType = 0; iType < nbTypes; ++iType ) - { - const int nb = aSupportOnFaces1->getNumberOfElements( types[iType] ); - const int* nums = aSupportOnFaces1->getNumber ( types[iType] ); - for ( int i = 0; i < nb; ++i ) - CPPUNIT_ASSERT_EQUAL( iElem++, nums[i] ); - } - iElem = 1, nbTypes = aSupportOnCells1->getNumberOfTypes(); - types = aSupportOnCells1->getTypes(); - for ( int iType = 0; iType < nbTypes; ++iType ) - { - const int nb = aSupportOnCells1->getNumberOfElements( types[iType] ); - const int* nums = aSupportOnCells1->getNumber ( types[iType] ); - for ( int i = 0; i < nb; ++i ) - CPPUNIT_ASSERT_EQUAL( iElem++, nums[i] ); - } - } - - // operator == - aSupportOnFaces2->setName("Support On Faces 2"); - aSupportOnCells2->setName("Support On Cells 2"); - - // because aSupportOnFaces1 is on all elements, but aSupportOnFaces2 not - CPPUNIT_ASSERT(!(aSupportOnFaces1 == aSupportOnFaces2)); - - aSupportOnCells1->setAll(false); - CPPUNIT_ASSERT(!aSupportOnCells1->isOnAllElements()); - // this is only sets flag _isOnAllElts to false, but not clear elements and types - // information, so aSupportOnCells1 is not equal to aSupportOnCells2 at this moment - - //#ifdef ENABLE_FAULTS - // (BUG) SUPPORT::operator= gives "Segmentation Fault" on supports with NULL meshes!!! - //CPPUNIT_ASSERT(!(aSupportOnCells1 == aSupportOnCells2)); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_FAIL("SUPPORT::operator= gives Segmentation Fault on supports with NULL meshes!!!"); - //#endif - - aSupportOnFaces2->setAll(true); - CPPUNIT_ASSERT(aSupportOnFaces2->isOnAllElements()); - // flag _isOnAllElts now is set to true, but we need also to call update() - // to set elements and types information from mesh to this support - CPPUNIT_ASSERT(!(*aSupportOnFaces1 == *aSupportOnFaces2)); - aSupportOnFaces2->update(); - CPPUNIT_ASSERT(*aSupportOnFaces1 == *aSupportOnFaces2); - - // deep compare - CPPUNIT_ASSERT(aSupportOnFaces1->deepCompare(*aSupportOnFaces2)); - - CPPUNIT_ASSERT(!(*aSupportOnFaces1 == *aSupportOnFaces3)); // different mesh pointers - CPPUNIT_ASSERT(aSupportOnFaces1->deepCompare(*aSupportOnFaces3)); // meshes are really equal - - // description - aSupportOnFaces1->setDescription("Support on all faces with mesh pointer"); - aSupportOnFaces2->setDescription("Support on all faces with mesh pointer"); - - aSupportOnCells1->setDescription("Support on a part of cells with mesh name"); - aSupportOnCells2->setDescription("Support on a part of cells with mesh name"); - - CPPUNIT_ASSERT(aSupportOnFaces1->getDescription() == "Support on all faces with mesh pointer"); - CPPUNIT_ASSERT(aSupportOnFaces2->getDescription() == "Support on all faces with mesh pointer"); - CPPUNIT_ASSERT(aSupportOnCells1->getDescription() == "Support on a part of cells with mesh name"); - CPPUNIT_ASSERT(aSupportOnCells2->getDescription() == "Support on a part of cells with mesh name"); - aSupportOnFaces2->removeReference(); - // operator<< - ostringstream ostr1; - ostr1 << *aSupportOnFaces1; - CPPUNIT_ASSERT(ostr1.str() != ""); - - ostringstream ostr2; - ostr2 << *aSupportOnCells2; - CPPUNIT_ASSERT(ostr2.str() != ""); - - // set/get elements and types information - - // 1. aSupportOnCells1 is not on all elements, but now it contains information - // about all cells of aMesh, because it was created on mesh and with parameters. - CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells1->getTypes() != NULL); - - aSupportOnCells1->setNumberOfGeometricType(0); - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells1->getTypes() == NULL); - - MED_EN::medGeometryElement aSCTypes[2] = - { - MED_EN::MED_PYRA5, MED_EN::MED_PENTA15 - }; - aSupportOnCells1->setNumberOfGeometricType(2); - aSupportOnCells1->setGeometricType(aSCTypes); - - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells1->getTypes() != NULL); - CPPUNIT_ASSERT(aSupportOnCells1->getNumberOfElements() == NULL); // reset by setNumberOfGeometricType - - int nbEltsSC[2] = - { - 2, 1 - }; - aSupportOnCells1->setNumberOfElements(nbEltsSC); - - const int * nbEltsSCBack = aSupportOnCells1->getNumberOfElements(); - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells1->getNumberOfElements(MED_EN::MED_PYRA5)); - CPPUNIT_ASSERT_EQUAL(2, nbEltsSCBack[0]); - CPPUNIT_ASSERT_EQUAL(1, aSupportOnCells1->getNumberOfElements(MED_EN::MED_PENTA15)); - CPPUNIT_ASSERT_EQUAL(1, nbEltsSCBack[1]); - CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - // old types - CPPUNIT_ASSERT_THROW(aSupportOnCells1->getNumberOfElements(MED_EN::MED_TETRA4), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnCells1->getNumberOfElements(MED_EN::MED_HEXA8), MEDEXCEPTION); - - //_number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy); - int indexSC[3] = - { - 1,3,4 - }; // length = nb.types + 1 - int valueSC[3] = - { - 21,22,47 - }; // length = total nb. of elements - aSupportOnCells1->setNumber(indexSC, valueSC); - - // check number - MEDSKYLINEARRAY * aNumberSCBack = aSupportOnCells1->getnumber(); - - CPPUNIT_ASSERT_EQUAL(2, aNumberSCBack->getNumberOf()); - CPPUNIT_ASSERT_EQUAL(3, aNumberSCBack->getLength()); - const int * ind = aNumberSCBack->getIndex(); - const int * val = aNumberSCBack->getValue(); - CPPUNIT_ASSERT_EQUAL(1, ind[0]); - CPPUNIT_ASSERT_EQUAL(3, ind[1]); - CPPUNIT_ASSERT_EQUAL(4, ind[2]); - CPPUNIT_ASSERT_EQUAL(21, val[0]); - CPPUNIT_ASSERT_EQUAL(22, val[1]); - CPPUNIT_ASSERT_EQUAL(47, val[2]); - - // 2. aSupportOnCells2 is not on all elements, and now it contains - // no information about elements of a mesh - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells2->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells2->getTypes() == NULL); - - aSupportOnCells2->setNumberOfGeometricType(2); - aSupportOnCells2->setGeometricType(aSCTypes); - - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells2->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells2->getTypes() != NULL); - - aSupportOnCells2->setNumberOfElements(nbEltsSC); - - // we create MEDSKYLINEARRAY as pointer, because aSupportOnCells2 will - // become an owner of it, and we must not delete it. - MEDSKYLINEARRAY * aNumberSC = new MEDSKYLINEARRAY(2, 3, indexSC, valueSC); - aSupportOnCells2->setNumber(aNumberSC); - - // check number - const int * aNumberIndexSC = aSupportOnCells2->getNumberIndex(); - CPPUNIT_ASSERT_EQUAL(1, aNumberIndexSC[0]); - CPPUNIT_ASSERT_EQUAL(3, aNumberIndexSC[1]); - CPPUNIT_ASSERT_EQUAL(4, aNumberIndexSC[2]); - - const int * aNbPYRA5 = aSupportOnCells2->getNumber(MED_EN::MED_PYRA5); - const int * aNbPENTA15 = aSupportOnCells2->getNumber(MED_EN::MED_PENTA15); - CPPUNIT_ASSERT_THROW(aSupportOnCells2->getNumber(MED_EN::MED_TETRA4), MEDEXCEPTION); - - const int * aNbC = aSupportOnCells2->getNumber(MED_EN::MED_ALL_ELEMENTS); - - CPPUNIT_ASSERT_EQUAL(21, aNbPYRA5[0]); - CPPUNIT_ASSERT_EQUAL(22, aNbPYRA5[1]); - CPPUNIT_ASSERT_EQUAL(47, aNbPENTA15[0]); - - CPPUNIT_ASSERT_EQUAL(21, aNbC[0]); - CPPUNIT_ASSERT_EQUAL(22, aNbC[1]); - CPPUNIT_ASSERT_EQUAL(47, aNbC[2]); - - // getValIndFromGlobalNumber - CPPUNIT_ASSERT_EQUAL(1, aSupportOnCells2->getValIndFromGlobalNumber(21)); - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells2->getValIndFromGlobalNumber(22)); - CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells2->getValIndFromGlobalNumber(47)); - // not existing element - CPPUNIT_ASSERT_THROW(aSupportOnCells2->getValIndFromGlobalNumber(10), MEDEXCEPTION); - - // compare aSupportOnCells1 and aSupportOnCells2 - - // temporary set mesh (because of bug with operator==) - aSupportOnCells1->setMesh(aMesh); - aSupportOnCells2->setMesh(aMesh); - - CPPUNIT_ASSERT_EQUAL(*aSupportOnCells1, *aSupportOnCells2); - - // restore mesh name - aSupportOnCells1->setMesh(NULL); - aSupportOnCells2->setMesh(NULL); - aSupportOnCells1->setMeshName("Mesh 1"); - aSupportOnCells2->setMeshName("Mesh 1"); - aSupportOnCells2->removeReference(); - - // 3. aSupportOnFacesN is on all elements, and it contains - // information about all faces of aMesh - CPPUNIT_ASSERT_EQUAL(2, aSupportOnFaces1->getNumberOfTypes()); - const MED_EN::medGeometryElement* aSF1Types = aSupportOnFaces1->getTypes(); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_TRIA3, aSF1Types[0]); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_QUAD4, aSF1Types[1]); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Comment to method SUPPORT::getTypes() says: - // "If isOnAllElements is false, returns an array of %medGeometryElement types used by the support." - // But in fact it returns types in any case (comment to SUPPORT::setAll() gives more information). - //CPPUNIT_FAIL("Comment and implementation does not match for SUPPORT::getTypes()"); - // This concerns also method SUPPORT::update(), being called from constructor, - // which fills internal SUPPORT structures with information about mesh elements - // in case of isOnAllElements == true. - // Also comments and implementation does not match for SUPPORT::getNumberOfElements(). - // It seems that in case "isOnAllElements == true" calls like getNumberOfElements() - // must be redirected to mesh, but what if mesh is not set (mesh name used instead)?. - //#endif - const int * nbEltsSF1 = aSupportOnFaces1->getNumberOfElements(); - CPPUNIT_ASSERT_EQUAL(4, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(4, nbEltsSF1[0]); - CPPUNIT_ASSERT_EQUAL(4, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_EQUAL(4, nbEltsSF1[1]); - CPPUNIT_ASSERT_EQUAL(8, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumberOfElements(MED_EN::MED_TRIA6), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumberOfElements(MED_EN::MED_QUAD8), MEDEXCEPTION); - - // check type of nodal support - // (021199: MEDMEM::SUPPORT : geometric type when support is on node) - { - const SUPPORT* s = aMesh->getSupportOnAll( MED_EN::MED_NODE ); - CPPUNIT_ASSERT_EQUAL( MED_EN::MED_NONE, s->getTypes()[0] ); - - SUPPORT* s2 = new SUPPORT( *s ); - CPPUNIT_ASSERT_EQUAL( MED_EN::MED_NONE, s2->getTypes()[0] ); - const MED_EN::medGeometryElement point1 = MED_EN::MED_POINT1; - s2->setNumberOfGeometricType( 1 ); - CPPUNIT_ASSERT_THROW( s2->setGeometricType( &point1 ), MEDEXCEPTION ); - s2->removeReference(); - } - - //checking makeMesh() - MESH *meshFromSupport=aSupportOnFaces1->makeMesh(); - CPPUNIT_ASSERT_EQUAL(4,meshFromSupport->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(4,meshFromSupport->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_QUAD4)); - int nbnodes= meshFromSupport->getNumberOfNodes(); - const int* conn=meshFromSupport->getConnectivity( MED_EN::MED_NODAL, MED_EN::MED_CELL, MED_EN::MED_TRIA3); - for (int i=0; i<12;i++) - CPPUNIT_ASSERT(conn[i]>0 && conn[i]<=nbnodes); - meshFromSupport->removeReference(); - const SUPPORT *nodal_support=aSupportOnFaces1->getMesh()->getSupportOnAll( MED_EN::MED_NODE ); - CPPUNIT_ASSERT_THROW(nodal_support->makeMesh(), MEDEXCEPTION); - //checking makeMesh() on polygonal support - { - // "poly3D" mesh contains: - // 19 MED_NODE - // 6 MED_TRIA3 - // 8 MED_QUAD4 - // 3 MED_POLYGON - // 1 MED_TETRA4 - // 2 MED_POLYHEDRA - string med_file = getResourceFile("poly3D.med"); - MESH *poly_mesh=new MESH; - MED_MESH_RDONLY_DRIVER meshDrv(med_file,poly_mesh); - meshDrv.setMeshName( "poly3D" ); - meshDrv.desactivateFacesComputation(); // to have nb of faces like in the file - meshDrv.open(); - meshDrv.read(); - meshDrv.close(); - if ( poly_mesh->getNumberOfElements(MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS) != 17 ) - CPPUNIT_FAIL("Nb of faces in mesh from 'poly3D.med' resource file != 17"); - - // support on 3 cells and the mesh made from it - const SUPPORT *poly_supp=poly_mesh->getSupportOnAll( MED_CELL ); - MESH *poly_supp_mesh=poly_supp->makeMesh(); - CPPUNIT_ASSERT_EQUAL(3,poly_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(1,poly_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_TETRA4)); - CPPUNIT_ASSERT_EQUAL(2,poly_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_POLYHEDRA)); - int nbnodes=poly_supp_mesh->getNumberOfNodes(); - const int* conn=poly_supp_mesh->getConnectivity(MED_EN::MED_NODAL, - MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - int con_len = 1 * MED_EN::MED_TETRA4 % 100; - for (int i=0; i0 && conn[i]<=nbnodes); - - conn = poly_supp_mesh->getConnectivity(MED_EN::MED_NODAL, - MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA); - con_len = poly_supp_mesh->getConnectivityLength(MED_EN::MED_NODAL, - MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA); - for (int i=0; i0 && conn[i]<=nbnodes) || conn[i]==-1 ); - poly_supp_mesh->removeReference(); - // support on 17 faces and the mesh made from it - SUPPORT *polygon_supp= new SUPPORT( *poly_mesh->getSupportOnAll( MED_EN::MED_FACE )); - poly_mesh->removeReference(); - MESH *polygon_supp_mesh=polygon_supp->makeMesh(); - CPPUNIT_ASSERT_EQUAL(17,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(6,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(8,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_EQUAL(3,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_POLYGON)); - nbnodes = polygon_supp_mesh->getNumberOfNodes(); - conn=polygon_supp_mesh->getConnectivity(MED_EN::MED_NODAL, - MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - con_len = 6 * MED_EN::MED_TRIA3 % 100 + 8 * MED_EN::MED_QUAD4 % 100; - for (int i=0; i0 && conn[i]<=nbnodes); - - conn = polygon_supp_mesh->getConnectivity(MED_EN::MED_NODAL, - MED_EN::MED_CELL,MED_EN::MED_POLYGON); - con_len = polygon_supp_mesh->getConnectivityLength(MED_EN::MED_NODAL, - MED_EN::MED_CELL,MED_EN::MED_POLYGON); - for (int i=0; i0 && conn[i]<=nbnodes); - polygon_supp_mesh->removeReference(); - // make polygon_supp patrial: make it contain 4 QUAD4 and 2 POLYGON - const int nb_types = 2; - const int nb_elems = 4 + 2; - int index[nb_types+1] = - { - 1, 1+4, 1+4+2 - }; - int elems[nb_elems] = - { - 8, 10, 11, 13, 16, 17 - }; - MED_EN::medGeometryElement types[nb_types] = - { - MED_EN::MED_QUAD4, MED_EN::MED_POLYGON - }; - MEDSKYLINEARRAY* array = new MEDSKYLINEARRAY(nb_types, nb_elems, index, elems); - polygon_supp->setNumberOfGeometricType( nb_types ); - polygon_supp->setGeometricType( types ); - polygon_supp->setpartial( array, /*shallowCopy=*/true); - - // 0020912: [CEA 414] setPartial and polygons/polyhedra - // do the same but using another version of setpartial() - const int nb_of_elems[nb_types] = - { - 4, 2 - }; - polygon_supp->setpartial("issue 0020912",nb_types, nb_elems, types, nb_of_elems, elems); - - // make mesh from partial support containing polygons - MESH *partial_supp_mesh=polygon_supp->makeMesh(); - polygon_supp->removeReference(); - CPPUNIT_ASSERT_EQUAL(6,partial_supp_mesh->getNumberOfElements(MED_EN::MED_CELL, - MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(4,partial_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,types[0])); - CPPUNIT_ASSERT_EQUAL(2,partial_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,types[1])); - - nbnodes = partial_supp_mesh->getNumberOfNodes(); - int spaceDimension = partial_supp_mesh->getSpaceDimension(); - int meshDimension = partial_supp_mesh->getMeshDimension(); - const double *coords = partial_supp_mesh->getCoordinates(MED_FULL_INTERLACE); - const double coordsExpected[45]= - { - 3., 2., 2., 3., 2., 0., 4., 1., 0., 4., 1., 2., 0., 1., 2., 2., 0., 2., 2., 0., 0., 0., - 1., 0., 1., 2., 2., 1., 2., 0., 7., 2., 2., 5., 3., 2., 6., 3., 0., 7., 2., 0., 6., 0., 2. - }; - CPPUNIT_ASSERT_EQUAL(3,spaceDimension); - CPPUNIT_ASSERT_EQUAL(2,meshDimension); - CPPUNIT_ASSERT_EQUAL(15,nbnodes); - for(int i=0 ; igetConnectivity(MED_EN::MED_NODAL, - MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - con_len = 4 * MED_EN::MED_QUAD4 % 100; - int connExpected[16]= - { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 8, 10, 11, 12, 13, 14 - }; - for (int i=0; igetConnectivity(MED_EN::MED_NODAL, - MED_EN::MED_CELL,MED_EN::MED_POLYGON); - con_len = partial_supp_mesh->getConnectivityLength(MED_EN::MED_NODAL, - MED_EN::MED_CELL,MED_EN::MED_POLYGON); - int connExpectedP[10]= - { - 7, 3, 2, 10, 8, 12, 11, 15, 4, 1 - }; - for (int i=0; iremoveReference(); - } - - - // check number - CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumberIndex()); - CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getnumber()); - - // getValIndFromGlobalNumber - CPPUNIT_ASSERT_EQUAL(8, aMesh->getNumberOfElements(MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS)); - for (int i = 1; i <= 8; i++) - { - CPPUNIT_ASSERT_EQUAL(i, aSupportOnFaces1->getValIndFromGlobalNumber(i)); - } - - //#ifdef ENABLE_FORCED_FAILURES - // Why methods setNumber do not throw exception in case "isOnAllElements == true", - // like methods getNumber do? - //skl??? CPPUNIT_ASSERT_THROW(aSupportOnFaces1->setNumber(indexSF1, valueSF1), MEDEXCEPTION); - //#endif - - //#ifdef ENABLE_FORCED_FAILURES - // It seems to be dangerous and useless to have method SUPPORT::setTotalNumberOfElements() - //CPPUNIT_FAIL("It seems to be dangerous and useless to have method SUPPORT::setTotalNumberOfElements()"); - //#endif - - // following test is commented since method - // setTotalNumberOfElements() is removed. - // setTotalNumberOfElements - //aSupportOnFaces1->setTotalNumberOfElements(1000); - //CPPUNIT_ASSERT_EQUAL(1000, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - aSupportOnFaces1->removeReference(); - // clearDataOnNumbers - aSupportOnCells1->clearDataOnNumbers(); - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT_THROW(aSupportOnCells1->getnumber(), MEDEXCEPTION); - aSupportOnCells1->removeReference(); - - ///////////////////////////////////// - // test SUPPORT* buildSupportOnNode() - ///////////////////////////////////// - - for (medEntityMesh entity = 0; entity < MED_ALL_ENTITIES; ++entity ) - { - if ( entity != MED_NODE && !aMesh->existConnectivity( MED_NODAL, entity )) - continue; - // buildSupportOnNode() from full entity support - const SUPPORT *allEntitySupport=aMesh->getSupportOnAll( entity ); - SUPPORT *testSupport=allEntitySupport->buildSupportOnNode(); - CPPUNIT_ASSERT(testSupport->isOnAllElements()); - CPPUNIT_ASSERT_EQUAL(1,testSupport->getNumberOfTypes()); - CPPUNIT_ASSERT_EQUAL(19,testSupport->getNumberOfElements(MED_ALL_ELEMENTS)); - - // buildSupportOnNode() from partial support - SUPPORT *partialSupport=new SUPPORT(*allEntitySupport); - partialSupport->setAll( false ); - partialSupport->setNumberOfGeometricType( 1 ); - partialSupport->setGeometricType( allEntitySupport->getTypes() ); - - // no element numbers set - CPPUNIT_ASSERT_THROW(partialSupport->buildSupportOnNode(), MEDEXCEPTION); - - int index[] = - { - 1,2 - }; - int numbers[] = - { - 1 - }; - partialSupport->setNumberOfElements(numbers); - partialSupport->setNumber( index, numbers ); - - // mesh not set - partialSupport->setMesh(0); - CPPUNIT_ASSERT_THROW(partialSupport->buildSupportOnNode(), MEDEXCEPTION); - partialSupport->setMesh(aMesh); - - testSupport->removeReference(); - testSupport =( partialSupport->buildSupportOnNode() ); - partialSupport->removeReference(); - CPPUNIT_ASSERT(!testSupport->isOnAllElements()); - CPPUNIT_ASSERT_EQUAL(1,testSupport->getNumberOfTypes()); - int nbNodes = testSupport->getNumberOfElements(MED_ALL_ELEMENTS); - if ( entity == MED_NODE ) - CPPUNIT_ASSERT_EQUAL(1, nbNodes); - else - CPPUNIT_ASSERT_EQUAL(aMesh->getCellsTypes(entity)[0].getNumberOfNodes(), nbNodes); - const int * nodes = testSupport->getNumber( MED_ALL_ELEMENTS ); - switch ( entity ) - { - case MED_CELL: - CPPUNIT_ASSERT_EQUAL(1,nodes[0]); - CPPUNIT_ASSERT_EQUAL(2,nodes[1]); - CPPUNIT_ASSERT_EQUAL(3,nodes[2]); - CPPUNIT_ASSERT_EQUAL(6,nodes[3]); - break; - case MED_FACE: - CPPUNIT_ASSERT_EQUAL(1,nodes[0]); - CPPUNIT_ASSERT_EQUAL(3,nodes[1]); - CPPUNIT_ASSERT_EQUAL(4,nodes[2]); - break; - case MED_NODE: - CPPUNIT_ASSERT_EQUAL(1,nodes[0]); - break; - default:; - } - testSupport->removeReference(); - } - - //////////// - // TEST 2 // - //////////// - - list nodes137; - nodes137.push_back(1); - nodes137.push_back(3); - nodes137.push_back(7); - - list nodes248; - nodes248.push_back(2); - nodes248.push_back(4); - nodes248.push_back(8); - - list nodes27; - nodes27.push_back(2); - nodes27.push_back(7); - - SUPPORT *aNodes137 = new SUPPORT; - SUPPORT *aNodes248 = new SUPPORT; - SUPPORT *aNodes27 = new SUPPORT; - aNodes137->setMesh( aMesh ); - aNodes248->setMesh( aMesh ); - aNodes27->setMesh( aMesh ); - aNodes137->setName( "Support On Nodes 1,3,7" ); - aNodes248->setName( "Support On Nodes 2,4,8" ); - aNodes27->setName( "Support On Nodes 2,7" ); - - aNodes137->fillFromNodeList(nodes137); - aNodes248->fillFromNodeList(nodes248); - aNodes27->fillFromNodeList(nodes27); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes137->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes248->getEntity()); - - list::const_iterator iter137 = nodes137.begin(); - list::const_iterator iter248 = nodes248.begin(); - for (int i = 1; i <= 3; i++, iter137++, iter248++) - { - CPPUNIT_ASSERT_EQUAL(i, aNodes137->getValIndFromGlobalNumber(*iter137)); - CPPUNIT_ASSERT_EQUAL(i, aNodes248->getValIndFromGlobalNumber(*iter248)); - } - - //////////// - - list faces123; - faces123.push_back(1); - faces123.push_back(2); - faces123.push_back(3); - - list faces135; - faces135.push_back(1); - faces135.push_back(3); - faces135.push_back(5); - - SUPPORT *aFaces123 = new SUPPORT; - aFaces123->setMesh( aMesh ); - aFaces123->setName( "Support On Faces 1,2,3" ); - aFaces123->setEntity( MED_EN::MED_FACE ); - SUPPORT *aFaces135 = new SUPPORT; - aFaces135->setMesh( aMesh ); - aFaces135->setName( "Support On Faces 1,3,5" ); - aFaces135->setEntity( MED_EN::MED_FACE ); - - aFaces123->fillFromElementList(faces123); - aFaces135->fillFromElementList(faces135); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces123->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces135->getEntity()); - - list::const_iterator iter123 = faces123.begin(); - list::const_iterator iter135 = faces135.begin(); - for (int i = 1; i <= 3; i++, iter123++, iter135++) - { - CPPUNIT_ASSERT_EQUAL(i, aFaces123->getValIndFromGlobalNumber(*iter123)); - CPPUNIT_ASSERT_EQUAL(i, aFaces135->getValIndFromGlobalNumber(*iter135)); - } - - // substract - SUPPORT * aFaces2 = aFaces123->substract(*aFaces135); // => 2 - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces2->getEntity()); - CPPUNIT_ASSERT_EQUAL(1, aFaces2->getValIndFromGlobalNumber(2)); - CPPUNIT_ASSERT_EQUAL(1, aFaces2->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - CPPUNIT_ASSERT_THROW(aFaces123->substract(*aNodes137), MEDEXCEPTION); - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) SUPPORT::substract() does not work with supports on nodes, - // because it uses method MESH::buildSupportOnNodeFromElementList(), - // which does not work if entity = MED_NODE - //SUPPORT * aNodes137mesh = aMesh->buildSupportOnNodeFromElementList(nodes137, MED_EN::MED_NODE); - //delete aNodes137mesh; - SUPPORT * aNodes137sub = aNodes137->substract(*aNodes248); // => 1,3,7 - CPPUNIT_ASSERT_EQUAL(*aNodes137sub, *aNodes137); - aNodes137sub->removeReference(); - //#endif - - // belongsTo - CPPUNIT_ASSERT(aFaces2->belongsTo(*aFaces123)); - CPPUNIT_ASSERT(!aFaces2->belongsTo(*aFaces135)); - - CPPUNIT_ASSERT(!aFaces2->belongsTo(*aSupportOnFaces3)); - CPPUNIT_ASSERT(aFaces2->belongsTo(*aSupportOnFaces3, /*deepCompare*/true)); - - aFaces2->removeReference(); - - // getComplement - SUPPORT * aFaces_135 = aFaces135->getComplement(); // => 2,4,6,7,8 - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces_135->getEntity()); - CPPUNIT_ASSERT_EQUAL(5, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Memory problem in SUPPORT::sub() - // Invalid read of size 4 - // at 0x34902492: MEDMEM::SUPPORT::sub(int, int, int const*, int) (MEDMEM_Support.cxx:852) - // by 0x3490296B: MEDMEM::SUPPORT::getComplement() const (MEDMEM_Support.cxx:916) - // by 0x34398F1E: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:514) - // Address 0x352DB91C is 0 bytes after a block of size 12 alloc'd - // at 0x3414C8E2: operator new[](unsigned) (vg_replace_malloc.c:138) - // by 0x3490243A: MEDMEM::SUPPORT::sub(int, int, int const*, int) (MEDMEM_Support.cxx:847) - // by 0x3490296B: MEDMEM::SUPPORT::getComplement() const (MEDMEM_Support.cxx:916) - // by 0x34398F1E: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:514) - //CPPUNIT_FAIL("Memory problem in SUPPORT::sub(): Invalid read of size 4 from array "); - //#endif - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) SUPPORT::getComplement() does not work with support on nodes, - // because it uses method MESH::buildSupportOnNodeFromElementList(), - // which does not work if entity = MED_NODE - SUPPORT * aNodes_137 = aNodes137->getComplement(); // => 2,4,5,6,8,9,10-19 - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes_137->getEntity()); - CPPUNIT_ASSERT_EQUAL(16, aNodes_137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - //#endif - - // intersecting - aFaces_135->intersecting(aFaces123); // => 2 - aFaces123->removeReference(); - CPPUNIT_ASSERT_EQUAL(1, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(1, aFaces_135->getValIndFromGlobalNumber(2)); - - //aNodes_137->intersecting(&aNodes248); // => 2,4,8 - //CPPUNIT_ASSERT_EQUAL(3, aNodes_137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - //CPPUNIT_ASSERT_EQUAL(*aNodes_137, aNodes248); - aNodes137->intersecting(aNodes248); // => - { - } - CPPUNIT_ASSERT_EQUAL(0, aNodes137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - aNodes137->removeReference(); - // blending - aFaces_135->blending(aFaces135); // => 1,2,3,5 - CPPUNIT_ASSERT_EQUAL(4, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - aNodes248->blending(aNodes27); // => 2,4,7,8 - aNodes27->removeReference(); - CPPUNIT_ASSERT_EQUAL(4, aNodes248->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - // operator= - SUPPORT *aCopy1=new SUPPORT; - *aCopy1 = *aNodes248; - CPPUNIT_ASSERT_EQUAL(*aNodes248, *aCopy1); - aCopy1->removeReference(); - aNodes248->removeReference(); - // copy constructor - SUPPORT *aCopy2=new SUPPORT (*aFaces135); - CPPUNIT_ASSERT_EQUAL(*aFaces135, *aCopy2); - aCopy2->removeReference(); - - aFaces_135->removeReference(); - //#ifdef ENABLE_FORCED_FAILURES - aNodes_137->removeReference(); - //#endif - - // profil names - vector aPrN2 (2); // nb. types - aPrN2[0] = "Profil 1"; - aPrN2[1] = "Profil 2"; - aFaces135->setProfilNames(aPrN2); - - // because on all elements - CPPUNIT_ASSERT_THROW(aSupportOnFaces3->setProfilNames(aPrN2), MEDEXCEPTION); - - // because length of vector is not equal to nb.types - vector aPrN3 (3); - CPPUNIT_ASSERT_THROW(aFaces135->setProfilNames(aPrN3), MEDEXCEPTION); - - vector aPrN2Back = aFaces135->getProfilNames(); - CPPUNIT_ASSERT_EQUAL(aPrN2[0], aPrN2Back[0]); - CPPUNIT_ASSERT_EQUAL(aPrN2[1], aPrN2Back[1]); - aFaces135->removeReference(); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) profil names are not copied by copy constructor and operator=, - // not compared by operator==, not dumped in stream by operator<< - //CPPUNIT_FAIL("Not complete implementation for Profil Names"); - //#endif - - //////////// - // TEST 3 // - //////////// - - SUPPORT *aPartialCells = new SUPPORT; - aPartialCells->setMesh( aMesh ); - aPartialCells->setName( "Support On Cells 2,3,4" ); - aPartialCells->setEntity( MED_EN::MED_CELL ); - - SUPPORT *aPartialNodes = new SUPPORT; - aPartialNodes->setMesh( aMesh ); - aPartialNodes->setName( "Support On Nodes 2,3,4" ); - aPartialNodes->setEntity( MED_EN::MED_NODE ); - - // setpartial - MED_EN::medGeometryElement gtCells[1] = - { - MED_EN::MED_TETRA4 - }; - int nbCells[1] = - { - 3 - }; - int cells[3] = - { - 2,3,4 - }; - aPartialCells->setpartial("with description", 1, 3, gtCells, nbCells, cells); - CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(2)); - CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(3)); - CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(4)); - - MED_EN::medGeometryElement gtNodes[1] = - { - MED_EN::MED_NONE - }; - aPartialNodes->setNumberOfGeometricType(1); - aPartialNodes->setGeometricType(gtNodes); - int indexSN[2] = - { - 1,4 - }; - int valueSN[3] = - { - 2,3,4 - }; - MEDSKYLINEARRAY * aNumberSN = new MEDSKYLINEARRAY(1, 3, indexSN, valueSN); - aPartialNodes->setpartial(aNumberSN, /*shallowCopy*/false); - delete aNumberSN; - CPPUNIT_ASSERT_EQUAL(1, aPartialNodes->getValIndFromGlobalNumber(2)); - CPPUNIT_ASSERT_EQUAL(2, aPartialNodes->getValIndFromGlobalNumber(3)); - CPPUNIT_ASSERT_EQUAL(3, aPartialNodes->getValIndFromGlobalNumber(4)); - - // changeElementsNbs - - // {1,2,3,4,5,6,7,8,9,10} -> {10,9,8,7,6,5,4,3,2,1} - int renumberingFromOldToNew[10] = - { - 10,9,8,7,6,5,4,3,2,1 - }; - - CPPUNIT_ASSERT_THROW(aPartialCells->changeElementsNbs - (MED_EN::MED_NODE, renumberingFromOldToNew), MEDEXCEPTION); - - aPartialCells->changeElementsNbs(MED_EN::MED_CELL, renumberingFromOldToNew); - CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(9)); - CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(8)); - CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(7)); - - // {1,2,3,4,5,6,7} -> {1,3,5,7,2,4,6}, {8,9,10,11} -> {8,10,9,11} - int renumberingFromOldToNewP[11] = - { - 1,3,5,7,2,4,6,8,10,9,11 - }; - aPartialCells->changeElementsNbs(MED_EN::MED_CELL, renumberingFromOldToNewP); - CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(10)); - CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(8)); - CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(6)); - aPartialCells->removeReference(); - // this method does not suit for nodes renumbering! - // {1,2,3} -> {3,2,1}, {4,5,6,7} -> {5,6,7,4} - //int renumberingFromOldToNewN[3] = {3,2,1}; - //int renumberingFromOldToNewPolyN[4] = {5,6,7,4}; - //aPartialNodes.changeElementsNbs(MED_EN::MED_NODE, renumberingFromOldToNewN, - // 3, renumberingFromOldToNewPolyN); - aPartialNodes->removeReference(); - // getBoundaryElements - //#ifdef ENABLE_FAULTS - // (BUG) Segmentation Fault during SUPPORT::getBoundaryElements() - // ??? May be mesh is not complete ??? - SUPPORT *aBoundaryFaces = new SUPPORT; - aBoundaryFaces->setMesh( aMesh ); - aBoundaryFaces->setName( "meshing boundary faces" ); - aBoundaryFaces->setEntity( MED_EN::MED_FACE ); - aBoundaryFaces->getBoundaryElements(); - //cout << "aBoundaryFaces:" << endl; - //cout << aBoundaryFaces << endl; - aBoundaryFaces->removeReference(); - SUPPORT * aBoundaryNodes = aSupportOnFaces3->getBoundaryElements(MED_EN::MED_NODE); - //cout << "aSupportOnFaces3:" << endl; - //cout << aSupportOnFaces3 << endl; - //cout << "aBoundaryNodes:" << endl; - //cout << aBoundaryNodes << endl; - aBoundaryNodes->removeReference(); - aSupportOnFaces3->removeReference(); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - //CPPUNIT_FAIL("Segmentation Fault during SUPPORT::getBoundaryElements()"); - // Invalid write of size 4 - // at 0x3439DFCE: void std::_Construct(int*, int const&) (stl_construct.h:81) - // by 0x3476E4D1: std::vector >::push_back(int const&) (stl_vector.h:560) - // by 0x34763DDB: MEDMEM::CONNECTIVITY::calculateReverseNodalConnectivity() (MEDMEM_Connectivity.cxx:1155) - // by 0x347655FF: MEDMEM::CONNECTIVITY::calculateDescendingConnectivity() (MEDMEM_Connectivity.cxx:1333) - // by 0x3476363E: MEDMEM::CONNECTIVITY::getReverseDescendingConnectivity() (MEDMEM_Connectivity.cxx:1090) - // by 0x34772AB6: MEDMEM::CONNECTIVITY::getReverseConnectivity(long, long) (MEDMEM_Connectivity.hxx:503) - // by 0x348F4F4B: MEDMEM::MESH::getReverseConnectivity(long, long) const (MEDMEM_Mesh.hxx:848) - // by 0x348FF559: MEDMEM::SUPPORT::getBoundaryElements() (MEDMEM_Support.cxx:483) - // by 0x3439C8E5: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:641) - // Address 0x61666A2F is not stack'd, malloc'd or (recently) free'd - //#endif - aMesh->removeReference(); - aMeshOneMore->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Support_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_Support_fault.cxx deleted file mode 100644 index c9d7c20d1..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Support_fault.cxx +++ /dev/null @@ -1,760 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_Support.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -// #52: MEDMEM_Support.hxx } MEDMEMTest_Support.cxx - -/*! - * Check methods (48), defined in MEDMEM_Support.hxx: - * class SUPPORT : public RCBASE -{ - * (+) SUPPORT(); - * (+) SUPPORT(MESH* Mesh, string Name="", MED_EN::medEntityMesh Entity=MED_EN::MED_CELL); - * (+) SUPPORT(const SUPPORT & m); - * (+) virtual ~SUPPORT(); - * - * (+) friend ostream & operator<<(ostream &os,const SUPPORT &my); - * (+) SUPPORT& operator=(const SUPPORT &support); - * (+) bool operator == (const SUPPORT &support) const; - * (+) bool deepCompare(const SUPPORT &support) const; - * - * (+) void update(); - * - * (+) inline void setName(string Name); - * (+) inline void setDescription(string Description); - * (+) void setMesh(MESH *Mesh) const; - * (+) inline void setMeshName(const string & meshName); - * (+) inline void setAll(bool All); - * (+) inline void setEntity(MED_EN::medEntityMesh Entity); - * - * (+) inline void setNumberOfGeometricType(int NumberOfGeometricType); - * (+) inline void setGeometricType(const MED_EN::medGeometryElement *GeometricType); - * (+) inline void setNumberOfElements(const int *NumberOfElements); - * (+) inline void setTotalNumberOfElements(int TotalNumberOfElements); - * (+) inline void setNumber(MEDSKYLINEARRAY * Number); - * (+) inline void setNumber(const int * index, const int* value, bool shallowCopy=false); - * - * (+) inline string getName() const; - * (+) inline string getDescription() const; - * (+) virtual inline MESH * getMesh() const; - * (+) string getMeshName() const; - * (+) inline MED_EN::medEntityMesh getEntity() const; - * (+) inline bool isOnAllElements() const; - * - * (+) inline int getNumberOfTypes() const; - * (+) inline const MED_EN::medGeometryElement* getTypes() const; - * (+) inline int getNumberOfElements - * (MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - * (+) inline const int * getNumberOfElements() const throw (MEDEXCEPTION); - * (+) virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION); - * (NO METHOD IN THIS BRANCH) virtual inline MEDSKYLINEARRAY * getnumberFromFile() const throw (MEDEXCEPTION); - * (+) virtual inline const int * getNumber - * (MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - * (NO METHOD IN THIS BRANCH) virtual inline const int * getNumberFromFile - * (MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION); - * (+) virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION); - * (+) virtual int getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION); - * - * (+) void blending(SUPPORT * mySupport) throw (MEDEXCEPTION); - * - * (+) void setpartial(string Description, int NumberOfGeometricType, - * int TotalNumberOfEntity, MED_EN::medGeometryElement *GeometricType, - * int *NumberOfEntity, int *NumberValue); - * (+) void setpartial(MEDSKYLINEARRAY * number, bool shallowCopy=false) throw (MEDEXCEPTION); - * (NO METHOD IN THIS BRANCH) void setpartial_fromfile(MEDSKYLINEARRAY * number, bool shallowCopy=false) throw (MEDEXCEPTION); - * - * (+) void setProfilNames(vector profilNames) throw (MEDEXCEPTION); - * (+) vector getProfilNames() const throw (MEDEXCEPTION); - * - * (+) void getBoundaryElements() throw (MEDEXCEPTION); - * - * (+) void changeElementsNbs(MED_EN::medEntityMesh entity, const int *renumberingFromOldToNew); - * (+) void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION); - * (+) bool belongsTo(const SUPPORT& other, bool deepCompare=false) const; - * - * (+) SUPPORT *getComplement() const; - * (+) SUPPORT *substract(const SUPPORT& other) const throw (MEDEXCEPTION); - * - * (+) SUPPORT *getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION); - * - * (+) void fillFromNodeList(const list& listOfNode) throw (MEDEXCEPTION); - * (+) void fillFromElementList(const list& listOfElt) throw (MEDEXCEPTION); - * - * (+) void clearDataOnNumbers(); - * - * (reference counter presently disconnected in C++) virtual void addReference() const; - * (reference counter presently disconnected in C++) virtual void removeReference() const; - * -} - */ -static void MEDMEMTest_testSupport() -{ - MESH * aMesh = MEDMEMTest_createTestMesh(); - MESH * aMeshOneMore = MEDMEMTest_createTestMesh(); - - //////////// - // TEST 1 // - //////////// - - SUPPORT *aSupportOnFaces1 = new SUPPORT; - aSupportOnFaces1->setMesh( aMesh ); - aSupportOnFaces1->setName( "Support On Faces 1" ); - aSupportOnFaces1->setEntity( MED_EN::MED_FACE ); - aSupportOnFaces1->setAll( true ); - aSupportOnFaces1->update(); - - SUPPORT *aSupportOnCells1 = new SUPPORT; - aSupportOnCells1->setMesh( aMesh ); - aSupportOnCells1->setName( "Support On Cells 1" ); - aSupportOnFaces1->setAll( true ); - aSupportOnFaces1->update(); - - SUPPORT *aSupportOnFaces2=new SUPPORT; - SUPPORT *aSupportOnCells2=new SUPPORT; - - SUPPORT *aSupportOnFaces3 = new SUPPORT; - aSupportOnFaces3->setMesh( aMeshOneMore ); - aSupportOnFaces3->setName( "Support On Faces 3" ); - aSupportOnFaces3->setEntity( MED_EN::MED_FACE ); - aSupportOnFaces1->setAll( true ); - aSupportOnFaces1->update(); - - // entity - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aSupportOnFaces1->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnCells1->getEntity()); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnFaces2->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnCells2->getEntity()); - - aSupportOnFaces2->setEntity(MED_EN::MED_FACE); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aSupportOnFaces2->getEntity()); - - // isOnAllElements - CPPUNIT_ASSERT(aSupportOnFaces1->isOnAllElements()); - CPPUNIT_ASSERT(aSupportOnCells1->isOnAllElements()); - - CPPUNIT_ASSERT(!aSupportOnFaces2->isOnAllElements()); - CPPUNIT_ASSERT(!aSupportOnCells2->isOnAllElements()); - - // mesh and mesh name - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->setMeshName("Mesh 1"), MEDEXCEPTION); - - aSupportOnFaces2->setMeshName("Mesh 1"); - aSupportOnCells2->setMeshName("Mesh 1"); - CPPUNIT_ASSERT(aSupportOnFaces2->getMeshName() == "Mesh 1"); - CPPUNIT_ASSERT(aSupportOnCells2->getMeshName() == "Mesh 1"); - - aSupportOnFaces2->setMesh(aMesh); - CPPUNIT_ASSERT_THROW(aSupportOnFaces2->setMeshName("Mesh 1"), MEDEXCEPTION); - - aSupportOnCells1->setMesh(NULL); - aSupportOnCells1->setMeshName("Mesh 1"); - - CPPUNIT_ASSERT(aSupportOnFaces1->getMeshName() == "meshing"); - CPPUNIT_ASSERT(aSupportOnFaces2->getMeshName() == "meshing"); - CPPUNIT_ASSERT(aSupportOnCells1->getMeshName() == "Mesh 1"); - CPPUNIT_ASSERT(aSupportOnCells2->getMeshName() == "Mesh 1"); - - CPPUNIT_ASSERT(aSupportOnFaces1->getMesh() == aMesh); - CPPUNIT_ASSERT(aSupportOnFaces2->getMesh() == aMesh); - CPPUNIT_ASSERT(aSupportOnCells1->getMesh() == NULL); - CPPUNIT_ASSERT(aSupportOnCells2->getMesh() == NULL); - - // operator == - aSupportOnFaces2->setName("Support On Faces 2"); - aSupportOnCells2->setName("Support On Cells 2"); - - // because aSupportOnFaces1 is on all elements, but aSupportOnFaces2 not - CPPUNIT_ASSERT(!(aSupportOnFaces1 == aSupportOnFaces2)); - - aSupportOnCells1->setAll(false); - CPPUNIT_ASSERT(!aSupportOnCells1->isOnAllElements()); - // this is only sets flag _isOnAllElts to false, but not clear elements and types - // information, so aSupportOnCells1 is not equal to aSupportOnCells2 at this moment - - //#ifdef ENABLE_FAULTS - // (BUG) SUPPORT::operator= gives "Segmentation Fault" on supports with NULL meshes!!! - CPPUNIT_ASSERT(!(aSupportOnCells1 == aSupportOnCells2)); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("SUPPORT::operator= gives Segmentation Fault on supports with NULL meshes!!!"); - //#endif - - aSupportOnFaces2->setAll(true); - CPPUNIT_ASSERT(aSupportOnFaces2->isOnAllElements()); - // flag _isOnAllElts now is set to true, but we need also to call update() - // to set elements and types information from mesh to this support - CPPUNIT_ASSERT(!(aSupportOnFaces1 == aSupportOnFaces2)); - aSupportOnFaces2->update(); - CPPUNIT_ASSERT(aSupportOnFaces1 == aSupportOnFaces2); - - // deep compare - CPPUNIT_ASSERT(aSupportOnFaces1->deepCompare(*aSupportOnFaces2)); - - CPPUNIT_ASSERT(!(aSupportOnFaces1 == aSupportOnFaces3)); // different mesh pointers - CPPUNIT_ASSERT(aSupportOnFaces1->deepCompare(*aSupportOnFaces3)); // meshes are really equal - - // description - aSupportOnFaces1->setDescription("Support on all faces with mesh pointer"); - aSupportOnFaces2->setDescription("Support on all faces with mesh pointer"); - - aSupportOnCells1->setDescription("Support on a part of cells with mesh name"); - aSupportOnCells2->setDescription("Support on a part of cells with mesh name"); - - CPPUNIT_ASSERT(aSupportOnFaces1->getDescription() == "Support on all faces with mesh pointer"); - CPPUNIT_ASSERT(aSupportOnFaces2->getDescription() == "Support on all faces with mesh pointer"); - CPPUNIT_ASSERT(aSupportOnCells1->getDescription() == "Support on a part of cells with mesh name"); - CPPUNIT_ASSERT(aSupportOnCells2->getDescription() == "Support on a part of cells with mesh name"); - - // operator<< - ostringstream ostr1; - ostr1 << aSupportOnFaces1; - CPPUNIT_ASSERT(ostr1.str() != ""); - - ostringstream ostr2; - ostr2 << aSupportOnCells2; - CPPUNIT_ASSERT(ostr2.str() != ""); - - // set/get elements and types information - - // 1. aSupportOnCells1 is not on all elements, but now it contains information - // about all cells of aMesh, because it was created on mesh and with parameters. - CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells1->getTypes() != NULL); - - aSupportOnCells1->setNumberOfGeometricType(0); - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells1->getTypes() == NULL); - - MED_EN::medGeometryElement aSCTypes[2] = - { - MED_EN::MED_PYRA5, MED_EN::MED_PENTA15 - }; - aSupportOnCells1->setNumberOfGeometricType(2); - aSupportOnCells1->setGeometricType(aSCTypes); - - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells1->getTypes() != NULL); - CPPUNIT_ASSERT(aSupportOnCells1->getNumberOfElements() == NULL); // reset by setNumberOfGeometricType - - int nbEltsSC[2] = - { - 2, 1 - }; - aSupportOnCells1->setNumberOfElements(nbEltsSC); - - const int * nbEltsSCBack = aSupportOnCells1->getNumberOfElements(); - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells1->getNumberOfElements(MED_EN::MED_PYRA5)); - CPPUNIT_ASSERT_EQUAL(2, nbEltsSCBack[0]); - CPPUNIT_ASSERT_EQUAL(1, aSupportOnCells1->getNumberOfElements(MED_EN::MED_PENTA15)); - CPPUNIT_ASSERT_EQUAL(1, nbEltsSCBack[1]); - CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - // old types - CPPUNIT_ASSERT_THROW(aSupportOnCells1->getNumberOfElements(MED_EN::MED_TETRA4), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnCells1->getNumberOfElements(MED_EN::MED_HEXA8), MEDEXCEPTION); - - //_number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy); - int indexSC[3] = - { - 1,3,4 - }; // length = nb.types + 1 - int valueSC[3] = - { - 21,22,47 - }; // length = total nb. of elements - aSupportOnCells1->setNumber(indexSC, valueSC); - - // check number - MEDSKYLINEARRAY * aNumberSCBack = aSupportOnCells1->getnumber(); - - CPPUNIT_ASSERT_EQUAL(2, aNumberSCBack->getNumberOf()); - CPPUNIT_ASSERT_EQUAL(3, aNumberSCBack->getLength()); - const int * ind = aNumberSCBack->getIndex(); - const int * val = aNumberSCBack->getValue(); - CPPUNIT_ASSERT_EQUAL(1, ind[0]); - CPPUNIT_ASSERT_EQUAL(3, ind[1]); - CPPUNIT_ASSERT_EQUAL(4, ind[2]); - CPPUNIT_ASSERT_EQUAL(21, val[0]); - CPPUNIT_ASSERT_EQUAL(22, val[1]); - CPPUNIT_ASSERT_EQUAL(47, val[2]); - - // 2. aSupportOnCells2 is not on all elements, and now it contains - // no information about elements of a mesh - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells2->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells2->getTypes() == NULL); - - aSupportOnCells2->setNumberOfGeometricType(2); - aSupportOnCells2->setGeometricType(aSCTypes); - - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells2->getNumberOfTypes()); - CPPUNIT_ASSERT(aSupportOnCells2->getTypes() != NULL); - - aSupportOnCells2->setNumberOfElements(nbEltsSC); - - // we create MEDSKYLINEARRAY as pointer, because aSupportOnCells2 will - // become an owner of it, and we must not delete it. - MEDSKYLINEARRAY * aNumberSC = new MEDSKYLINEARRAY(2, 3, indexSC, valueSC); - aSupportOnCells2->setNumber(aNumberSC); - - // check number - const int * aNumberIndexSC = aSupportOnCells2->getNumberIndex(); - CPPUNIT_ASSERT_EQUAL(1, aNumberIndexSC[0]); - CPPUNIT_ASSERT_EQUAL(3, aNumberIndexSC[1]); - CPPUNIT_ASSERT_EQUAL(4, aNumberIndexSC[2]); - - const int * aNbPYRA5 = aSupportOnCells2->getNumber(MED_EN::MED_PYRA5); - const int * aNbPENTA15 = aSupportOnCells2->getNumber(MED_EN::MED_PENTA15); - CPPUNIT_ASSERT_THROW(aSupportOnCells2->getNumber(MED_EN::MED_TETRA4), MEDEXCEPTION); - - const int * aNbC = aSupportOnCells2->getNumber(MED_EN::MED_ALL_ELEMENTS); - - CPPUNIT_ASSERT_EQUAL(21, aNbPYRA5[0]); - CPPUNIT_ASSERT_EQUAL(22, aNbPYRA5[1]); - CPPUNIT_ASSERT_EQUAL(47, aNbPENTA15[0]); - - CPPUNIT_ASSERT_EQUAL(21, aNbC[0]); - CPPUNIT_ASSERT_EQUAL(22, aNbC[1]); - CPPUNIT_ASSERT_EQUAL(47, aNbC[2]); - - // getValIndFromGlobalNumber - CPPUNIT_ASSERT_EQUAL(1, aSupportOnCells2->getValIndFromGlobalNumber(21)); - CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells2->getValIndFromGlobalNumber(22)); - CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells2->getValIndFromGlobalNumber(47)); - // not existing element - CPPUNIT_ASSERT_THROW(aSupportOnCells2->getValIndFromGlobalNumber(10), MEDEXCEPTION); - - // compare aSupportOnCells1 and aSupportOnCells2 - - // temporary set mesh (because of bug with operator==) - aSupportOnCells1->setMesh(aMesh); - aSupportOnCells2->setMesh(aMesh); - - CPPUNIT_ASSERT_EQUAL(aSupportOnCells1, aSupportOnCells2); - - // restore mesh name - aSupportOnCells1->setMesh(NULL); - aSupportOnCells2->setMesh(NULL); - aSupportOnCells1->setMeshName("Mesh 1"); - aSupportOnCells2->setMeshName("Mesh 1"); - - // 3. aSupportOnFacesN is on all elements, and it contains - // information about all faces of aMesh - CPPUNIT_ASSERT_EQUAL(2, aSupportOnFaces1->getNumberOfTypes()); - const MED_EN::medGeometryElement* aSF1Types = aSupportOnFaces1->getTypes(); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_TRIA3, aSF1Types[0]); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_QUAD4, aSF1Types[1]); - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Comment to method SUPPORT::getTypes() says: - // "If isOnAllElements is false, returns an array of %medGeometryElement types used by the support." - // But in fact it returns types in any case (comment to SUPPORT::setAll() gives more information). - // CPPUNIT_FAIL("Comment and implementation does not match for SUPPORT::getTypes()"); - // This concerns also method SUPPORT::update(), being called from constructor, - // which fills internal SUPPORT structures with information about mesh elements - // in case of isOnAllElements == true. - // Also comments and implementation does not match for SUPPORT::getNumberOfElements(). - // It seems that in case "isOnAllElements == true" calls like getNumberOfElements() - // must be redirected to mesh, but what if mesh is not set (mesh name used instead)?. - //#endif - const int * nbEltsSF1 = aSupportOnFaces1->getNumberOfElements(); - CPPUNIT_ASSERT_EQUAL(4, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_TRIA3)); - CPPUNIT_ASSERT_EQUAL(4, nbEltsSF1[0]); - CPPUNIT_ASSERT_EQUAL(4, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_QUAD4)); - CPPUNIT_ASSERT_EQUAL(4, nbEltsSF1[1]); - CPPUNIT_ASSERT_EQUAL(8, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumberOfElements(MED_EN::MED_TRIA6), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumberOfElements(MED_EN::MED_QUAD8), MEDEXCEPTION); - - // check number - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumberIndex(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_TRIA3), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_QUAD4), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_ALL_ELEMENTS), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getnumber(), MEDEXCEPTION); - - // getValIndFromGlobalNumber - CPPUNIT_ASSERT_EQUAL(8, aMesh->getNumberOfElements(MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS)); - for (int i = 1; i <= 8; i++) - { - CPPUNIT_ASSERT_EQUAL(i, aSupportOnFaces1->getValIndFromGlobalNumber(i)); - } - - //#ifdef ENABLE_FORCED_FAILURES - // Why methods setNumber do not throw exception in case "isOnAllElements == true", - // like methods getNumber do? - //CPPUNIT_ASSERT_THROW(aSupportOnFaces1->setNumber(indexSF1, valueSF1)); - //#endif - - // skl: setTotalNumberOfElements() is removed. - //#ifdef ENABLE_FORCED_FAILURES - // It seems to be dangerous and useless to have method SUPPORT::setTotalNumberOfElements() - //CPPUNIT_FAIL("It seems to be dangerous and useless to have method SUPPORT::setTotalNumberOfElements()"); - //#endif - - // following test is commented since method - // setTotalNumberOfElements() is removed. - /* - // setTotalNumberOfElements - aSupportOnFaces1->setTotalNumberOfElements(1000); - CPPUNIT_ASSERT_EQUAL(1000, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - */ - - // clearDataOnNumbers - aSupportOnCells1->clearDataOnNumbers(); - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfTypes()); - CPPUNIT_ASSERT_THROW(aSupportOnCells1->getnumber(), MEDEXCEPTION); - - //////////// - // TEST 2 // - //////////// - - list nodes137; - nodes137.push_back(1); - nodes137.push_back(3); - nodes137.push_back(7); - - list nodes248; - nodes248.push_back(2); - nodes248.push_back(4); - nodes248.push_back(8); - - list nodes27; - nodes27.push_back(2); - nodes27.push_back(7); - - SUPPORT *aNodes137 = new SUPPORT; - SUPPORT *aNodes248 = new SUPPORT; - SUPPORT *aNodes27 = new SUPPORT; - aNodes137->setMesh( aMesh ); - aNodes248->setMesh( aMesh ); - aNodes27->setMesh( aMesh ); - aNodes137->setName( "Support On Nodes 1,3,7" ); - aNodes248->setName( "Support On Nodes 2,4,8" ); - aNodes27->setName( "Support On Nodes 2,7" ); - - aNodes137->fillFromNodeList(nodes137); - aNodes248->fillFromNodeList(nodes248); - aNodes27->fillFromNodeList(nodes27); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes137->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes248->getEntity()); - - list::const_iterator iter137 = nodes137.begin(); - list::const_iterator iter248 = nodes248.begin(); - for (int i = 1; i <= 3; i++, iter137++, iter248++) - { - CPPUNIT_ASSERT_EQUAL(i, aNodes137->getValIndFromGlobalNumber(*iter137)); - CPPUNIT_ASSERT_EQUAL(i, aNodes248->getValIndFromGlobalNumber(*iter248)); - } - - //////////// - - list faces123; - faces123.push_back(1); - faces123.push_back(2); - faces123.push_back(3); - - list faces135; - faces135.push_back(1); - faces135.push_back(3); - faces135.push_back(5); - - SUPPORT *aFaces123 = new SUPPORT; - aFaces123->setMesh( aMesh ); - aFaces123->setName( "Support On Faces 1,2,3" ); - aFaces123->setEntity( MED_EN::MED_FACE ); - SUPPORT *aFaces135 = new SUPPORT; - aFaces135->setMesh( aMesh ); - aFaces135->setName( "Support On Faces 1,3,5" ); - aFaces135->setEntity( MED_EN::MED_FACE ); - - aFaces123->fillFromElementList(faces123); - aFaces135->fillFromElementList(faces135); - - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces123->getEntity()); - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces135->getEntity()); - - list::const_iterator iter123 = faces123.begin(); - list::const_iterator iter135 = faces135.begin(); - for (int i = 1; i <= 3; i++, iter123++, iter135++) - { - CPPUNIT_ASSERT_EQUAL(i, aFaces123->getValIndFromGlobalNumber(*iter123)); - CPPUNIT_ASSERT_EQUAL(i, aFaces135->getValIndFromGlobalNumber(*iter135)); - } - - // substract - SUPPORT * aFaces2 = aFaces123->substract(*aFaces135); // => 2 - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces2->getEntity()); - CPPUNIT_ASSERT_EQUAL(1, aFaces2->getValIndFromGlobalNumber(2)); - CPPUNIT_ASSERT_EQUAL(1, aFaces2->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - CPPUNIT_ASSERT_THROW(aFaces123->substract(*aNodes137), MEDEXCEPTION); - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) SUPPORT::substract() does not work with supports on nodes, - // because it uses method MESH::buildSupportOnNodeFromElementList(), - // which does not work if entity = MED_NODE - //SUPPORT * aNodes137mesh = aMesh->buildSupportOnNodeFromElementList(nodes137, MED_EN::MED_NODE); - //delete aNodes137mesh; - SUPPORT * aNodes137sub = aNodes137->substract(*aNodes248); // => 1,3,7 - CPPUNIT_ASSERT_EQUAL(*aNodes137sub, *aNodes137); - aNodes137sub->removeReference(); - //#endif - - // belongsTo - CPPUNIT_ASSERT(aFaces2->belongsTo(*aFaces123)); - CPPUNIT_ASSERT(!aFaces2->belongsTo(*aFaces135)); - - CPPUNIT_ASSERT(!aFaces2->belongsTo(*aSupportOnFaces3)); - CPPUNIT_ASSERT(aFaces2->belongsTo(*aSupportOnFaces3, /*deepCompare*/true)); - - aFaces2->removeReference(); - - // getComplement - SUPPORT * aFaces_135 = aFaces135->getComplement(); // => 2,4,6,7,8 - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces_135->getEntity()); - CPPUNIT_ASSERT_EQUAL(5, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) Memory problem in SUPPORT::sub() - // Invalid read of size 4 - // at 0x34902492: MEDMEM::SUPPORT::sub(int, int, int const*, int) (MEDMEM_Support.cxx:852) - // by 0x3490296B: MEDMEM::SUPPORT::getComplement() const (MEDMEM_Support.cxx:916) - // by 0x34398F1E: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:514) - // Address 0x352DB91C is 0 bytes after a block of size 12 alloc'd - // at 0x3414C8E2: operator new[](unsigned) (vg_replace_malloc.c:138) - // by 0x3490243A: MEDMEM::SUPPORT::sub(int, int, int const*, int) (MEDMEM_Support.cxx:847) - // by 0x3490296B: MEDMEM::SUPPORT::getComplement() const (MEDMEM_Support.cxx:916) - // by 0x34398F1E: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:514) - // CPPUNIT_FAIL("Memory problem in SUPPORT::sub(): Invalid read of size 4 from array "); - //#endif - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) SUPPORT::getComplement() does not work with support on nodes, - // because it uses method MESH::buildSupportOnNodeFromElementList(), - // which does not work if entity = MED_NODE - SUPPORT * aNodes_137 = aNodes137->getComplement(); // => 2,4,5,6,8,9,10-19 - CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes_137->getEntity()); - CPPUNIT_ASSERT_EQUAL(16, aNodes_137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - //#endif - - // intersecting - aFaces_135->intersecting(aFaces123); // => 2 - CPPUNIT_ASSERT_EQUAL(1, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - CPPUNIT_ASSERT_EQUAL(1, aFaces_135->getValIndFromGlobalNumber(2)); - - //aNodes_137->intersecting(&aNodes248); // => 2,4,8 - //CPPUNIT_ASSERT_EQUAL(3, aNodes_137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - //CPPUNIT_ASSERT_EQUAL(*aNodes_137, aNodes248); - aNodes137->intersecting(aNodes248); // => - { - } - CPPUNIT_ASSERT_EQUAL(0, aNodes137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - // blending - aFaces_135->blending(aFaces135); // => 1,2,3,5 - CPPUNIT_ASSERT_EQUAL(4, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - aNodes248->blending(aNodes27); // => 2,4,7,8 - CPPUNIT_ASSERT_EQUAL(4, aNodes248->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - // operator= - SUPPORT *aCopy1=new SUPPORT; - *aCopy1 = *aNodes248; - CPPUNIT_ASSERT_EQUAL(*aNodes248, *aCopy1); - - // copy constructor - SUPPORT *aCopy2=new SUPPORT(*aFaces135); - CPPUNIT_ASSERT_EQUAL(*aFaces135, *aCopy2); - - aFaces_135->removeReference(); - //#ifdef ENABLE_FORCED_FAILURES - aNodes_137->removeReference(); - //#endif - - // profil names - vector aPrN2 (2); // nb. types - aPrN2[0] = "Profil 1"; - aPrN2[1] = "Profil 2"; - aFaces135->setProfilNames(aPrN2); - - // because on all elements - CPPUNIT_ASSERT_THROW(aSupportOnFaces3->setProfilNames(aPrN2), MEDEXCEPTION); - - // because length of vector is not equal to nb.types - vector aPrN3 (3); - CPPUNIT_ASSERT_THROW(aFaces135->setProfilNames(aPrN3), MEDEXCEPTION); - - vector aPrN2Back = aFaces135->getProfilNames(); - CPPUNIT_ASSERT_EQUAL(aPrN2[0], aPrN2Back[0]); - CPPUNIT_ASSERT_EQUAL(aPrN2[1], aPrN2Back[1]); - - //#ifdef ENABLE_FORCED_FAILURES - // (BUG) profil names are not copied by copy constructor and operator=, - // not compared by operator==, not dumped in stream by operator<< - //CPPUNIT_FAIL("Not complete implementation for Profil Names"); - //#endif - - //////////// - // TEST 3 // - //////////// - - SUPPORT *aPartialCells = new SUPPORT; - aPartialCells->setMesh( aMesh ); - aPartialCells->setName( "Support On Cells 2,3,4" ); - aPartialCells->setEntity( MED_EN::MED_CELL ); - - SUPPORT *aPartialNodes = new SUPPORT; - aPartialNodes->setMesh( aMesh ); - aPartialNodes->setName( "Support On Nodes 2,3,4" ); - aPartialNodes->setEntity( MED_EN::MED_NODE ); - - // setpartial - MED_EN::medGeometryElement gtCells[1] = - { - MED_EN::MED_TETRA4 - }; - int nbCells[1] = - { - 3 - }; - int cells[3] = - { - 2,3,4 - }; - aPartialCells->setpartial("with description", 1, 3, gtCells, nbCells, cells); - CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(2)); - CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(3)); - CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(4)); - - MED_EN::medGeometryElement gtNodes[1] = - { - MED_EN::MED_NONE - }; - aPartialNodes->setNumberOfGeometricType(1); - aPartialNodes->setGeometricType(gtNodes); - int indexSN[2] = - { - 1,4 - }; - int valueSN[3] = - { - 2,3,4 - }; - MEDSKYLINEARRAY * aNumberSN = new MEDSKYLINEARRAY(1, 3, indexSN, valueSN); - aPartialNodes->setpartial(aNumberSN, /*shallowCopy*/false); - delete aNumberSN; - CPPUNIT_ASSERT_EQUAL(1, aPartialNodes->getValIndFromGlobalNumber(2)); - CPPUNIT_ASSERT_EQUAL(2, aPartialNodes->getValIndFromGlobalNumber(3)); - CPPUNIT_ASSERT_EQUAL(3, aPartialNodes->getValIndFromGlobalNumber(4)); - - // changeElementsNbs - - // {1,2,3,4,5,6,7,8,9,10} -> {10,9,8,7,6,5,4,3,2,1} - int renumberingFromOldToNew[10] = - { - 10,9,8,7,6,5,4,3,2,1 - }; - - CPPUNIT_ASSERT_THROW(aPartialCells->changeElementsNbs - (MED_EN::MED_NODE, renumberingFromOldToNew), MEDEXCEPTION); - - aPartialCells->changeElementsNbs(MED_EN::MED_CELL, renumberingFromOldToNew); - CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(9)); - CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(8)); - CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(7)); - - // {1,2,3,4,5,6,7} -> {1,3,5,7,2,4,6}, {8,9,10,11} -> {8,10,9,11} - int renumberingFromOldToNewP[11] = - { - 1,3,5,7,2,4,6,8,10,9,11 - }; - aPartialCells->changeElementsNbs(MED_EN::MED_CELL, renumberingFromOldToNewP); - CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(10)); - CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(8)); - CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(6)); - - // this method does not suit for nodes renumbering! - // {1,2,3} -> {3,2,1}, {4,5,6,7} -> {5,6,7,4} - //int renumberingFromOldToNewN[3] = {3,2,1}; - //int renumberingFromOldToNewPolyN[4] = {5,6,7,4}; - //aPartialNodes.changeElementsNbs(MED_EN::MED_NODE, renumberingFromOldToNewN, - // 3, renumberingFromOldToNewPolyN); - - // getBoundaryElements - //#ifdef ENABLE_FAULTS - // (BUG) Segmentation Fault during SUPPORT::getBoundaryElements() - // ??? May be mesh is not complete ??? - SUPPORT *aBoundaryFaces = new SUPPORT; - aBoundaryFaces->setMesh( aMesh ); - aBoundaryFaces->setName( "meshing boundary faces" ); - aBoundaryFaces->setEntity( MED_EN::MED_FACE ); - //cout << "aBoundaryFaces:" << endl; - //cout << aBoundaryFaces << endl; - aBoundaryFaces->removeReference(); - - SUPPORT * aBoundaryNodes = aSupportOnFaces3->getBoundaryElements(MED_EN::MED_NODE); - //cout << "aSupportOnFaces3:" << endl; - //cout << aSupportOnFaces3 << endl; - //cout << "aBoundaryNodes:" << endl; - //cout << aBoundaryNodes << endl; - aBoundaryNodes->removeReference(); - //#endif - //#ifdef ENABLE_FORCED_FAILURES - // CPPUNIT_FAIL("Segmentation Fault during SUPPORT::getBoundaryElements()"); - // Invalid write of size 4 - // at 0x3439DFCE: void std::_Construct(int*, int const&) (stl_construct.h:81) - // by 0x3476E4D1: std::vector >::push_back(int const&) (stl_vector.h:560) - // by 0x34763DDB: MEDMEM::CONNECTIVITY::calculateReverseNodalConnectivity() (MEDMEM_Connectivity.cxx:1155) - // by 0x347655FF: MEDMEM::CONNECTIVITY::calculateDescendingConnectivity() (MEDMEM_Connectivity.cxx:1333) - // by 0x3476363E: MEDMEM::CONNECTIVITY::getReverseDescendingConnectivity() (MEDMEM_Connectivity.cxx:1090) - // by 0x34772AB6: MEDMEM::CONNECTIVITY::getReverseConnectivity(long, long) (MEDMEM_Connectivity.hxx:503) - // by 0x348F4F4B: MEDMEM::MESH::getReverseConnectivity(long, long) const (MEDMEM_Mesh.hxx:848) - // by 0x348FF559: MEDMEM::SUPPORT::getBoundaryElements() (MEDMEM_Support.cxx:483) - // by 0x3439C8E5: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:641) - // Address 0x61666A2F is not stack'd, malloc'd or (recently) free'd - //#endif - - delete aMesh; - delete aMeshOneMore; -} - -int main (int argc, char** argv) -{ - MEDMEMTest_testSupport(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_TopLevel.cxx b/src/MEDMEMCppTest/MEDMEMTest_TopLevel.cxx deleted file mode 100644 index 275ae407c..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_TopLevel.cxx +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (6), defined in MEDMEM_TopLevel.hxx: - * (+) MESH *readMeshInFile(const std::string& fileName, const std::string& meshName); - * (+) template FIELD *readFieldInFile - * (const std::string& fileName, const std::string& fieldName); - * (+) void writeMeshToFile(const MESH *meshObj, const std::string& fileName); - * (-) template void writeFieldToFile(const FIELD *fieldObj, const std::string& fileName); - */ -void MEDMEMTest::testTopLevel() -{ - string filename_rd = getResourceFile("pointe.med"); - string filename22_rd = getResourceFile("pointe.med"); - string filenameMesh_wr = makeTmpFile("myMesh.med"); - string filenameMed_wr = makeTmpFile("myMed.med"); - string filenameField_wr = makeTmpFile("myField.med"); - string fileNotExist_rd = "/notExist.med"; - string fileNotExist_wr = "/path_not_exist/file_not_exist.med"; - string meshname = "maa1"; - string meshname_not_exist = "anymesh"; - string fieldname_not_exist = "anyfield"; - string fieldname = "fieldnodedouble"; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filenameMesh_wr); - aRemover.Register(filenameMed_wr); - aRemover.Register(filenameField_wr); - - /////////////////// - //Test Read Part // - /////////////////// - { - CPPUNIT_ASSERT_THROW(readMeshInFile(fileNotExist_rd, meshname), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(readFieldInFile(fileNotExist_rd, fieldname), MEDEXCEPTION); - - //Trying read not existing mesh from file - CPPUNIT_ASSERT_THROW(readMeshInFile(filename_rd, meshname_not_exist), MEDEXCEPTION); - - //Trying read not existing field from file - CPPUNIT_ASSERT_THROW(readFieldInFile(filename_rd, fieldname_not_exist), MEDEXCEPTION); - - //Test readMeshInFile() method - { - MESH * aMesh = NULL; - CPPUNIT_ASSERT_NO_THROW(aMesh = readMeshInFile(filename22_rd, meshname)); - CPPUNIT_ASSERT(aMesh); - aMesh->removeReference(); - } - - //Test readFieldInFile() method - { - FIELD * aField = NULL; - CPPUNIT_ASSERT_NO_THROW(aField = readFieldInFile(filename22_rd, fieldname)); - CPPUNIT_ASSERT(aField); - aField->removeReference(); - } - } - - //////////////////// - //Test Write Part // - //////////////////// - { - //Create a FIELD - FIELD *aField_1 = new FIELD(); - - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver22 = - new MED_FIELD_RDONLY_DRIVER(filename22_rd, aField_1); - aMedRdFieldDriver22->setFieldName(fieldname); - aMedRdFieldDriver22->open(); - aMedRdFieldDriver22->read(); - aMedRdFieldDriver22->close(); - - //Create a MESH - MESH * aMesh = MEDMEMTest_createTestMesh(); - CPPUNIT_ASSERT_THROW(writeMeshToFile(aMesh, fileNotExist_wr), MEDEXCEPTION); - - //Trying write mesh in the file with empty name - aMesh->setName(""); - CPPUNIT_ASSERT_THROW(writeMeshToFile(aMesh, filenameField_wr), MEDEXCEPTION); - - //Test writeMeshToFile() method - aMesh->setName(meshname); - CPPUNIT_ASSERT_NO_THROW(writeMeshToFile(aMesh, filenameMesh_wr)); - - aField_1->removeReference(); - aMesh->removeReference(); - } -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Unit.cxx b/src/MEDMEMCppTest/MEDMEMTest_Unit.cxx deleted file mode 100644 index dd0a54103..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Unit.cxx +++ /dev/null @@ -1,354 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include - -#include -#include - -#include - -using namespace std; -using namespace MEDMEM; - - -/*! - * Check methods (18), defined in MEDMEM_Unit.hxx: - * class UNIT { - * (+) UNIT(); - * (+) UNIT(string Name, string Description); - * (+) ~UNIT(); - * (+) UNIT & operator=(const UNIT &unit); - * (+) inline void setName(string Name); - * (+) inline void setDescription(string Description); - * (+) inline void setMasse(int Masse); - * (+) inline void setLength(int Length); - * (+) inline void setTime(int Time); - * (+) inline void setTemperature(int Temperature); - * (+) inline void setMatterQuantity(int MatterQuantity); - * (+) void setCurrentStrength(int CurrentStrength); - * (+) inline void setLightIntensity(int LightIntensity); - * - * (+) inline string getName() const; - * (+) inline string getDescription() const; - * (+) inline int getMasse() const; - * (+) inline int getLength() const; - * (+) inline int getTime() const; - * (+) inline int getTemperature() const; - * (+) inline int getMatterQuantity() const; - * (+) inline int getCurrentStrength() const; - * (+) inline int getLightIntensity() const; - * } - * - * Used code of MEDMEM/tests/testUUnit.cxx - */ - -void MEDMEMTest::testUnit() -{ - string myName = "NameForTesting"; - string myDescription = "all values are setted 10"; - int myMasse = 10; - int myLength = 10; - int myTime = 10; - int myTemperature = 10; - int myMatterQuantity = 10; - int myCurrentStrength = 10; - int myLightIntensity = 10; - - //Default constructor - UNIT myUNIT; - - //Normal constructor - UNIT *myUNIT1 = new UNIT(myName,myDescription); - CPPUNIT_ASSERT(myUNIT1); - delete myUNIT1; - - //--------------------------------------------------------------------// - // Tests des methodes // - // // - // - setName // - // - setDescription // - // - setMasse // - // - setLength // - // - setTime // - // - setTemperature // - // - setMatterQuantity // - // - setCurrentStrength // - // - setLightIntensity // - //--------------------------------------------------------------------// - - try - { - myUNIT.setName(myName); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myUNIT.setDescription(myDescription); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("MEDMEM_UNIT::setDescription(): Unknown exception"); - } - - try - { - myUNIT.setMasse(myMasse); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myUNIT.setLength(myLength); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myUNIT.setTime(myTime); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myUNIT.setTemperature(myTemperature); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myUNIT.setMatterQuantity(myMatterQuantity); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myUNIT.setCurrentStrength(myCurrentStrength); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - myUNIT.setLightIntensity(myLightIntensity); - } - catch(const std::exception &e) - { - CPPUNIT_FAIL(e.what()); - } - catch(...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //--------------------------------------------------------------------// - // Tests des methodes // - // // - // - getName // - // - getDescription // - // - getMasse // - // - getLength // - // - getTime // - // - getTemperature // - // - getMatterQuantity // - // - getCurrentStrength // - // - getLightIntensity // - //--------------------------------------------------------------------// - - try - { - CPPUNIT_ASSERT( myUNIT.getName() == myName ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getDescription() == myDescription ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getMasse() == myMasse ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getLength() == myLength ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getTime() == myTime ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getTemperature() == myTemperature ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getMatterQuantity() == myMatterQuantity ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getCurrentStrength() == myCurrentStrength ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - CPPUNIT_ASSERT( myUNIT.getLightIntensity() == myLightIntensity ); - } - catch( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch ( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //--------------------------------------------------------------------// - // Tests des method // - // - operator= // - //--------------------------------------------------------------------// - - UNIT myUNITCpy; - myUNITCpy = myUNIT; - CPPUNIT_ASSERT_EQUAL( myUNITCpy.getTemperature(), myUNITCpy.getTemperature()); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Utils.cxx b/src/MEDMEMCppTest/MEDMEMTest_Utils.cxx deleted file mode 100644 index 4f88162d1..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Utils.cxx +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest_Utils.hxx" -#include -#include -#include - -#ifdef WIN32 -#include -#else -#include -#endif - -//================================================================================ -/*! - * \brief Get path to the resources file. - * - * When running 'make test' source file is taken from MED_SRC/resources folder. - * Otherwise, file is searched in ${MED_ROOT_DIR}/share/salome/resources/med folder. - * - * \param filename name of the resource file (should not include a path) - * \return full path to the resource file - */ -//================================================================================ - -std::string getResourceFile( const std::string& filename ) -{ - std::string resourceFile = ""; - - if ( getenv("top_srcdir") ) { - // we are in 'make check' step - resourceFile = getenv("top_srcdir"); - resourceFile += "/resources/"; - } - else if ( getenv("MED_ROOT_DIR") ) { - // use MED_ROOT_DIR env.var - resourceFile = getenv("MED_ROOT_DIR"); - resourceFile += "/share/salome/resources/med/"; - } - resourceFile += filename; - return fixSlashes( resourceFile ); -} - -//================================================================================ -/*! - * \brief Returns writable temporary directory - * \return full path to the temporary directory - */ -//================================================================================ - -std::string getTmpDirectory() -{ - std::string path; - - std::list dirs; - if ( getenv("TEMP") ) dirs.push_back( getenv("TEMP" )); - if ( getenv("TMP") ) dirs.push_back( getenv("TMP" )); - if ( getenv("TMPDIR") ) dirs.push_back( getenv("TMPDIR" )); - dirs.push_back( "/tmp" ); - - std::string tmpd = ""; - for ( std::list::iterator dir = dirs.begin(); dir != dirs.end() && tmpd == "" ; ++dir ) { -#ifdef WIN32 - if ( GetFileAttributes(dir->data()) & FILE_ATTRIBUTE_DIRECTORY ) -#else - if ( access( dir->data(), W_OK ) == 0 ) -#endif - tmpd = dir->data(); - } - - if ( tmpd == "" ) - throw std::runtime_error("Can't find writable temporary directory. Set TMP environment variable"); - - return tmpd; -} - -//================================================================================ -/*! - * \brief Creates a copy of source file (if source file is specified) - * in the temporary directory and returns a path to the tmp file - * - * \param tmpfile name of the temporary file (without path) - * \param srcfile source file - * \return path to the temporary file - */ -//================================================================================ - -std::string makeTmpFile( const std::string& tmpfile, const std::string& srcfile ) -{ - std::string tmpf = fixSlashes( getTmpDirectory() + "/" + tmpfile ); - if ( srcfile != "" ) { -#ifdef WIN32 - std::string cmd = "copy " + fixSlashes( srcfile ) + " " + tmpf; -#else - std::string cmd = "cp " + srcfile + " " + tmpf + " ; chmod +w " + tmpf; -#endif - system( cmd.c_str() ); - } - return tmpf; -} - -//================================================================================ -/*! - * \brief On WINDOWS, replaces all forward slashes by back slashes - * to avoid mixed slashes in one path - */ -//================================================================================ - -std::string fixSlashes( const std::string& path) -{ -#ifdef WIN32 - std::string fixedpath = path; - for ( int i=0; i < path.size(); ++i ) - if (path[i] == '/') - fixedpath[i] = '\\'; - return fixedpath; -#else - return path; -#endif -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_Utils.hxx b/src/MEDMEMCppTest/MEDMEMTest_Utils.hxx deleted file mode 100644 index 9add9a18b..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_Utils.hxx +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _MEDMEMTEST_UTILS_HXX_ -#define _MEDMEMTEST_UTILS_HXX_ - -#include "MEDMEMCppTestExport.hxx" - -#include - -MEDMEMCPPTEST_EXPORT std::string getResourceFile( const std::string& ); -MEDMEMCPPTEST_EXPORT std::string getTmpDirectory(); -MEDMEMCPPTEST_EXPORT std::string makeTmpFile( const std::string&, const std::string& = "" ); -MEDMEMCPPTEST_EXPORT std::string fixSlashes( const std::string& path); - -#endif diff --git a/src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver.cxx deleted file mode 100644 index 96cae149a..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver.cxx +++ /dev/null @@ -1,395 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (14), defined in MEDMEM_VtkFieldDriver.hxx: - * template class VTK_FIELD_DRIVER : public GENDRIVER { - * //MUST BE PRIVATE, because it is impossible to set _ptrField after this constructor. - * //AND cannot compile, so maybe it is specially implemented to prevent usage of it. - * (!) template VTK_FIELD_DRIVER(); - * (+) template VTK_FIELD_DRIVER - * (const string & fileName, FIELD * ptrField) - * (+) VTK_FIELD_DRIVER(const VTK_FIELD_DRIVER & fieldDriver) - * (+) ~VTK_FIELD_DRIVER() - * (+) void openConst() const throw (MEDEXCEPTION) - * (+) void openConstAppend() const throw (MEDEXCEPTION) - * (+) void open() throw (MEDEXCEPTION) - * (+) void openAppend() throw (MEDEXCEPTION) - * (+) void closeConst() const throw (MEDEXCEPTION) - * (+) void close() - * (+) void setFieldName(const string & fieldName); - * (+) string getFieldName() const; - * (+) void read (void) throw (MEDEXCEPTION); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void writeAppend(void) const throw (MEDEXCEPTION); - * } - */ -void MEDMEMTest::testVtkFieldDriver() -{ - FIELD *aField = new FIELD(); - FIELD *aField_1 = new FIELD(); - - string filename_rd = getResourceFile("pointe.med"); - string emptyfilename = ""; - string fileNotExistsName = "/path_not_exists/file_not_exists.vtk"; - string filename_wr = makeTmpFile( "myField_pointe.vtk" ); - - string fieldname_rd_int = "fieldnodeint"; - string fieldname_wr_int = "myintfield"; - string fieldname_rd_double = "fieldnodedouble"; - string fieldname_wr_double = "mydoublefield"; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - - ///////////////////////////////////// - // TEST1: Open not existing file // - ///////////////////////////////////// - //Creation Invalid VtkFieldDriver (file not exist) - VTK_FIELD_DRIVER *aInvalidVtkFieldDriver_1 = new VTK_FIELD_DRIVER(fileNotExistsName, aField); - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_1->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_1->openConst(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_1->openConstAppend(), MEDEXCEPTION); - - ///////////////////////////////////////////// - // TEST2: Open file with empty file name // - ///////////////////////////////////////////// - //Creation Invalid VtkFieldDriver (empty file name) - VTK_FIELD_DRIVER *aInvalidVtkFieldDriver_2 = new VTK_FIELD_DRIVER(emptyfilename, aField); - - //Trying file with empty name - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_2->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_2->openConst(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_2->openConstAppend(), MEDEXCEPTION); - - //////////////////////// - // TEST2: Main test // - //////////////////////// - //Read Fields from file - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver22_int = new MED_FIELD_RDONLY_DRIVER(filename_rd, aField); - aMedRdFieldDriver22_int->open(); - aMedRdFieldDriver22_int->setFieldName(fieldname_rd_int); - aMedRdFieldDriver22_int->read(); - aMedRdFieldDriver22_int->close(); - MESH *mesh=new MESH(MED_DRIVER,filename_rd,"maa1"); - aField->getSupport()->setMesh(mesh); - - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver22_double = new MED_FIELD_RDONLY_DRIVER(filename_rd, aField_1); - aMedRdFieldDriver22_double->open(); - aMedRdFieldDriver22_double->setFieldName(fieldname_rd_double); - aMedRdFieldDriver22_double->read(); - aMedRdFieldDriver22_double->close(); - aField_1->getSupport()->setMesh(mesh); - mesh->removeReference(); - //Check fields - CPPUNIT_ASSERT(aField); - - //Creation correct VtkFieldDriver - VTK_FIELD_DRIVER *aVtkFieldDriver_int = new VTK_FIELD_DRIVER(filename_wr, aField); - - //Check driver - CPPUNIT_ASSERT(aVtkFieldDriver_int); - - //Test setFieldName() and getFieldName() methods - try - { - aVtkFieldDriver_int->setFieldName(fieldname_wr_int); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT_EQUAL(fieldname_wr_int, aVtkFieldDriver_int->getFieldName()); - - //Test open() method - try - { - aVtkFieldDriver_int->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test write() method - try - { - aVtkFieldDriver_int->write(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test read() method for Vtk Field Driver - CPPUNIT_ASSERT_THROW(aVtkFieldDriver_int->read(),MEDEXCEPTION); - - //Test close() method - try - { - aVtkFieldDriver_int->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test openAppend() method - try - { - aVtkFieldDriver_int->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - - ///////////////////////////////////////////////////////// - // TEST? Test openAppend() and writeAppend() methods // - ///////////////////////////////////////////////////////// - - //Creation correct VtkFieldDriver - VTK_FIELD_DRIVER *aVtkFieldDriver_double = new VTK_FIELD_DRIVER(filename_wr, aField_1); - - //Check driver - CPPUNIT_ASSERT(aVtkFieldDriver_double); - - //Test openAppend() method - try - { - aVtkFieldDriver_double->openAppend(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - aVtkFieldDriver_double->setFieldName(fieldname_wr_double); - - //Test writeAppend() method - try - { - aVtkFieldDriver_double->writeAppend(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - aVtkFieldDriver_double->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - ///////////////////////// - // TEST BINARY FORMAT // - ///////////////////////// - - DRIVERFACTORY::setVtkBinaryFormatForWriting( true ); - - //BINARY: Test open() method - try - { - aVtkFieldDriver_int->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //BINARY: Test write() method - try - { - aVtkFieldDriver_int->write(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //BINARY: Test read() method for Vtk Field Driver - CPPUNIT_ASSERT_THROW(aVtkFieldDriver_int->read(),MEDEXCEPTION); - - //BINARY: Test close() method - try - { - aVtkFieldDriver_int->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //BINARY: Test openAppend() method - try - { - aVtkFieldDriver_int->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - - ///////////////////////////////////////////////////////// - // BINARY: Test openAppend() and writeAppend() methods // - ///////////////////////////////////////////////////////// - - try - { - aVtkFieldDriver_double->openAppend(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - aVtkFieldDriver_double->setFieldName(fieldname_wr_double); - - //BINARY: Test writeAppend() method - try - { - aVtkFieldDriver_double->writeAppend(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - try - { - aVtkFieldDriver_double->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - DRIVERFACTORY::setVtkBinaryFormatForWriting( false ); - - VTK_FIELD_DRIVER aVtkFieldDriver_intCpy_1; - - //Test copy constructor - VTK_FIELD_DRIVER aVtkFieldDriver_intCpy_2 (*aVtkFieldDriver_int); - - CPPUNIT_ASSERT_EQUAL(aVtkFieldDriver_intCpy_2, *aVtkFieldDriver_int); - //Test (bool operator ==) defined in GENDRIVER class in MEDMEM_GenDriver.hxx - CPPUNIT_ASSERT(aVtkFieldDriver_intCpy_2.GENDRIVER::operator== (*aVtkFieldDriver_int)); - - //Test (friend ostream & operator <<) defined in GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream ostr1, ostr2; - ostr1<<*aVtkFieldDriver_int; - ostr2<removeReference(); - aField_1->removeReference(); - delete aInvalidVtkFieldDriver_1; - delete aInvalidVtkFieldDriver_2; - delete aMedRdFieldDriver22_int; - delete aMedRdFieldDriver22_double; - delete aVtkFieldDriver_int; - delete aVtkFieldDriver_double; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver_fault.cxx deleted file mode 100644 index a899aa54c..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_VtkFieldDriver_fault.cxx +++ /dev/null @@ -1,302 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (14), defined in MEDMEM_VtkFieldDriver.hxx: - * template class VTK_FIELD_DRIVER : public GENDRIVER { - * //MUST BE PRIVATE, because it is impossible to set _ptrField after this constructor. - * //AND cannot compile, so maybe it is specially implemented to prevent usage of it. - * (!) template VTK_FIELD_DRIVER(); - * (+) template VTK_FIELD_DRIVER - * (const string & fileName, FIELD * ptrField) - * (+) VTK_FIELD_DRIVER(const VTK_FIELD_DRIVER & fieldDriver) - * (+) ~VTK_FIELD_DRIVER() - * (+) void openConst() const throw (MEDEXCEPTION) - * (+) void openConstAppend() const throw (MEDEXCEPTION) - * (+) void open() throw (MEDEXCEPTION) - * (+) void openAppend() throw (MEDEXCEPTION) - * (+) void closeConst() const throw (MEDEXCEPTION) - * (+) void close() - * (+) void setFieldName(const string & fieldName); - * (+) string getFieldName() const; - * (+) void read (void) throw (MEDEXCEPTION); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void writeAppend(void) const throw (MEDEXCEPTION); - * } - */ -static void MEDMEMTest_testVtkFieldDriver() -{ - FIELD *aField = new FIELD(); - FIELD *aField_1 = new FIELD(); - - string filename_rd = getResourceFile("pointe.med"); - string emptyfilename = ""; - string fileNotExistsName = "/path_not_exists/file_not_exists.vtk"; - string filename_wr = makeTmpFile( "myField_pointe.vtk" ); - - string fieldname_rd_int = "fieldnodeint"; - string fieldname_wr_int = "myintfield"; - string fieldname_rd_double = "fieldnodedouble"; - string fieldname_wr_double = "mydoublefield"; - - // To remove tmp files from disk - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - - ///////////////////////////////////// - // TEST1: Open not existing file // - ///////////////////////////////////// - //Creation Invalid VtkFieldDriver (file not exist) - VTK_FIELD_DRIVER *aInvalidVtkFieldDriver_1 = new VTK_FIELD_DRIVER(fileNotExistsName, aField); - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_1->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_1->openConst(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_1->openConstAppend(), MEDEXCEPTION); - - ///////////////////////////////////////////// - // TEST2: Open file with empty file name // - ///////////////////////////////////////////// - //Creation Invalid VtkFieldDriver (empty file name) - VTK_FIELD_DRIVER *aInvalidVtkFieldDriver_2 = new VTK_FIELD_DRIVER(emptyfilename, aField); - - //Trying file with empty name - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_2->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_2->openConst(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkFieldDriver_2->openConstAppend(), MEDEXCEPTION); - - //////////////////////// - // TEST2: Main test // - //////////////////////// - //Read Fields from file - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver22_int = new MED_FIELD_RDONLY_DRIVER(filename_rd, aField); - aMedRdFieldDriver22_int->open(); - aMedRdFieldDriver22_int->setFieldName(fieldname_rd_int); - aMedRdFieldDriver22_int->read(); - aMedRdFieldDriver22_int->close(); - MESH *mesh=new MESH(MED_DRIVER,filename_rd,"maa1"); - aField->getSupport()->setMesh(mesh); - - MED_FIELD_RDONLY_DRIVER *aMedRdFieldDriver22_double = new MED_FIELD_RDONLY_DRIVER(filename_rd, aField_1); - aMedRdFieldDriver22_double->open(); - aMedRdFieldDriver22_double->setFieldName(fieldname_rd_double); - aMedRdFieldDriver22_double->read(); - aMedRdFieldDriver22_double->close(); - aField_1->getSupport()->setMesh(mesh); - mesh->removeReference(); - //Check fields - CPPUNIT_ASSERT(aField); - - //Creation correct VtkFieldDriver - VTK_FIELD_DRIVER *aVtkFieldDriver_int = new VTK_FIELD_DRIVER(filename_wr, aField); - - //Check driver - CPPUNIT_ASSERT(aVtkFieldDriver_int); - - //Test setFieldName() and getFieldName() methods - try - { - aVtkFieldDriver_int->setFieldName(fieldname_wr_int); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - CPPUNIT_ASSERT_EQUAL(fieldname_wr_int, aVtkFieldDriver_int->getFieldName()); - - //Test open() method - try - { - aVtkFieldDriver_int->open(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - -//#ifdef ENABLE_FAULTS - //Test write() method - try - { - aVtkFieldDriver_int->write(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - // => Segmentation fault -//#endif - - //Test read() method for Vtk Field Driver - CPPUNIT_ASSERT_THROW(aVtkFieldDriver_int->read(),MEDEXCEPTION); - - //Test close() method - try - { - aVtkFieldDriver_int->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //Test openAppend() method - try - { - aVtkFieldDriver_int->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - - ///////////////////////////////////////////////////////// - // TEST? Test openAppend() and writeAppend() methods // - ///////////////////////////////////////////////////////// - - //Creation correct VtkFieldDriver - VTK_FIELD_DRIVER *aVtkFieldDriver_double = new VTK_FIELD_DRIVER(filename_wr, aField_1); - - //Check driver - CPPUNIT_ASSERT(aVtkFieldDriver_double); - - //Test openAppend() method - try - { - aVtkFieldDriver_double->openAppend(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - aVtkFieldDriver_double->setFieldName(fieldname_wr_double); - -//#ifdef ENABLE_FAULTS - //Test writeAppend() method - try - { - aVtkFieldDriver_double->writeAppend(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - // => Segmentation fault -//#endif - - try - { - aVtkFieldDriver_double->close(); - } - catch(MEDEXCEPTION &e) - { - CPPUNIT_FAIL(e.what()); - } - catch( ... ) - { - CPPUNIT_FAIL("Unknown exception"); - } - - //#ifdef ENABLE_FORCED_FAILURES - //VTK_FIELD_DRIVER aVtkFieldDriver_intCpy_1; - //VTK_FIELD_DRIVER.template VTK_FIELD_DRIVER aVtkFieldDriver_intCpy_1; - //CPPUNIT_FAIL("Compilation error: no matching function for call to 'MEDMEM::VTK_FIELD_DRIVER::VTK_FIELD_DRIVER()"); - //#endif - -//#ifdef ENABLE_FAULTS - //Test copy constructor - VTK_FIELD_DRIVER aVtkFieldDriver_intCpy_2 (*aVtkFieldDriver_int); - // => Segmentation fault after call Copy Constructor - - CPPUNIT_ASSERT_EQUAL(aVtkFieldDriver_intCpy_2, *aVtkFieldDriver_int); - //Test (bool operator ==) defined in GENDRIVER class in MEDMEM_GenDriver.hxx - CPPUNIT_ASSERT(aVtkFieldDriver_intCpy_2.GENDRIVER::operator== (*aVtkFieldDriver_int)); - - //Test (friend ostream & operator <<) defined in GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream ostr1, ostr2; - ostr1<<*aVtkFieldDriver_int; - ostr2<removeReference(); - aField_1->removeReference(); -//#ifdef ENABLE_FORCED_FAILURES - // (BUG) Exception in the destructor after trying close not existing file. - delete aInvalidVtkFieldDriver_1; -//#endif - delete aInvalidVtkFieldDriver_2; - delete aMedRdFieldDriver22_int; - delete aMedRdFieldDriver22_double; - delete aVtkFieldDriver_int; - delete aVtkFieldDriver_double; -} - -int main (int argc, char** argv) -{ - MEDMEMTest_testVtkFieldDriver(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_VtkMedDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_VtkMedDriver.cxx deleted file mode 100644 index 8219aef53..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_VtkMedDriver.cxx +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (5), defined in MEDMEM_VtkMedDriver.hxx: - * class VTK_MED_DRIVER : public GENDRIVER { - * (+) VTK_MED_DRIVER(const string & fileName, MED * const ptrMed); - * (+) VTK_MED_DRIVER(const VTK_MED_DRIVER & driver); - * (+) ~VTK_MED_DRIVER(); - * (+) void write (void) const; - * (-) virtual void read (void) {}; - * (+) GENDRIVER * copy (void) const; - * } - */ -void MEDMEMTest::testVtkMedDriver() -{ - MEDFILEBROWSER *aMed = new MEDFILEBROWSER(); - string filename_rd = getResourceFile("pointe.med"); - string emptyfilename = ""; - string fileNotExistsName = "/path_not_exists/file_not_exists.vtk"; - string filename_wr = makeTmpFile( "myMED_pointe.vtk" ); - - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename_wr); - - //Read MED structure from file (not generic code) - vector fields; - aMed->readFileStruct( filename_rd ); - MESH mesh(MED_DRIVER, aMed->getFileName(), aMed->getMeshNames()[0] ); - vector fieldsNames = aMed->getFieldNames(); - for ( unsigned i = 0; i < fieldsNames.size(); ++i ) - { - VEC_DT_IT_ vecDtIt = aMed->getFieldIteration( fieldsNames[i] ); - for ( unsigned j = 0; j < vecDtIt.size(); ++j ) - if ( aMed->getFieldType( fieldsNames[i] ) == MED_REEL64 ) - fields.push_back( new FIELD(MED_DRIVER, filename_rd, fieldsNames[i], - vecDtIt[j].dt, vecDtIt[j].it, &mesh)); - else - fields.push_back( new FIELD(MED_DRIVER, filename_rd, fieldsNames[i], - vecDtIt[j].dt, vecDtIt[j].it, &mesh)); - } - - //Check Med - CPPUNIT_ASSERT(fields.size()); - - //Creation incorrect Vtk Med Driver (file is not exists) - VTK_MED_DRIVER *aInvalidVtkMedDriver = new VTK_MED_DRIVER(fileNotExistsName,fields); - - //Trying write data in the not existing file - CPPUNIT_ASSERT_THROW(aInvalidVtkMedDriver->write(),MEDEXCEPTION); - - //Creation correct Vtk Med Driver - VTK_MED_DRIVER *aVtkMedDriver = new VTK_MED_DRIVER(filename_wr ,fields); - - //Check driver - CPPUNIT_ASSERT(aVtkMedDriver); - - //Test write() method - - CPPUNIT_ASSERT_NO_THROW(aVtkMedDriver->write()); - - - //Test BINARY write() method - - DRIVERFACTORY::setVtkBinaryFormatForWriting( true ); - CPPUNIT_ASSERT_NO_THROW( aVtkMedDriver->write() ); - DRIVERFACTORY::setVtkBinaryFormatForWriting( false ); - - - //Test copy constructor - VTK_MED_DRIVER *aVtkMedDriverCpy = new VTK_MED_DRIVER(*aVtkMedDriver); - CPPUNIT_ASSERT_EQUAL(*aVtkMedDriverCpy, *aVtkMedDriver); - - //Test (operator ==) defined in GENDRIVER class in MEDMEM_GenDriver.hxx - CPPUNIT_ASSERT(*aVtkMedDriverCpy == *aVtkMedDriver); - - //Test copy() function - VTK_MED_DRIVER *aVtkMedDriverCpy_1 = (VTK_MED_DRIVER*)aVtkMedDriver->copy(); - CPPUNIT_ASSERT_EQUAL(*aVtkMedDriverCpy_1, *aVtkMedDriver); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - ostringstream ostr1, ostr2; - ostr1<<*aVtkMedDriverCpy; - ostr2<<*aVtkMedDriverCpy_1; - CPPUNIT_ASSERT(ostr1.str() != ""); - CPPUNIT_ASSERT(ostr1.str() == ostr2.str()); - - - //Delete objects - delete aInvalidVtkMedDriver; - delete aVtkMedDriver; - delete aVtkMedDriverCpy; - delete aVtkMedDriverCpy_1; - delete aMed; - - for ( unsigned i = 0; i < fields.size(); ++i ) - fields[i]->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver.cxx b/src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver.cxx deleted file mode 100644 index 0c3fc2e54..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver.cxx +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include - -#include -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; - -/*! - * Check methods (11), defined in MEDMEM_VtkMeshDriver.hxx: - * class VTK_MESH_DRIVER : public GENDRIVER { - * (+) VTK_MESH_DRIVER(); - * (+) VTK_MESH_DRIVER(const string & fileName, MESH * ptrMesh); - * (+) VTK_MESH_DRIVER(const VTK_MESH_DRIVER & driver); - * (+) ~VTK_MESH_DRIVER(); - * (+) void open(); - * (+) void close(); - * (+) void openConst() const throw (MEDEXCEPTION); - * (+) void closeConst() const throw (MEDEXCEPTION); - * (+) void write(void) const throw (MEDEXCEPTION); - * (+) void read (void) throw (MEDEXCEPTION); - * (+) void setMeshName(const string & meshName); - * (+) string getMeshName() const; - * } - */ -void MEDMEMTest::testVtkMeshDriver() -{ - MESH * aMesh = new MESH; - - string filename_rd = getResourceFile("pointe.med"); - string emptyfilename = ""; - string meshname_rd = "maa1"; - string meshname = "MyMesh"; - string fileNotExistsName = "/path_not_exists/file_not_exists.vtk"; - string filename = makeTmpFile("my_pointe.vtk"); - - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename); - - { - //Creation a invalid Vtk driver - VTK_MESH_DRIVER *aInvalidVtkDriver = new VTK_MESH_DRIVER(fileNotExistsName, aMesh); - - //Trying open not existing file - CPPUNIT_ASSERT_THROW(aInvalidVtkDriver->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aInvalidVtkDriver->openConst(), MEDEXCEPTION); - - CPPUNIT_ASSERT_NO_THROW(delete aInvalidVtkDriver); - } - - { - //Create Vtk driver with empty file name - VTK_MESH_DRIVER *aEmptyVtkDriver = new VTK_MESH_DRIVER(emptyfilename, aMesh); - - //Test open() and openConst() methods with empty file name - CPPUNIT_ASSERT_THROW(aEmptyVtkDriver->open(), MEDEXCEPTION); - CPPUNIT_ASSERT_THROW(aEmptyVtkDriver->openConst(), MEDEXCEPTION); - - delete aEmptyVtkDriver; - } - - //Creation corect driver - VTK_MESH_DRIVER *aVtkDriver = new VTK_MESH_DRIVER(filename, aMesh); - CPPUNIT_ASSERT(aVtkDriver); - - //Create a Mesh - MED_MESH_RDONLY_DRIVER *aMedMeshRdDriver22 = new MED_MESH_RDONLY_DRIVER(filename_rd, aMesh); - aMedMeshRdDriver22->open(); - aMedMeshRdDriver22->setMeshName(meshname_rd); - - //Test openConst() and closeConst() methods - CPPUNIT_ASSERT_NO_THROW(aVtkDriver->openConst()); - CPPUNIT_ASSERT_NO_THROW(aVtkDriver->closeConst()); - - //Test open() method - CPPUNIT_ASSERT_NO_THROW(aVtkDriver->open()); - - //Trying open file secondary - // (NOT!!! BUG) No exception on attempt to open a file for the second time - //CPPUNIT_ASSERT_NO_THROW(aVtkDriver->open()); - - //Test read method - CPPUNIT_ASSERT_THROW(aVtkDriver->read(), MEDEXCEPTION); - - //Trying write empty mesh - CPPUNIT_ASSERT_THROW(aVtkDriver->write(), MEDEXCEPTION); - - //Read mesh from Med file - aMedMeshRdDriver22->read(); - - //Check mesh - CPPUNIT_ASSERT(aMesh); - - //Test SetMeshName and getMeshName methods - CPPUNIT_ASSERT_NO_THROW(aVtkDriver->setMeshName(meshname)); - CPPUNIT_ASSERT_EQUAL(meshname, aVtkDriver->getMeshName()); - - //Test write method - CPPUNIT_ASSERT_NO_THROW(aVtkDriver->write()); - - //Test close method - CPPUNIT_ASSERT_NO_THROW(aVtkDriver->close()); - - //Test Default constructor - VTK_MESH_DRIVER aVtkDriverCpy_1; - - //Test copy constructor - VTK_MESH_DRIVER aVtkDriverCpy_2 (*aVtkDriver); - - //Test (bool operator ==) defined in GENDRIVER class - //CPPUNIT_ASSERT(aVtkDriverCpy_2.GENDRIVER::operator==(aVtkDriver)); - - //Test (friend ostream & operator <<) defined GENDRIVER class in MEDMEM_GenDriver.hxx - //ostringstream ostr1, ostr2; - //ostr1 << aVtkDriverCpy_2; - //ostr2 << aVtkDriver; - //CPPUNIT_ASSERT(ostr1.str() != ""); - //CPPUNIT_ASSERT_EQUAL(ostr1.str(), ostr2.str()); - - //Delete objects - delete aVtkDriver; - delete aMedMeshRdDriver22; - aMesh->removeReference(); -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver_fault.cxx b/src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver_fault.cxx deleted file mode 100644 index cf7439bbc..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_VtkMeshDriver_fault.cxx +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" - -#include -#include - -using namespace std; -using namespace MEDMEM; - -int main (int argc, char** argv) -{ - string meshname = "MyMesh"; - string filename = makeTmpFile( "my_pointe.vtk" ); - - MEDMEMTest_TmpFilesRemover aRemover; - aRemover.Register(filename); - - //Create an empty Mesh - MESH * aMesh = new MESH(); - - //Creation corect driver - VTK_MESH_DRIVER *aVtkDriver = new VTK_MESH_DRIVER(filename, aMesh); - aVtkDriver->setMeshName(meshname); - aVtkDriver->open(); - - // ? (BUG) ? In VTK_MESH_DRIVER::write() => Segmentation fault on attempt to write an empty mesh - try - { - //Trying write an empty mesh - aVtkDriver->write(); - } - catch (MEDEXCEPTION & ex) - { - // good behaviour - } - catch (...) - { - } - - aVtkDriver->close(); - - // (BUG) In copy constructor of VTK_MESH_DRIVER: Segmentation fault or Infinite loop - VTK_MESH_DRIVER aVtkDriverCpy_2 (*aVtkDriver); - - delete aVtkDriver; - delete aMesh; -} diff --git a/src/MEDMEMCppTest/MEDMEMTest_nArray.cxx b/src/MEDMEMCppTest/MEDMEMTest_nArray.cxx deleted file mode 100644 index c48dd0acc..000000000 --- a/src/MEDMEMCppTest/MEDMEMTest_nArray.cxx +++ /dev/null @@ -1,530 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest.hxx" -#include -#include - -#include "MEDMEM_nArray.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_ArrayConvert.hxx" - -#include -#include - -// use this define to enable lines, execution of which leads to Segmentation Fault -//#define ENABLE_FAULTS - -// use this define to enable CPPUNIT asserts and fails, showing bugs -//#define ENABLE_FORCED_FAILURES - -using namespace std; -using namespace MEDMEM; -using namespace MED_EN; - -/*! - * Check methods (21), defined in MEDMEM_nArray.hxx: - * class MEDMEM_Array_ { - * (-) virtual bool getGaussPresence() const { return false; } - * (-) virtual MED_EN::medModeSwitch getInterlacingType() const {return MED_EN::MED_UNDEFINED_INTERLACE;} - * (+) ~MEDMEM_Array_() {}; - * } - * template - * class MEDMEM_Array : public INTERLACING_POLICY, public CHECKING_POLICY, public MEDMEM_Array_ { - * (+) MEDMEM_Array(); - * (+) ~MEDMEM_Array(); - * (+) inline MEDMEM_Array(int dim, int nbelem); - * (+) inline MEDMEM_Array(ElementType * values, int dim, int nbelem, - * bool shallowCopy=false, bool ownershipOfValues=false); - * (+) inline MEDMEM_Array(int dim, int nbelem, int nbtypegeo, - * const int * const nbelgeoc, const int * const nbgaussgeo); - * (+) inline MEDMEM_Array(ElementType * values, int dim, int nbelem, int nbtypegeo, - * const int * const nbelgeoc, const int * const nbgaussgeo, - * bool shallowCopy=false, bool ownershipOfValues=false); - * (+) inline MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false); - * (+) inline MEDMEM_Array & - * operator=(const MEDMEM_Array & array); - * (+) MED_EN::medModeSwitch getInterlacingType() const; - * (+) bool getGaussPresence() const; - * (+) ElementType * getPtr(); - * (+) void setPtr(ElementType * values, bool shallowCopy=false, bool ownershipOfValues=false); - * (+) inline const ElementType * getRow(int i) const; - * (+) void setRow(int i,const ElementType * const value); - * (+) inline const ElementType * getColumn(int j) const; - * (+) void setColumn(int j, const ElementType * const value); - * (+) inline const ElementType & getIJ(int i, int j) const; - * (+) inline const ElementType & getIJK(int i, int j, int k) const; - * (+) inline void setIJ(int i, int j, const ElementType & value); - * (+) inline void setIJK(int i, int j, int k, const ElementType & value); - * (+) bool operator == (const MEDMEM_Array & array) const; - * (+) friend ostream & operator<<(ostream & os, const MEDMEM_Array & array); - * } - */ -void MEDMEMTest::testnArray() -{ - const int mdim = 2; - const int nbelem1 = 20; - const double EPS = 0.00001; - - ///////////////////////////////////////// - // TEST 1 FullInterlace et NoGauss // - //////////////////////////////////////// - const double * myArray1Ptr = 0; - const double array1Ref[] = { 11 , 12 , 21 , 22 , 31 , 32 , 41 , 42 , 51 , 52 , - 61 , 62 , 71 , 72 , 81 , 82 , 91 , 92 , 101 , 102 , - 111 , 112 , 121 , 122 , 131 , 132 , 141 , 142 , - 151 , 152 , 161 , 162 , 171 , 172 , 181 , 182 , - 191 , 192 , 201 , 202 }; - - const double array2Ref[] = { 11 , 21 , 31 , 41 , 51 , 61 , 71 , 81 , 91 , 101 - , 111 , 121 , 131 , 141 , 151 , 161 , 171 , 181 - , 191 , 201 , - 12 , 22 , 32 , 42 , 52 , 62 , 72 , 82 , 92 , 102 - , 112 , 122 , 132 , 142 , 152 , 162 , 172 , 182 - , 192 , 202 }; - - //test MEDMEM_Array(int dim, int nbelem) - MEDMEM_Array myArray1(mdim,nbelem1); - //test getGaussPresence - CPPUNIT_ASSERT( !myArray1.getGaussPresence()); - - //test setIJ. Fill array - for (int i =1; i <= nbelem1; i++) - for (int j =1; j <= mdim; j++) - { - CPPUNIT_ASSERT_NO_THROW(myArray1.setIJ(i,j,i*10+j)); - } - - //test getPtr - myArray1Ptr = myArray1.getPtr(); - for (int i = 0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray1Ptr[i] == array1Ref[i] ); - - { - //test MEDMEM_Array(ElementType * values, int dim, int nbelem, bool shallowCopy=false, bool ownershipOfValues=false) - MEDMEM_Array myArray1val ((double*)array1Ref, mdim, nbelem1); - myArray1Ptr = myArray1val.getPtr(); - for (int i = 0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray1Ptr[i] == array1Ref[i] ); - - //test MEDMEM_Array(ElementType * values, int dim, int nbelem, bool shallowCopy=true, bool ownershipOfValues=false); - MEDMEM_Array myArray1valsh ((double*)array1Ref, mdim, nbelem1, true); - myArray1Ptr = myArray1valsh.getPtr(); - for (int i = 0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray1Ptr[i] == array1Ref[i] ); - - //test setPtr - double myPtr[10] = {-1, -2, -3, -4, -5, -6, -7, -8, -9, 0}; - CPPUNIT_ASSERT_NO_THROW(myArray1valsh.setPtr(myPtr)); - //size the array stays the same, only first 10 element are being overwritten - myArray1Ptr = myArray1valsh.getPtr(); - for (int i = 0; i < 10; i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(myArray1Ptr[i], myPtr[i], EPS); - } - - //test MEDMEM_Array(ElementType * values, int dim, int nbelem, bool shallowCopy=true, bool ownershipOfValues=true); - { - double * array1Ref_do_not_delete = new double[40]; - for (int i = 0; i < 40; i = i + 2) { - array1Ref_do_not_delete[i ] = 10.0 * (i+1) + 1; - array1Ref_do_not_delete[i+1] = 10.0 * (i+1) + 2; - } - MEDMEM_Array myArray1valow (array1Ref_do_not_delete, mdim, nbelem1, true, true); - } - - //test MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false) - MEDMEM_Array myArray1bis (myArray1, false); - CPPUNIT_ASSERT(myArray1 == myArray1bis); - - myArray1Ptr = myArray1bis.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray1Ptr[i] == array1Ref[i] ); - - //test MEDMEM_Array() - MEDMEM_Array myArray1ter; - try - { - myArray1ter = myArray1; - myArray1Ptr = myArray1ter.getPtr(); - } - catch ( const std::exception &e ) - { - CPPUNIT_FAIL(e.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - - for (int i =0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray1Ptr[i] == array1Ref[i] ); - - MEDMEM_Array myArray1qua(mdim,nbelem1); - myArray1Ptr = myArray1qua.getPtr(); - - for (int i =1; i <= nbelem1; i++) - { - try { - //test setRow(int i,const ElementType * const value) - myArray1qua.setRow(i,&array1Ref[(i-1)*mdim]); - } - catch (MEDMEM::MEDEXCEPTION &m) { - CPPUNIT_FAIL(m.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - - for (int i =0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray1Ptr[i] == array1Ref[i] ); - - //test getColumn(int j) - CPPUNIT_ASSERT_THROW(myArray1qua.getColumn(1), MEDEXCEPTION); - - MEDMEM_Array * myArray1cin = ArrayConvert(myArray1); - myArray1Ptr = myArray1cin->getPtr(); - int elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i <= nbelem1 ; i++ ) { - CPPUNIT_ASSERT( myArray1cin->getIJ(i,j) == array2Ref[elemno] ); - CPPUNIT_ASSERT( myArray1Ptr[elemno] == array2Ref[elemno] ); - elemno++; - } - delete myArray1cin; - ///////////////////////////////////// - // TEST 2 NoInterlace et NoGauss // - ///////////////////////////////////// - { - const double * myArray2Ptr = 0; - //MEDMEM_Array(int dim, int nbelem) - MEDMEM_Array myArray2(mdim,nbelem1); - - for (int i =1; i <= nbelem1; i++) { - for (int j =1; j <= mdim; j++) { - //test setIJ(int i, int j, const ElementType & value) - CPPUNIT_ASSERT_NO_THROW(myArray2.setIJ(i,j,i*10+j)); - } - } - - //test getPtr() - myArray2Ptr = myArray2.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray2Ptr[i] == array2Ref[i] ); - - //test MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false) - MEDMEM_Array myArray2bis(myArray2, false); - myArray2Ptr = myArray2bis.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray2Ptr[i] == array2Ref[i] ); - - //test MEDMEM_Array() - MEDMEM_Array myArray2ter; - //test operator=(const MEDMEM_Array & array) - myArray2ter = myArray2; - //test getPtr - myArray2Ptr = myArray2ter.getPtr(); - for (int i =0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray2Ptr[i] == array2Ref[i] ); - - MEDMEM_Array myArray2qua(mdim,nbelem1); - myArray2Ptr = myArray2qua.getPtr(); - - for (int j = 1; j <= mdim; j++) { - //test setColumn(int j, const ElementType * const value) - CPPUNIT_ASSERT_NO_THROW(myArray2qua.setColumn(j,&array2Ref[nbelem1*(j-1)])); - } - - for (int i =0; i < mdim*nbelem1; i++) - CPPUNIT_ASSERT( myArray2Ptr[i] == array2Ref[i] ); - - //test getRow(int i) - CPPUNIT_ASSERT_THROW(myArray2qua.getRow(1), MEDEXCEPTION); - - MEDMEM_Array * myArray2cin = ArrayConvert(myArray2); - myArray2Ptr = myArray2cin->getPtr(); - elemno = 0; - for (int i=1; i <= nbelem1 ; i++) { - for (int j=1; j <= mdim; j++) { - CPPUNIT_ASSERT( myArray2cin->getIJ(i,j) == array1Ref[elemno] ); - CPPUNIT_ASSERT( myArray2Ptr[elemno] == array1Ref[elemno] ); - elemno++; - } - } - delete myArray2cin; - } - - /////////////////////////////////////// - // TEST 3 FullInterlace et Gauss // - ////////////////////////////////////// - const int nbelem2 = 5; - const int nbtypegeo = 2; - const int nbelgeoc[nbtypegeo+1] = {1,3,6}; - const int nbgaussgeo[nbtypegeo+1] = {-1,2,3}; - - const double * myArray3Ptr = 0; - const double array3Ref[] = {1.11 , 1.12 , 1.21 , 1.22 , - 2.11 , 2.12 , 2.21 , 2.22 , - 13.11 , 13.12 , 13.21 , 13.22 , 13.31 , 13.32 , - 14.11 , 14.12 , 14.21 , 14.22 , 14.31 , 14.32 , - 15.11 , 15.12 , 15.21 , 15.22 , 15.31 , 15.32 }; - - const double array4Ref[] = { 1.11 , 1.21 , 2.11 , 2.21, - 13.11 , 13.21 , 13.31 , 14.11 , 14.21 , 14.31 , - 15.11 , 15.21 , 15.31 , - 1.12 , 1.22 , 2.12 , 2.22 , - 13.12 , 13.22 , 13.32 , 14.12 , 14.22 , 14.32 , - 15.12 , 15.22 , 15.32 }; - - const int array5Ref[] = { 1 , 1 , 2 , 2, - 13 , 13 , 13 , 14 , 14 , 14 , - 15 , 15 , 15 , - 1 , 1 , 2 , 2 , - 13 , 13 , 13 , 14 , 14 , 14 , - 15 , 15 , 15 }; - - //test MEDMEM_Array(int dim, int nbelem, int nbtypegeo, const int * const nbelgeoc, const int * const nbgaussgeo) - MEDMEM_Array myArray3(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); - - elemno = 1; - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { - for (int k=1; k <= nbgaussgeo[ntyp]; k++) - for (int j=1; j <= mdim; j++) { - try{ - //test setIJK(int i, int j, int k, const ElementType & value) - myArray3.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j); - } - catch (MEDMEM::MEDEXCEPTION &m) { - CPPUNIT_FAIL(m.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - elemno++; - } - } - - myArray3Ptr = myArray3.getPtr(); - for (int i =0; i < myArray3.getArraySize(); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL(myArray3Ptr[i], array3Ref[i], EPS); - - MEDMEM_Array myArray3bis(myArray3, false); - myArray3Ptr = myArray3bis.getPtr(); - - elemno = 0; - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray3bis.getNbGauss(i); k++) - for (int j=1; j <= mdim; j++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray3bis.getIJK(i,j,k), array3Ref[elemno], EPS ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray3Ptr[elemno], array3Ref[elemno], EPS ); - elemno++; - } - - //test MEDMEM_Array() - MEDMEM_Array myArray3ter; - //test operator=(const MEDMEM_Array & array) - myArray3ter = myArray3; - myArray3Ptr = myArray3ter.getPtr(); - - elemno = 0; - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray3ter.getNbGauss(i); k++) - for (int j=1; j <= mdim; j++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray3ter.getIJK(i,j,k), array3Ref[elemno], EPS ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray3Ptr[elemno], array3Ref[elemno], EPS ); - elemno++; - } - - MEDMEM_Array myArray3qua(mdim,nbelem2, - nbtypegeo,nbelgeoc,nbgaussgeo); - myArray3Ptr = myArray3qua.getPtr(); - - int cumul = 0; - for (int i =1; i <= nbelem2; i++){ - try{ - myArray3qua.setRow(i,&array3Ref[cumul]); - cumul+=myArray3qua.getNbGauss(i)*mdim; - } - catch (MEDMEM::MEDEXCEPTION &m) { - CPPUNIT_FAIL(m.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - }; - - for (int i =0; i < myArray3qua.getArraySize(); i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray3Ptr[i], array3Ref[i], EPS ); - } - - MEDMEM_Array * myArray3cin = ArrayConvert(myArray3); - myArray3Ptr = myArray3cin->getPtr(); - elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray3cin->getNbGauss(i); k++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray3cin->getIJK(i,j,k), array4Ref[elemno], EPS ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(myArray3Ptr[elemno], array4Ref[elemno], EPS ); - elemno++; - } - delete myArray3cin; - //////////////////////////////////// - // TEST 4 NoInterlace et Gauss // - //////////////////////////////////// - const double * myArray4Ptr = 0; - //test MEDMEM_Array(int dim, int nbelem, int nbtypegeo, const int * const nbelgeoc, const int * const nbgaussgeo) - MEDMEM_Array myArray4(mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); - - elemno = 1; - for (int ntyp=1; ntyp <= nbtypegeo; ntyp++ ) { - for (int i=0; i < (nbelgeoc[ntyp]-nbelgeoc[ntyp-1]) ; i++ ) { - for (int k=1; k <= nbgaussgeo[ntyp]; k++) - for (int j=1; j <= mdim; j++) { - try{ - //test setIJK(int i, int j, int k, const ElementType & value) - myArray4.setIJK(elemno,j,k,elemno+(ntyp-1)*10+0.1*k+0.01*j); - } - catch (MEDMEM::MEDEXCEPTION &m) { - CPPUNIT_FAIL(m.what()); - } - catch (...) - { - CPPUNIT_FAIL("Unknown exception"); - } - } - elemno++; - } - } - - //test getPtr() - myArray4Ptr = myArray4.getPtr(); - for (int i =0; i < myArray4.getArraySize(); i++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4Ptr[i], array4Ref[i], EPS ); - } - - //test MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false) - MEDMEM_Array myArray4bis(myArray4, false); - myArray4Ptr = myArray4bis.getPtr(); - - elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray4bis.getNbGauss(i); k++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4bis.getIJK(i,j,k), array4Ref[elemno], EPS ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4Ptr[elemno], array4Ref[elemno], EPS ); - elemno++; - } - - //test MEDMEM_Array() - MEDMEM_Array myArray4ter; - //test operator=(const MEDMEM_Array & array) - myArray4ter = myArray4; - myArray4Ptr = myArray4ter.getPtr(); - - elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray4ter.getNbGauss(i); k++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4ter.getIJK(i,j,k), array4Ref[elemno], EPS ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4Ptr[elemno], array4Ref[elemno], EPS ); - elemno++; - } - - { - MEDMEM_Array myArray4qua (mdim,nbelem2,nbtypegeo,nbelgeoc,nbgaussgeo); - myArray4Ptr = myArray4qua.getPtr(); - - for (int j = 1; j <= mdim; j++) { - int k = (myArray4qua.getArraySize() / mdim) * (j - 1); - CPPUNIT_ASSERT_NO_THROW(myArray4qua.setColumn(j, &array4Ref[k])); - } - - for (int i =0; i < myArray4qua.getArraySize(); i++) - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4Ptr[i], array4Ref[i], EPS ); - } - - { - MEDMEM_Array * myArray4cin = ArrayConvert(myArray4); - myArray4Ptr = myArray4cin->getPtr(); - elemno = 0; - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray4cin->getNbGauss(i); k++) - for (int j=1; j <= mdim; j++) { - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4cin->getIJK(i,j,k), array3Ref[elemno], EPS ); - CPPUNIT_ASSERT( myArray4cin->getIJK(i,j,k) == myArray3.getIJK(i,j,k) ); - CPPUNIT_ASSERT_DOUBLES_EQUAL( myArray4Ptr[elemno], array3Ref[elemno], EPS ); - elemno++; - } - delete myArray4cin; - } - - CPPUNIT_ASSERT(myArray4bis.getInterlacingType() != MED_UNDEFINED_INTERLACE); - - CPPUNIT_ASSERT_THROW(myArray4.getIJ(0,2), MEDEXCEPTION); - - ostringstream os; - //test operator<<(ostream & os, const MEDMEM_Array & array) - os << myArray4; - CPPUNIT_ASSERT(os.str() != ""); - - const int * myArray5Ptr = 0; - //test MEDMEM_Array(ElementType * values, int dim, int nbelem, int nbtypegeo, - // const int * const nbelgeoc, const int * const nbgaussgeo, - // bool shallowCopy=false, bool ownershipOfValues=false) - MEDMEM_Array myArray5 ((int*)array5Ref, mdim, nbelem2, - nbtypegeo, nbelgeoc, nbgaussgeo); - //test getGaussPresence - CPPUNIT_ASSERT( myArray5.getGaussPresence()); - - myArray5Ptr = myArray5.getPtr(); - for (int i =0; i < myArray5.getArraySize(); i++) { - CPPUNIT_ASSERT_EQUAL( myArray5Ptr[i], array5Ref[i]); - } - - //test MEDMEM_Array(const MEDMEM_Array & array, bool shallowCopy=false) - MEDMEM_Array myArray5bis(myArray5, false); - myArray5Ptr = myArray5bis.getPtr(); - - elemno = 0; - for (int j=1; j <= mdim; j++) - for (int i=1; i < nbelgeoc[nbtypegeo] ; i++ ) - for (int k=1; k <= myArray5bis.getNbGauss(i); k++) { - CPPUNIT_ASSERT_EQUAL( myArray5bis.getIJK(i,j,k), array5Ref[elemno] ); - CPPUNIT_ASSERT_EQUAL( myArray5Ptr[elemno], array5Ref[elemno] ); - elemno++; - } - - //MEDMEM_Array() - MEDMEM_Array myArray5ter; - //test setPtr(ElementType * values, bool shallowCopy=false, bool ownershipOfValues=false) - CPPUNIT_ASSERT_NO_THROW(myArray5.setPtr((int*)array5Ref)); - - //test getPtr() - myArray5Ptr = myArray5ter.getPtr(); - for (int i =0; i < myArray5ter.getArraySize(); i++) { - CPPUNIT_ASSERT_EQUAL( myArray5Ptr[i], array5Ref[i]); - } -} diff --git a/src/MEDMEMCppTest/Makefile.am b/src/MEDMEMCppTest/Makefile.am deleted file mode 100644 index a1749393b..000000000 --- a/src/MEDMEMCppTest/Makefile.am +++ /dev/null @@ -1,135 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# SALOMELocalTrace : log on local machine -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES = libMEDMEMCppTest.la - -salomeinclude_HEADERS = MEDMEMTest.hxx MEDMEMCppTestExport.hxx - -EXTRA_DIST += BasicMainTest.hxx - -dist_libMEDMEMCppTest_la_SOURCES= \ - MEDMEMTest.cxx \ - MEDMEMTest_Array.cxx \ - MEDMEMTest_AsciiFieldDriver.cxx \ - MEDMEMTest_Connectivity.cxx \ - MEDMEMTest_Coordinate.cxx \ - MEDMEMTest_DesactivateFacesComputation.cxx \ - MEDMEMTest_GetVolumeAbs.cxx \ - MEDMEMTest_DriverFactory.cxx \ - MEDMEMTest_Exception.cxx \ - MEDMEMTest_Extractor.cxx \ - MEDMEMTest_Family.cxx \ - MEDMEMTest_Field.cxx \ - MEDMEMTest_Formulae.cxx \ - MEDMEMTest_GaussLocalization.cxx \ - MEDMEMTest_GibiMeshDriver.cxx \ - MEDMEMTest_Grid.cxx \ - MEDMEMTest_Group.cxx \ - MEDMEMTest_MedFileBrowser.cxx \ - MEDMEMTest_MedFieldDriver.cxx \ - MEDMEMTest_MedMeshDriver.cxx \ - MEDMEMTest_MedVersion.cxx \ - MEDMEMTest_MeshAndMeshing.cxx \ - MEDMEMTest_ModulusArray.cxx \ - MEDMEMTest_PartialDescendingConnectivity.cxx \ - MEDMEMTest_PointerOf.cxx \ - MEDMEMTest_PorflowMeshDriver.cxx \ - MEDMEMTest_Remapper.cxx \ - MEDMEMTest_SkyLineArray.cxx \ - MEDMEMTest_Support.cxx \ - MEDMEMTest_TopLevel.cxx \ - MEDMEMTest_Unit.cxx \ - MEDMEMTest_VtkFieldDriver.cxx \ - MEDMEMTest_VtkMedDriver.cxx \ - MEDMEMTest_VtkMeshDriver.cxx \ - MEDMEMTest_nArray.cxx \ - MEDMEMTest_Utils.hxx \ - MEDMEMTest_Utils.cxx \ - MEDMEMTest_MeshFuse.cxx - -libMEDMEMCppTest_la_CPPFLAGS= @CPPUNIT_INCLUDES@ $(MED3_INCLUDES) $(HDF5_INCLUDES) \ - -I$(srcdir)/../MEDMEM \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/GaussPoints \ - -I$(srcdir)/../INTERP_KERNEL/Geometric2D - -libMEDMEMCppTest_la_LDFLAGS= $(MED3_LIBS_C_ONLY) @CPPUNIT_LIBS@ \ - ../MEDMEM/libmedmem.la - -if MED_ENABLE_KERNEL - libMEDMEMCppTest_la_CPPFLAGS+= ${KERNEL_CXXFLAGS} - libMEDMEMCppTest_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace -endif - -# Executables targets -bin_PROGRAMS = TestMEDMEM \ - MEDMEMTest_Array_fault \ - MEDMEMTest_Connectivity_fault \ - MEDMEMTest_Coordinate_fault \ - MEDMEMTest_Family_fault \ - MEDMEMTest_Field_fault \ - MEDMEMTest_Grid_fault \ - MEDMEMTest_MeshAndMeshing_fault \ - MEDMEMTest_Support_fault \ - MEDMEMTest_VtkFieldDriver_fault \ - MEDMEMTest_VtkMeshDriver_fault - -dist_TestMEDMEM_SOURCES= TestMEDMEM.cxx -dist_MEDMEMTest_Array_fault_SOURCES= MEDMEMTest_Array_fault.cxx -dist_MEDMEMTest_Connectivity_fault_SOURCES= MEDMEMTest_Connectivity_fault.cxx -dist_MEDMEMTest_Coordinate_fault_SOURCES= MEDMEMTest_Coordinate_fault.cxx -dist_MEDMEMTest_Family_fault_SOURCES= MEDMEMTest_Family_fault.cxx -dist_MEDMEMTest_Field_fault_SOURCES= MEDMEMTest_Field_fault.cxx -dist_MEDMEMTest_Grid_fault_SOURCES= MEDMEMTest_Grid_fault.cxx -dist_MEDMEMTest_MeshAndMeshing_fault_SOURCES= MEDMEMTest_MeshAndMeshing_fault.cxx -dist_MEDMEMTest_Support_fault_SOURCES= MEDMEMTest_Support_fault.cxx -dist_MEDMEMTest_VtkFieldDriver_fault_SOURCES= MEDMEMTest_VtkFieldDriver_fault.cxx -dist_MEDMEMTest_VtkMeshDriver_fault_SOURCES= MEDMEMTest_VtkMeshDriver_fault.cxx - -LDADD= $(MED3_LIBS_C_ONLY) $(libMEDMEMCppTest_la_LDFLAGS) -lm \ - ../MEDMEM/libmedmem.la \ - ../INTERP_KERNEL/libinterpkernel.la libMEDMEMCppTest.la -if MED_ENABLE_KERNEL - LDADD+= -lSALOMEBasics -endif -AM_CPPFLAGS += $(libMEDMEMCppTest_la_CPPFLAGS) - -dist_salomescript_DATA = testMEDMEM.py - -UNIT_TEST_PROG = TestMEDMEM - -OBSOLETE_FILES = \ - TestOpenMED.cxx - -EXTRA_DIST += $(OBSOLETE_FILES) - -check: tests - -CLEANFILES = \ - UnitTestsResult - -clean-local: - rm -rf *.med - - diff --git a/src/MEDMEMCppTest/TestMEDMEM.cxx b/src/MEDMEMCppTest/TestMEDMEM.cxx deleted file mode 100644 index 022144676..000000000 --- a/src/MEDMEMCppTest/TestMEDMEM.cxx +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// --- include all MEDMEM Test -// -#include "MEDMEMTest.hxx" - -// --- Registers the fixture into the 'registry' - -CPPUNIT_TEST_SUITE_REGISTRATION( MEDMEMTest ); - -// --- generic Main program from KERNEL_SRC/src/Basics/Test - -#include "BasicMainTest.hxx" diff --git a/src/MEDMEMCppTest/TestOpenMED.cxx b/src/MEDMEMCppTest/TestOpenMED.cxx deleted file mode 100644 index 7bb848a29..000000000 --- a/src/MEDMEMCppTest/TestOpenMED.cxx +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEMTest_Utils.hxx" - -#include -#include - -using namespace std; - -namespace med_2_3 { - extern "C" { - #include - #include - extern med_idt _MEDdatagroupOuvrir(med_idt pid, char *nom); - extern med_err _MEDdatagroupFermer(med_idt id); - } -} - -int main(int argc, char** argv) -{ - cout<<"test start"< (filename.c_str())), - med_2_3::MED_LECTURE_ECRITURE); - - cout<<"The idt of file "< 0) { - cout<<"File is opened in mode MED_LECTURE_ECRITURE"< (filename.c_str())), - med_2_3::MED_LECTURE); - - cout<<"The idt of file "< 0) { - cout<<"File is opened in mode MED_LECTURE"<getIdentifier(); - } - catch(MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces Family Identifier"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); - } - -} -//============================================================================= -/*! - * CORBA: Accessor for number of attributes - */ -//============================================================================= -CORBA::Long FAMILY_i::getNumberOfAttributes() -throw (SALOME::SALOME_Exception) -{ - if (_family==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - try - { - return _family->getNumberOfAttributes(); - } - catch(MEDEXCEPTION &ex) - { - MESSAGE("Unable to get number of attributes"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for attributes identifiers - */ -//============================================================================= -SALOME_TYPES::ListOfLong* FAMILY_i::getAttributesIdentifiers() -throw (SALOME::SALOME_Exception) -{ - if (_family==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - int nbAttribute=_family->getNumberOfAttributes(); - myseq->length(nbAttribute); - const int * identifiers=_family->getAttributesIdentifiers(); - for (int i=0;igetAttributeIdentifier(i); - } - catch(MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces Family Identifier"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); - } - -} -//============================================================================= -/*! - * CORBA: Accessor for attributes values - */ -//============================================================================= -SALOME_TYPES::ListOfLong* FAMILY_i::getAttributesValues() -throw (SALOME::SALOME_Exception) -{ - if (_family==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - int nbAttribute=_family->getNumberOfAttributes(); - myseq->length(nbAttribute); - const int * values=_family->getAttributesValues(); - for (int i=0;igetAttributeValue(i); - } - catch(MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces specified attribut value"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for attributes desriptions - */ -//============================================================================= -SALOME_TYPES::ListOfString * FAMILY_i::getAttributesDescriptions() -throw (SALOME::SALOME_Exception) -{ - if (_family==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - try - { - int nbAttribute=_family->getNumberOfAttributes(); - myseq->length(nbAttribute); - const string * descattribute=_family->getAttributesDescriptions(); - for (int i=0;igetAttributeDescription(i).c_str()); - } - catch(MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces specified attribut description"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for number of groups the family belongs to - */ -//============================================================================= -CORBA::Long FAMILY_i::getNumberOfGroups() -throw (SALOME::SALOME_Exception) -{ - if (_family==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - try - { - return _family->getNumberOfGroups(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces specified attribut value"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for groups names - */ -//============================================================================= -SALOME_TYPES::ListOfString * FAMILY_i::getGroupsNames() -throw (SALOME::SALOME_Exception) -{ - if (_family==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ - SALOME::INTERNAL_ERROR); - - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - try - { - int nbGroups=_family->getNumberOfGroups(); - myseq->length(nbGroups); - const string * descGroups=_family->getGroupsNames(); - for (int i=0;igetGroupName(i).c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces specified attribut description"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(),SALOME::INTERNAL_ERROR); - } -} - diff --git a/src/MEDMEM_I/MEDMEM_Family_i.hxx b/src/MEDMEM_I/MEDMEM_Family_i.hxx deleted file mode 100644 index 95ea08858..000000000 --- a/src/MEDMEM_I/MEDMEM_Family_i.hxx +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Family_i.hxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Family_i.hxx -//============================================================================= -// -#ifndef MED_FAMILY_I_HXX_ -#define MED_FAMILY_I_HXX_ - -#include "MEDMEM_I.hxx" - -#include "MEDMEM_Support_i.hxx" - -namespace MEDMEM { -class FAMILY; -class MEDMEM_I_EXPORT FAMILY_i: - virtual public POA_SALOME_MED::FAMILY, - virtual public SUPPORT_i -{ -protected : - FAMILY_i(); - ~FAMILY_i(); - - // C++ object containing values - const ::MEDMEM::FAMILY * const _family ; - -public : - // Constructors and associated internal methods - FAMILY_i(const ::MEDMEM::FAMILY * const f); - FAMILY_i(const FAMILY_i & f); - - CORBA::Long getIdentifier() - throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfAttributes() - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong* getAttributesIdentifiers() - throw (SALOME::SALOME_Exception); - CORBA::Long getAttributeIdentifier(CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong* getAttributesValues() - throw (SALOME::SALOME_Exception); - CORBA::Long getAttributeValue(CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString* getAttributesDescriptions() - throw (SALOME::SALOME_Exception); - char* getAttributeDescription( CORBA::Long i) - throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfGroups() - throw (SALOME::SALOME_Exception); - char * getGroupName( CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString* getGroupsNames() - throw (SALOME::SALOME_Exception); - -}; -} -#endif /* MED_FAMILY_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_FieldTemplate_i.hxx b/src/MEDMEM_I/MEDMEM_FieldTemplate_i.hxx deleted file mode 100644 index add96498a..000000000 --- a/src/MEDMEM_I/MEDMEM_FieldTemplate_i.hxx +++ /dev/null @@ -1,207 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MED_FIELDTEMPLATE_I_HXX__ -#define __MED_FIELDTEMPLATE_I_HXX__ - -#include -#include CORBA_SERVER_HEADER(MED) -#include "MEDMEM_Field_i.hxx" -#include "MEDMEM_Field.hxx" -#include "SenderFactory.hxx" -#include "MultiCommException.hxx" -#include "MEDMEM_ArrayConvert.hxx" -#include "MEDMEM_TraitsForFields.hxx" -#include "utilities.h" - -namespace MEDMEM -{ - template < class T, class INTERLACING_TAG=FullInterlace > - class FIELDTEMPLATE_I : public FIELDI_TRAITS::InterfaceForServant, - public FIELD_i, - public SALOMEMultiComm - { - public: - FIELDTEMPLATE_I(); - ~FIELDTEMPLATE_I(); - FIELDTEMPLATE_I(MEDMEM::FIELD *f, bool ownCppPtr=false); - FIELDTEMPLATE_I(FIELDTEMPLATE_I & f); - typename FIELDI_TRAITS::SeqType* getValue (SALOME_MED::medModeSwitch mode ) - throw (SALOME::SALOME_Exception); - typename FIELDI_TRAITS::SenderPtrType getSenderForValue(SALOME_MED::medModeSwitch mode) - throw (SALOME::SALOME_Exception); - }; - - //============================================================================= - /*! - * Default constructor - */ - //============================================================================= - template < class T, class INTERLACING_TAG > - FIELDTEMPLATE_I::FIELDTEMPLATE_I(): FIELD_i() - { - } - //============================================================================= - /*! - * Destructor - */ - //============================================================================= - template < class T, class INTERLACING_TAG > - FIELDTEMPLATE_I::~FIELDTEMPLATE_I() - { - } - //============================================================================= - /*! - * Constructor par recopie - */ - //============================================================================= - template < class T, class INTERLACING_TAG > - FIELDTEMPLATE_I::FIELDTEMPLATE_I(FIELDTEMPLATE_I& fd): - FIELD_i(fd) - { - } - //============================================================================= - /*! - * Default constructor - */ - //============================================================================= - template < class T, class INTERLACING_TAG > - FIELDTEMPLATE_I::FIELDTEMPLATE_I(MEDMEM::FIELD *f, bool ownCppPtr):FIELD_i(f,ownCppPtr) - { - } - - //============================================================================= - /*! - * CORBA: Accessor for Field's values - */ - //============================================================================= - template < class T, class INTERLACING_TAG > - typename FIELDI_TRAITS::SeqType *FIELDTEMPLATE_I::getValue( SALOME_MED::medModeSwitch mode ) - throw (SALOME::SALOME_Exception) - { - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - typename FIELDI_TRAITS::SeqVarType myseq = new typename FIELDI_TRAITS::SeqType; - try - { - medModeSwitch modemed=convertIdlModeToMedMode(mode); - // ::FIELD *ptrD=dynamic_cast< ::FIELD* >(_fieldTptr); - // the alternative is not safe but the dynamic_cast fails using the python API - MEDMEM::FIELD *ptrD = static_cast* >(_fieldTptr); - int nbval=ptrD->getValueLength(); - if(ptrD->getInterlacingType()==modemed) - { - const T* values =ptrD->getValue(); - myseq->length(nbval); - for (int i=0; igetGaussPresence() ) - { - typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayGauss(); - int size=myArray->getArraySize(); - values=new T[size]; - delete ArrayConvert(*myArray,values); - } - else - { - typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayNoGauss(); - int size=myArray->getArraySize(); - values=new T[size]; - delete ArrayConvert(*myArray,values); - } - for (int i=0; i - typename FIELDI_TRAITS::SenderPtrType FIELDTEMPLATE_I::getSenderForValue( SALOME_MED::medModeSwitch mode ) - throw (SALOME::SALOME_Exception) - { - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - typename FIELDI_TRAITS::SenderPtrType ret; - try - { - medModeSwitch modemed=convertIdlModeToMedMode(mode); - // ::FIELD *ptrD=dynamic_cast< ::FIELD* >(_fieldTptr); - // the alternative is not safe but the dynamic_cast fails using the python API - MEDMEM::FIELD *ptrD=static_cast< MEDMEM::FIELD* >(_fieldTptr); - int nbval=ptrD->getValueLength(); - if(ptrD->getInterlacingType()==modemed) - { - const T* values =ptrD->getValue(); - ret=SenderFactory::buildSender(*this,values,nbval); - } - else - { - T *values; - if ( ptrD->getGaussPresence() ) - { - typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayGauss(); - int size=myArray->getArraySize(); - values=new T[size]; - delete ArrayConvert(*myArray,values); - - } - else - { - typename MEDMEM_ArrayInterface::Array * myArray = ptrD->getArrayNoGauss(); - int size=myArray->getArraySize(); - values=new T[size]; - delete ArrayConvert(*myArray,values); - } - ret=SenderFactory::buildSender(*this,values,nbval); - } - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces Field "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return ret; - } - -} - -#endif diff --git a/src/MEDMEM_I/MEDMEM_Field_i.cxx b/src/MEDMEM_I/MEDMEM_Field_i.cxx deleted file mode 100644 index 03a77d983..000000000 --- a/src/MEDMEM_I/MEDMEM_Field_i.cxx +++ /dev/null @@ -1,813 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Field_i.cxx -// Created : mer fév 20 15:47:57 CET 2002 -// Author : EDF -// Project : SALOME -//============================================================================= - -#include "MEDMEM_Field_i.hxx" - -#include "SALOME_NamingService.hxx" -#include "SALOME_LifeCycleCORBA.hxx" - -#include CORBA_SERVER_HEADER(SALOME_ModuleCatalog) -#include CORBA_CLIENT_HEADER(MED_Gen) - -using namespace MEDMEM; -using namespace MED_EN; - -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()),_corbaIndex(FIELD_i::fieldIndex++) -{ -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -FIELD_i::~FIELD_i() -{ - if ( _fieldTptr ) - _fieldTptr->removeReference(); - //if (_ownCppPtr) delete _fieldTptr; -} -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -FIELD_i::FIELD_i(::FIELD_ * const field, bool ownCppPtr): - _ownCppPtr(ownCppPtr), - _fieldTptr(field), - _corbaIndex(FIELD_i::fieldIndex++), - _FieldId("") -{ - if ( _fieldTptr ) _fieldTptr->addReference(); - FIELD_i::fieldMap[_corbaIndex]=_fieldTptr; - - MESSAGE("FIELD_i::FIELD_i Checking of pointeurs !!!"); - - SCRUTE(_fieldTptr); -} - -//============================================================================= -/*! - * Constructor par recopie - */ -//============================================================================= -FIELD_i::FIELD_i( FIELD_i & f):_ownCppPtr(false), _fieldTptr(f._fieldTptr), - _corbaIndex(FIELD_i::fieldIndex++), - _FieldId("") -{ - if ( _fieldTptr ) _fieldTptr->addReference(); - FIELD_i::fieldMap[_corbaIndex]=_fieldTptr; -} -//============================================================================= -/*! - * 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); - } -} - -void FIELD_i::setName(const char* theName) - throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr == NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", SALOME::INTERNAL_ERROR); - - try { - _fieldTptr->setName(theName); - } - 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) -{ - 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); - - 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 for gauss numbers presence. - */ -//============================================================================= -CORBA::Boolean FIELD_i::getGaussPresence() -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - try - { - return _fieldTptr->getGaussPresence(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Exception en accedant au champ"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor - */ -//============================================================================= -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_TYPES::ListOfString * FIELD_i::getComponentsNames() -throw (SALOME::SALOME_Exception) -{ - if (_fieldTptr==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Field", \ - SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - 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;iGetStudy()->NewChildIterator(theFather); - for (; anIter->More() && aChild->_is_nil(); anIter->Next()) { - aCurChild = anIter->Value(); - string aCurName = aCurChild->GetName(); - if (aCurName == theName) - aChild = aCurChild; - } - return aChild._retn(); -} - -void FIELD_i::addInStudyToComponent (SALOMEDS::SComponent_ptr myComponent, - SALOME_MED::FIELD_ptr myIor) - throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection) -{ - if (CORBA::is_nil(myComponent) || CORBA::is_nil(myIor)) - THROW_SALOME_CORBA_EXCEPTION("Null parameter", SALOME::BAD_PARAM); - - 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::Study_var myStudy = myComponent->GetStudy(); - SALOMEDS::StudyBuilder_var aBuilder = myStudy->NewBuilder(); - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var aIOR; - - // Create SObject labelled 'MEDFIELD' if it doesn't already exist - SALOMEDS::Study::ListOfSObject_var aMEDFIELDs = - myStudy->FindObjectByName("MEDFIELD", myComponent->ComponentDataType()); - int aLength = aMEDFIELDs->length(); - SALOMEDS::SObject_var medfieldfather; - if (aLength > 0) { - medfieldfather = aMEDFIELDs[0]; - } - else { - MESSAGE("Add Object 'MEDFIELD'"); - medfieldfather = aBuilder->NewObject(myComponent); - anAttr = aBuilder->FindOrCreateAttribute(medfieldfather, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue("MEDFIELD"); - } - - // Create SObject labelled 'FIELDNAME' if it doesn't already exit - string fieldName = _fieldTptr->getName(); - SALOMEDS::SObject_var medfieldnamefather = FindChildByName(medfieldfather, fieldName); - if ( CORBA::is_nil(medfieldnamefather) ) - { - MESSAGE("Add Object "<NewObject(medfieldfather); - anAttr = aBuilder->FindOrCreateAttribute(medfieldnamefather, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(fieldName.c_str()); - } - - string fieldEntryPath = "/"; - //fieldEntryPath += "Med/"; - string componentName = myComponent->GetName(); - fieldEntryPath += componentName + "/MEDFIELD/" + fieldName + "/"; - - int iterationNumber = _fieldTptr->getIterationNumber(); - SCRUTE(iterationNumber); - - int orderNumber = _fieldTptr->getOrderNumber(); - SCRUTE(orderNumber); - - ostringstream iterationName; - iterationName<<"(" << iterationNumber << "," << orderNumber << ")"; - string supportName = (_fieldTptr->getSupport())->getName(); - string meshName = ((_fieldTptr->getSupport())->getMesh())->getName(); - - SCRUTE(meshName); - for (string::size_type pos=0; posFindObjectByPath(fieldEntryPath.c_str()); - bool alreadyPublished = ! CORBA::is_nil(fieldSO); - aBuilder->NewCommand(); - if ( !alreadyPublished ) - { - MESSAGE("Add a Field Object under "<NewObject(medfieldnamefather); - // check that this method and getEntryPath() build the same path, - // though this is true only for MED component - MESSAGE("fieldEntryPath: "<< fieldEntryPath); - MESSAGE("getEntryPath(): "<< getEntryPath()); - if (componentName == "Med") - ASSERT( getEntryPath() == fieldEntryPath ); - } - anAttr = aBuilder->FindOrCreateAttribute(fieldSO, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(fieldEntryName); - - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init(0,0); - string iorStr = orb->object_to_string(myIor); - anAttr = aBuilder->FindOrCreateAttribute(fieldSO, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.c_str()); - _FieldId = fieldSO->GetID(); - - if ( !alreadyPublished ) - { - MESSAGE("Computing path to Support"); - - string supportEntryPath = SUPPORT_i::getEntryPath( _fieldTptr->getSupport() ); - SCRUTE(supportEntryPath); - - SALOMEDS::SObject_var supportObject = - myStudy->FindObjectByPath(supportEntryPath.c_str()); - - 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 = aBuilder->NewObject(fieldSO); - aBuilder->Addreference(newObjSupport,supportObject); - MESSAGE(" OUF !!!"); - } - } - - aBuilder->CommitCommand(); - - delete [] fieldEntryName; - - // register the Corba pointer: increase the referrence count - MESSAGE("Registering of the Corba Field pointer"); - Register(); - - MESSAGE("FIELD_i::addInStudy"); - - //END_OF(); -} - -//============================================================================= -/*! - * 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); - } - catch (MEDEXCEPTION &) - { - 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); - } -} - -//============================================================================= -/*! - * internal method: publish MED component - */ -//============================================================================= - -SALOMEDS::SComponent_ptr FIELD_i::PublishMedComponent(SALOMEDS::Study_ptr theStudy) -{ - if ( CORBA::is_nil(theStudy) ) - return SALOMEDS::SComponent::_nil(); - - SALOMEDS::SComponent_var medfather = theStudy->FindComponent("MED"); - if ( !CORBA::is_nil(medfather) ) - return medfather._retn(); - - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init(0,0); - - SALOME_NamingService* ns = SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - ns->init_orb( orb ); - - SALOME_LifeCycleCORBA* lcc = new SALOME_LifeCycleCORBA( ns ); - - SALOME_ModuleCatalog::ModuleCatalog_var aCatalog = - SALOME_ModuleCatalog::ModuleCatalog::_narrow(ns->Resolve("/Kernel/ModulCatalog")); - if ( CORBA::is_nil( aCatalog ) ) - return medfather._retn(); - SALOME_ModuleCatalog::Acomponent_var aComp = aCatalog->GetComponent( "MED" ); - if ( CORBA::is_nil( aComp ) ) - return medfather._retn(); - - SALOMEDS::StudyBuilder_var aBuilder = theStudy->NewBuilder(); - aBuilder->NewCommand(); - bool aLocked = theStudy->GetProperties()->IsLocked(); - if (aLocked) theStudy->GetProperties()->SetLocked(false); - - medfather = aBuilder->NewComponent("MED"); - SALOMEDS::GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute(medfather, "AttributeName"); - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue( aComp->componentusername() ); - - Engines::EngineComponent_var aMedComponent = lcc->FindOrLoad_Component("FactoryServer", "MED"); - SALOME_MED::MED_Gen_var aMedEngine = SALOME_MED::MED_Gen::_narrow( aMedComponent ); - aBuilder->DefineComponentInstance(medfather, aMedEngine); - - if (aLocked) theStudy->GetProperties()->SetLocked(true); - aBuilder->CommitCommand(); - - return medfather._retn(); -} - -//================================================================================ -/*! - * \brief Return a default path to publish this field - * \retval string - the path - */ -//================================================================================ - -string FIELD_i::getEntryPath () -{ - string path; - if ( _fieldTptr && - _fieldTptr->getSupport() && - _fieldTptr->getSupport()->getMesh() ) - { - string meshName = _fieldTptr->getSupport()->getMesh()->getName(); - for (string::size_type pos=0; posgetName() << "/" - << "(" << _fieldTptr->getIterationNumber() - << "," << _fieldTptr->getOrderNumber() - << ")_ON_" << _fieldTptr->getSupport()->getName() - << "_OF_" << meshName; - - path = os.str(); - } - return path; -} diff --git a/src/MEDMEM_I/MEDMEM_Field_i.hxx b/src/MEDMEM_I/MEDMEM_Field_i.hxx deleted file mode 100644 index 2420742f6..000000000 --- a/src/MEDMEM_I/MEDMEM_Field_i.hxx +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Field_i.hxx -// Project : SALOME -// Author : EDF -// $Header : $ -//============================================================================= -// -#ifndef MED_FIELD_I_HXX_ -#define MED_FIELD_I_HXX_ - -#include - -#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 MEDMEM_I_EXPORT FIELD_i: public virtual POA_SALOME_MED::FIELD, - public SALOME::GenericObj_i -{ -public : - static map < int, ::MEDMEM::FIELD_ * > fieldMap ; -protected : - static int fieldIndex ; - bool _ownCppPtr; -protected : - // 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(MEDMEM::FIELD_ * const field, bool ownCppPtr); - FIELD_i(FIELD_i & f); - -public : - // Associated internal methods - ~FIELD_i(); - - char * getName() throw (SALOME::SALOME_Exception); - void setName(const char* theName) - 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::Boolean getGaussPresence(); - CORBA::Double getTime() throw (SALOME::SALOME_Exception); - CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfString * getComponentsNames() throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString * getComponentsUnits() throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString * getComponentsDescriptions() throw (SALOME::SALOME_Exception); - - void addInStudy(SALOMEDS::Study_ptr myStudy, - SALOME_MED::FIELD_ptr myIor) - throw (SALOME::SALOME_Exception, - SALOMEDS::StudyBuilder::LockProtection); - - void addInStudyToComponent(SALOMEDS::SComponent_ptr myComponent, - 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 - MEDMEM::FIELD_ * constructConstField() const; - - // Publish MED Component - SALOMEDS::SComponent_ptr PublishMedComponent(SALOMEDS::Study_ptr theStudy); - - // Return a default path to publish this field - std::string getEntryPath (); - - }; -} - -//using namespace MEDMEM; - -#endif /* MED_FIELD_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_GMesh_i.cxx b/src/MEDMEM_I/MEDMEM_GMesh_i.cxx deleted file mode 100644 index 991dfa2dc..000000000 --- a/src/MEDMEM_I/MEDMEM_GMesh_i.cxx +++ /dev/null @@ -1,1225 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Mesh_i.cxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Mesh_i.cxx -//============================================================================= -// -#include - -#include "utilities.h" -#include "Utils_CorbaException.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" - -#include "MEDMEM_convert.hxx" -#include "MEDMEM_Mesh_i.hxx" -#include "MEDMEM_Support_i.hxx" -#include "MEDMEM_Family_i.hxx" -#include "MEDMEM_Group_i.hxx" -#include "MEDMEM_FieldTemplate_i.hxx" - -#include "MEDMEM_Mesh.hxx" -#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 -map < int, ::GMESH *> GMESH_i::meshMap ; -int GMESH_i::meshIndex = 0 ; - - - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -GMESH_i::GMESH_i(): - SALOMEMultiComm(), - SALOME::GenericObj_i(), - _mesh(constructConstMesh()), - _corbaIndex(MESH_i::meshIndex++), - _meshId("") -{ - MESH_i::meshMap[_corbaIndex]=_mesh; -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -GMESH_i::~GMESH_i() -{ - if ( _mesh ) - _mesh->removeReference(); -} -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -GMESH_i::GMESH_i(::GMESH * const m ) : - SALOMEMultiComm(), - SALOME::GenericObj_i(), - _mesh(m), - _corbaIndex(MESH_i::meshIndex++), - _meshId("") -{ - if ( _mesh ) _mesh->addReference(); - GMESH_i::meshMap[_corbaIndex]=_mesh; -} -//============================================================================= -/*! - * Copy Constructor - */ -//============================================================================= -//MESH_i::MESH_i(const MESH_i & m) :_mesh(m._mesh), -GMESH_i::GMESH_i( GMESH_i & m) : - SALOMEMultiComm(), - SALOME::GenericObj_i(), - _mesh(m._mesh), - _corbaIndex(MESH_i::meshIndex++), - _meshId("") -{ - if ( _mesh ) _mesh->addReference(); - GMESH_i::meshMap[_corbaIndex]=_mesh; -} -//============================================================================= -/*! - * Internal Method in order to have a const ptr - */ -//============================================================================= -::GMESH * GMESH_i::constructConstMesh() const -{ - ::MESH * const ptrMesh =new ::MESH(); - return ptrMesh; -} -//============================================================================= -/*! - * CORBA: Accessor for Name - */ -//============================================================================= -char * GMESH_i::getName() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - - try - { - return CORBA::string_dup(_mesh->getName().c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces the mesh name"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for corbaindex cuisine interne - */ -//============================================================================= -CORBA::Long GMESH_i::getCorbaIndex() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - return _corbaIndex; -} -//============================================================================= -/*! - * CORBA: Accessor for Space Dimension - */ -//============================================================================= -CORBA::Long GMESH_i::getSpaceDimension() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - return _mesh->getSpaceDimension(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces the space dimension "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for Mesh Dimension - */ -//============================================================================= -CORBA::Long GMESH_i::getMeshDimension() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - return _mesh->getMeshDimension(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces the mesh dimension "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: boolean indicating if mesh is a Grid - */ -//============================================================================= -CORBA::Boolean GMESH_i::getIsAGrid() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - return _mesh->getIsAGrid(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces mesh flag isAGrid"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for Coordinates System - */ -//============================================================================= -char * GMESH_i::getCoordinatesSystem() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - - try - { - return CORBA::string_dup(_mesh->getCoordinatesSystem().c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces the type of CoordinatesSystem"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for Coordinates Names - */ -//============================================================================= -SALOME_TYPES::ListOfString * GMESH_i::getCoordinatesNames() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - try - { - int spaceDimension=_mesh->getSpaceDimension(); - const string * coordinatesName =_mesh->getCoordinatesNames(); - myseq->length(spaceDimension); - for (int i=0; igetSpaceDimension(); - const string * coordinatesUnits =_mesh->getCoordinatesUnits(); - myseq->length(spaceDimension); - for (int i=0; igetNumberOfNodes(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces number of nodes"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for number of Types - */ -//============================================================================= -CORBA::Long GMESH_i::getNumberOfTypes(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - return _mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity)); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces number of differents types"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for existing geometry element types - */ -//============================================================================= -SALOME_MED::medGeometryElement GMESH_i::getElementType (SALOME_MED::medEntityMesh entity, - CORBA::Long number) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - return _mesh->getElementType(convertIdlEntToMedEnt(entity),number); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces number of differents element types"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for existing geometry element types - * Not implemented for MED_ALL_ENTITIES - */ -//============================================================================= -SALOME_MED::medGeometryElement_array * GMESH_i::getTypes (SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - if (entity ==SALOME_MED::MED_ALL_ENTITIES) - THROW_SALOME_CORBA_EXCEPTION("Not implemented for MED_ALL_ENTITIES",\ - SALOME::BAD_PARAM); - SALOME_MED::medGeometryElement_array_var myseq = - new SALOME_MED::medGeometryElement_array; - try - { - int nbTypes=_mesh->getNumberOfTypes(convertIdlEntToMedEnt(entity)); - const medGeometryElement * elemts =_mesh->getTypes( - convertIdlEntToMedEnt(entity)); - myseq->length(nbTypes); - for (int i=0; igetNumberOfElementsWithPoly(convertIdlEntToMedEnt(entity), -// convertIdlEltToMedElt(geomElement)); -// else - return _mesh->getNumberOfElements(convertIdlEntToMedEnt(entity), - convertIdlEltToMedElt(geomElement)); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces number of elements"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Returns number of families within the mesh - */ -//============================================================================= -CORBA::Long GMESH_i::getNumberOfFamilies(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - return _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity)); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces number of families of the mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Returns number of groups within the mesh - */ -//============================================================================= -CORBA::Long GMESH_i::getNumberOfGroups(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - return _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity)); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces number of groups of the mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Returns references for families within the mesh - */ -//============================================================================= -SALOME_MED::Family_array * GMESH_i::getFamilies(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array; - try - { - int nbfam= _mesh->getNumberOfFamilies(convertIdlEntToMedEnt(entity)); - myseq->length(nbfam); - vector fam(nbfam); - fam = _mesh->getFamilies(convertIdlEntToMedEnt(entity)); - for (int i=0;i_this(); - } - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces families of the mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return myseq._retn(); -} -//============================================================================= -/*! - * CORBA: Returns Coordinates global informations - */ -//============================================================================= -SALOME_MED::GMESH::coordinateInfos * GMESH_i::getCoordGlobal() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::GMESH::coordinateInfos_var all = new SALOME_MED::GMESH::coordinateInfos; - try - { - all->coordSystem = CORBA::string_dup(_mesh->getCoordinatesSystem().c_str()); - - int spaceDimension=_mesh->getSpaceDimension(); - const string * coordinatesUnits =_mesh->getCoordinatesUnits(); - const string * coordinatesName =_mesh->getCoordinatesNames(); - - all->coordUnits.length(spaceDimension); - all->coordNames.length(spaceDimension); - for (int i=0; icoordUnits[i]=CORBA::string_dup(coordinatesUnits[i].c_str()); - all->coordNames[i]=CORBA::string_dup(coordinatesName[i].c_str()); - } - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces coordinate information "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return all._retn(); -} - -//============================================================================= -/*! - * CORBA: Returns references for family i within the mesh - */ -//============================================================================= -SALOME_MED::FAMILY_ptr GMESH_i::getFamily(SALOME_MED::medEntityMesh entity, - CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - const FAMILY * fam = _mesh->getFamily(convertIdlEntToMedEnt(entity),i); - FAMILY_i * f1=new FAMILY_i(fam); - return f1->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces specified family of the mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - -} -//============================================================================= -/* - * CORBA: Returns Mesh global informations - */ -//============================================================================= -SALOME_MED::GMESH::meshInfos * GMESH_i::getMeshGlobal() -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::GMESH::meshInfos_var all = new SALOME_MED::GMESH::meshInfos; - try - { - all->name = CORBA::string_dup(_mesh->getName().c_str()); - all->spaceDimension = _mesh->getSpaceDimension(); - all->meshDimension = _mesh->getMeshDimension(); - all->numberOfNodes = _mesh->getNumberOfNodes(); - all->isAGrid = _mesh->getIsAGrid(); - - int nbFam= _mesh->getNumberOfFamilies(MED_NODE); - all->famNode.length(nbFam); - vector vNode (nbFam); - vNode = _mesh->getFamilies(MED_NODE); - for (int i=0;ifamNode[i] = f1->_this(); - } - - nbFam = _mesh->getNumberOfFamilies(MED_EDGE); - all->famEdge.length(nbFam); - vector vEdge (nbFam); - vEdge = _mesh->getFamilies(MED_EDGE); - for (int i=0;ifamEdge[i] = f1->_this(); - } - - nbFam = _mesh->getNumberOfFamilies(MED_FACE); - all->famFace.length(nbFam); - vector vFace (nbFam); - vFace = _mesh->getFamilies(MED_FACE); - for (int i=0;ifamFace[i] = f1->_this(); - } - - nbFam = _mesh->getNumberOfFamilies(MED_CELL); - all->famCell.length(nbFam); - vector vCell (nbFam); - vCell = _mesh->getFamilies(MED_CELL); - for (int i=0;ifamCell[i] = f1->_this(); - } - - int nbGroup = _mesh->getNumberOfGroups(MED_NODE); - all->groupNode.length(nbGroup); - vector gNode (nbGroup); - gNode = _mesh->getGroups(MED_NODE); - for (int i=0;igroupNode[i] = f1->_this(); - } - - nbGroup = _mesh->getNumberOfGroups(MED_EDGE); - all->groupEdge.length(nbGroup); - vector gEdge (nbGroup); - gEdge = _mesh->getGroups(MED_EDGE); - for (int i=0;igroupEdge[i] = f1->_this(); - } - nbGroup = _mesh->getNumberOfGroups(MED_FACE); - all->groupFace.length(nbGroup); - vector gFace (nbGroup); - gFace = _mesh->getGroups(MED_FACE); - for (int i=0;igroupFace[i] = f1->_this(); - } - - nbGroup = _mesh->getNumberOfGroups(MED_CELL); - all->groupCell.length(nbGroup); - vector gCell (nbGroup); - gCell = _mesh->getGroups(MED_CELL); - for (int i=0;igroupCell[i] = f1->_this(); - } - - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return all._retn(); -} -//============================================================================= - /* - * CORBA: Returns references for groups within the mesh - */ -//============================================================================= -SALOME_MED::Group_array * GMESH_i::getGroups(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - SALOME_MED::Group_array_var myseq = new SALOME_MED::Group_array; - try - { - int nbgroups = _mesh->getNumberOfGroups(convertIdlEntToMedEnt(entity)); - myseq->length(nbgroups); - vector groups(nbgroups); - groups = _mesh->getGroups(convertIdlEntToMedEnt(entity)); - for (int i=0;i_this(); - } - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces number of groups of the mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return myseq._retn(); -} -//============================================================================= -/*! - * CORBA: Returns references for group i within the mesh - */ -//============================================================================= -SALOME_MED::GROUP_ptr GMESH_i::getGroup(SALOME_MED::medEntityMesh entity, - CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - const GROUP * grou = _mesh->getGroup(convertIdlEntToMedEnt(entity),i); - GROUP_i * f1=new GROUP_i(grou); - return f1->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces specified group of the mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::SUPPORT_ptr GMESH_i::getBoundaryElements(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - SUPPORT * myNewSupport = _mesh->getBoundaryElements(convertIdlEntToMedEnt(entity)); - SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport); - return mySupportI->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the volume "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::SUPPORT_ptr GMESH_i::getSupportOnAll(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - const SUPPORT * myNewSupport = _mesh->getSupportOnAll(convertIdlEntToMedEnt(entity)); - SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport); - return mySupportI->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the support "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr GMESH_i::getVolume(SALOME_MED::SUPPORT_ptr mySupport) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); try - { - int sup = mySupport->getCorbaIndex(); - ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); - const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; - ::FIELD*f=_mesh->getVolume( myCppSupport); - FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); - return medf->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the volume "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::SUPPORT_ptr GMESH_i::getSkin(SALOME_MED::SUPPORT_ptr mySupport3D) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - int sup = mySupport3D->getCorbaIndex(); - ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); - const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; - SUPPORT * myNewSupport = _mesh->getSkin(myCppSupport); - SUPPORT_i * mySupportI = new SUPPORT_i(myNewSupport); - return mySupportI->_this() ; - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the volume "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr GMESH_i::getArea(SALOME_MED::SUPPORT_ptr mySupport) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - int sup = mySupport->getCorbaIndex(); - ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); - const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; - ::FIELD*f=_mesh->getArea( myCppSupport); - FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); - return medf->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the area "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr GMESH_i::getLength(SALOME_MED::SUPPORT_ptr mySupport) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - int sup = mySupport->getCorbaIndex(); - ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); - const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; - ::FIELD*f=_mesh->getLength( myCppSupport); - FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); - return medf->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the length "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr GMESH_i::getNormal(SALOME_MED::SUPPORT_ptr mySupport) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - int sup = mySupport->getCorbaIndex(); - ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); - const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; - ::FIELD*f=_mesh->getNormal( myCppSupport); - FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); - return medf->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the normal "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr GMESH_i::getBarycenter(SALOME_MED::SUPPORT_ptr mySupport) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - int sup = mySupport->getCorbaIndex(); - ASSERT(SUPPORT_i::supportMap.find(sup)!=SUPPORT_i::supportMap.end()); - const SUPPORT * myCppSupport=SUPPORT_i::supportMap[sup]; - ::FIELD*f=_mesh->getBarycenter( myCppSupport); - FIELDTEMPLATE_I *medf = new FIELDTEMPLATE_I(f); - return medf->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the barycenter "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -SALOME_MED::FIELD_ptr GMESH_i::getNeighbourhood(SALOME_MED::SUPPORT_ptr mySupport) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - MESSAGE("Not Implemented"); - return SALOME_MED::FIELD::_nil(); -} -//============================================================================= -/*! - * CORBA: add the Mesh in the StudyManager - */ -//============================================================================= -void GMESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::GMESH_ptr myIor ) -throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection) -{ - if ( _meshId != "" ) - { - MESSAGE("Mesh already in Study"); - THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \ - SALOME::BAD_PARAM); - }; - - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var aIOR; - - // Find SComponent labelled 'MED' - SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); - myBuilder->NewCommand(); - if ( CORBA::is_nil(medfather) ) - THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR); - - // Create SObject labelled 'MESH' if it doesn't already exit -// SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH"); -// if ( CORBA::is_nil(medmeshfather) ) -// { -// MESSAGE("Add Object MEDMESH"); -// medmeshfather = myBuilder->NewObject(medfather); -// //medmeshfather.Name = "MEDMESH" ; -// anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName"); -// aName = SALOMEDS::AttributeName::_narrow(anAttr); -// aName->SetValue("MEDMESH"); - -// } ; - - string aPath = "/Med/MEDMESH"; - SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath( aPath.c_str() ); - if ( CORBA::is_nil(medmeshfather) ) - { - MESSAGE("Add Object MEDMESH"); - - myBuilder->AddDirectory( aPath.c_str() ); - medmeshfather = myStudy->FindObjectByPath( aPath.c_str() ); - } ; - - aPath += "/" + _mesh->getName(); - SALOMEDS::SObject_var meshSO = myStudy->FindObjectByPath( aPath.c_str()); - bool alreadyPublished = ! CORBA::is_nil( meshSO ); - if ( !alreadyPublished ) { - MESSAGE("Add a mesh Object under MED/MEDMESH"); - meshSO = myBuilder->NewObject(medmeshfather); - - anAttr = myBuilder->FindOrCreateAttribute(meshSO, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(_mesh->getName().c_str()); - } - - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init(0,0); - string iorStr = orb->object_to_string(myIor); - anAttr = myBuilder->FindOrCreateAttribute(meshSO, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.c_str()); - _meshId = meshSO->GetID(); - myBuilder->CommitCommand(); - - // register the Corba pointer: increase the referrence count - MESSAGE("Registering of the Corba Mesh pointer"); - Register(); - -} -//============================================================================= -/*! - * CORBA: add the Mesh in the StudyManager - */ -//============================================================================= -void GMESH_i::addInStudy(SALOMEDS::Study_ptr myStudy,SALOME_MED::GMESH_ptr myIor,const string & fileName ) -throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection) -{ - if ( _meshId != "" ) - { - MESSAGE("Mesh already in Study"); - THROW_SALOME_CORBA_EXCEPTION("Mesh already in Study", \ - SALOME::BAD_PARAM); - }; - - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var aIOR; - SALOMEDS::AttributeComment_var aComment; - - // Find 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 'MESH' if it doesn't already exit - SALOMEDS::SObject_var medmeshfather = myStudy->FindObject("MEDMESH"); - if ( CORBA::is_nil(medmeshfather) ) - { - MESSAGE("Add Object MEDMESH"); - medmeshfather = myBuilder->NewObject(medfather); - //medmeshfather.Name = "MEDMESH" ; - anAttr = myBuilder->FindOrCreateAttribute(medmeshfather, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue("MEDMESH"); - - } ; - - MESSAGE("Add a mesh Object under MED/MEDMESH"); - myBuilder->NewCommand(); - SALOMEDS::SObject_var newObj = myBuilder->NewObject(medmeshfather); - - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init(0,0); - CORBA::String_var iorStr = orb->object_to_string(myIor); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.in()); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(_mesh->getName().c_str()); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeComment"); - aComment = SALOMEDS::AttributeComment::_narrow(anAttr); - aComment->SetValue(fileName.c_str()); - _meshId = newObj->GetID(); - myBuilder->CommitCommand(); - - // register the Corba pointer: increase the referrence count - MESSAGE("Registering of the Corba Mesh pointer"); - Register(); - -} -//============================================================================= - -//============================================================================= -/*! - * CORBA: write mesh in a med file - */ -//============================================================================= -void GMESH_i::write(CORBA::Long i, const char* driverMeshName) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - _mesh->write(i); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to write the mesh "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: read mesh in a med file - */ -//============================================================================= -void GMESH_i::read(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - _mesh->read(i); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to read the mesh "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA : release driver - */ -//============================================================================= -void GMESH_i::rmDriver(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - _mesh->rmDriver(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to unlink the mesh from the driver "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object"\ - ,SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA : attach driver - */ -//============================================================================= -CORBA::Long GMESH_i::addDriver(SALOME_MED::medDriverTypes driverType, - const char* fileName, const char* meshName) -throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", \ - SALOME::INTERNAL_ERROR); - try - { - int drivernum=_mesh->addDriver( - convertIdlDriverToMedDriver(driverType), - fileName, - meshName); - return drivernum; - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to link the mesh to the driver "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA : Test if this and other aggregate the same MESH using the MESH::operator== - */ -//============================================================================= -CORBA::Boolean GMESH_i::areEquals(SALOME_MED::GMESH_ptr other) -{ - PortableServer::ServantBase *baseServ; - try { - baseServ=_default_POA()->reference_to_servant(other); - } - catch(...){ - baseServ=0; - } - if(baseServ) - { - baseServ->_remove_ref(); - GMESH_i *otherServ=dynamic_cast(baseServ); - return *_mesh==*otherServ->_mesh; - } - return false; -} - -//================================================================================ -/*! - * \brief Converts this GMESH into MESH - */ -//================================================================================ - -SALOME_MED::MESH_ptr GMESH_i::convertInMESH() throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh",SALOME::INTERNAL_ERROR); - - const MESH* mesh = _mesh->convertInMESH(); - MESH_i* mesh_i = new MESH_i( const_cast< MESH*> ( mesh )); - return mesh_i->_this(); -} - diff --git a/src/MEDMEM_I/MEDMEM_GMesh_i.hxx b/src/MEDMEM_I/MEDMEM_GMesh_i.hxx deleted file mode 100644 index cbd699590..000000000 --- a/src/MEDMEM_I/MEDMEM_GMesh_i.hxx +++ /dev/null @@ -1,174 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_GMesh_i.hxx -// Project : SALOME -//============================================================================= -// -#ifndef _MED_GMESH_I_HXX_ -#define _MED_GMESH_I_HXX_ - -#include - -#include -#include - -#include -#include "SALOMEMultiComm.hxx" -#include "SALOME_GenericObj_i.hh" -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) -#include CORBA_SERVER_HEADER(SALOME_Comm) - -namespace MEDMEM { -class GMESH; -class MEDMEM_I_EXPORT GMESH_i: virtual public POA_SALOME_MED::GMESH, - virtual public SALOMEMultiComm, - virtual public SALOME::GenericObj_i -{ -public : - static std::map < int,::MEDMEM::GMESH *> meshMap; -private : - static int meshIndex; - -private : - -protected: - // C++ object containing values - ::MEDMEM::GMESH * const _mesh; - const int _corbaIndex; - std::string _meshId; - - -public: - - // Constructors and associated internal methods - GMESH_i(); - GMESH_i(::MEDMEM::GMESH * const m); - GMESH_i(GMESH_i & m); - ~GMESH_i(); - - // IDL Methods - char * getName() throw (SALOME::SALOME_Exception); - - CORBA::Long getSpaceDimension() throw (SALOME::SALOME_Exception); - - CORBA::Long getMeshDimension() throw (SALOME::SALOME_Exception); - - CORBA::Boolean getIsAGrid() throw (SALOME::SALOME_Exception); - - char * getCoordinatesSystem() - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfString* getCoordinatesNames() - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfString* getCoordinatesUnits() - throw (SALOME::SALOME_Exception); - - CORBA::Long getNumberOfNodes() - throw (SALOME::SALOME_Exception); - - CORBA::Long getNumberOfTypes (SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - SALOME_MED::medGeometryElement_array* getTypes(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - SALOME_MED::medGeometryElement getElementType(SALOME_MED::medEntityMesh entity, - CORBA::Long number) - throw (SALOME::SALOME_Exception); - - - CORBA::Long getNumberOfElements (SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - - - // Family and Group - CORBA::Long getNumberOfFamilies(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfGroups(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - SALOME_MED::Family_array* getFamilies(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - SALOME_MED::FAMILY_ptr getFamily (SALOME_MED::medEntityMesh entity, - CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_MED::Group_array* getGroups(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - SALOME_MED::GROUP_ptr getGroup (SALOME_MED::medEntityMesh entity, - CORBA::Long i) - throw (SALOME::SALOME_Exception); - // - SALOME_MED::SUPPORT_ptr getBoundaryElements(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - SALOME_MED::SUPPORT_ptr getSupportOnAll(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - SALOME_MED::SUPPORT_ptr getSkin (SALOME_MED::SUPPORT_ptr mySupport3D) - throw (SALOME::SALOME_Exception); - // - SALOME_MED::FIELD_ptr getVolume (SALOME_MED::SUPPORT_ptr mySupport) - throw (SALOME::SALOME_Exception); - SALOME_MED::FIELD_ptr getArea (SALOME_MED::SUPPORT_ptr mySupport) - throw (SALOME::SALOME_Exception); - SALOME_MED::FIELD_ptr getLength (SALOME_MED::SUPPORT_ptr mySupport) - throw (SALOME::SALOME_Exception); - SALOME_MED::FIELD_ptr getNormal (SALOME_MED::SUPPORT_ptr mySupport) - throw (SALOME::SALOME_Exception); - SALOME_MED::FIELD_ptr getBarycenter (SALOME_MED::SUPPORT_ptr mySupport) - throw (SALOME::SALOME_Exception); - SALOME_MED::FIELD_ptr getNeighbourhood (SALOME_MED::SUPPORT_ptr mySupport) - throw (SALOME::SALOME_Exception); - - SALOME_MED::MESH_ptr convertInMESH() throw (SALOME::SALOME_Exception); - - // Others - void addInStudy (SALOMEDS::Study_ptr myStudy, - SALOME_MED::GMESH_ptr myIor) - throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection); - void addInStudy (SALOMEDS::Study_ptr myStudy, - SALOME_MED::GMESH_ptr myIor, - const std::string & fileName) - throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection); - CORBA::Long addDriver (SALOME_MED::medDriverTypes driverType, - const char* fileName, const char* meshName) - 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* driverMeshName) - throw (SALOME::SALOME_Exception); - - // Cuisine interne - CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception); - ::MEDMEM::GMESH * constructConstMesh() const; - SALOME_MED::GMESH::meshInfos * getMeshGlobal() - throw (SALOME::SALOME_Exception); - SALOME_MED::GMESH::coordinateInfos * getCoordGlobal() - throw (SALOME::SALOME_Exception); - CORBA::Boolean areEquals(SALOME_MED::GMESH_ptr other); - -}; -} - -#endif /* _MED_MESH_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_Group_i.cxx b/src/MEDMEM_I/MEDMEM_Group_i.cxx deleted file mode 100644 index 52b87056d..000000000 --- a/src/MEDMEM_I/MEDMEM_Group_i.cxx +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Group_i.cxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Group_i.cxx -//============================================================================= -// -#include - -#include "utilities.h" -#include "Utils_CorbaException.hxx" - -#include "MEDMEM_Group_i.hxx" -#include "MEDMEM_Family_i.hxx" - -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Family.hxx" -using namespace MEDMEM; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -GROUP_i::GROUP_i():_group((::GROUP*)NULL) -{ -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -GROUP_i::~GROUP_i() -{ -} -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -GROUP_i::GROUP_i(const ::GROUP * const g):SUPPORT_i(g),_group(g) -{ -} -//============================================================================= -/*! - * Constructor par recopie - */ -//============================================================================= -GROUP_i::GROUP_i(const GROUP_i & g):SUPPORT_i(g._group),_group(g._group) -{ -} -//============================================================================= -/*! - * CORBA: Number of Families existing in the group - */ -//============================================================================= - -CORBA::Long GROUP_i::getNumberOfFamilies() -throw (SALOME::SALOME_Exception) -{ - if (_group==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Group",\ - SALOME::INTERNAL_ERROR); - try - { - return _group->getNumberOfFamilies(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get number of families of the group"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Returns references for families within the group - */ -//============================================================================= - -SALOME_MED::Family_array* GROUP_i::getFamilies() -throw (SALOME::SALOME_Exception) -{ - if (_group==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Group",\ - SALOME::INTERNAL_ERROR); - SALOME_MED::Family_array_var myseq = new SALOME_MED::Family_array; - try - { - int nbfam= _group->getNumberOfFamilies(); - myseq->length(nbfam); - vector fam(nbfam); - fam = _group->getFamilies(); - for (int i=0;i_this(); - } - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access families"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return myseq._retn(); -} -//============================================================================= -/*! - * CORBA: Returns reference for family I within the group - */ -//============================================================================= - -SALOME_MED::FAMILY_ptr GROUP_i::getFamily(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ - if (_group==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Group",\ - SALOME::INTERNAL_ERROR); - try - { - FAMILY * fam=_group->getFamily(i); - FAMILY_i * f1=new FAMILY_i(fam); - return f1->_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces to the specified family"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} diff --git a/src/MEDMEM_I/MEDMEM_Group_i.hxx b/src/MEDMEM_I/MEDMEM_Group_i.hxx deleted file mode 100644 index 867c24436..000000000 --- a/src/MEDMEM_I/MEDMEM_Group_i.hxx +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Group_i.hxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Group_i.hxx -//============================================================================= -// -#ifndef MED_GROUP_I_HXX_ -#define MED_GROUP_I_HXX_ - -#include "MEDMEM_I.hxx" - -#include "MEDMEM_Support_i.hxx" - -namespace MEDMEM { -class FAMILY_i; -class GROUP; - -class MEDMEM_I_EXPORT GROUP_i: - virtual public POA_SALOME_MED::GROUP, - virtual public SUPPORT_i -{ -protected : - GROUP_i(); - ~GROUP_i(); - - // C++ object containing values - const ::MEDMEM::GROUP * const _group; - -public : - // Constructors and associated internal methods - GROUP_i(const ::MEDMEM::GROUP * const g); - GROUP_i(const GROUP_i & g); - - CORBA::Long getNumberOfFamilies() - throw (SALOME::SALOME_Exception); - SALOME_MED::Family_array* getFamilies() - throw (SALOME::SALOME_Exception); - SALOME_MED::FAMILY_ptr getFamily(CORBA::Long i) - throw (SALOME::SALOME_Exception); -}; -} - -#endif /* MED_GROUP_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_I.hxx b/src/MEDMEM_I/MEDMEM_I.hxx deleted file mode 100755 index 7df579495..000000000 --- a/src/MEDMEM_I/MEDMEM_I.hxx +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM_I.hxx -// Author : Alexander A. BORODIN -// Module : MED -// -#ifndef _MEDMEM_I_HXX_ -#define _MEDMEM_I_HXX_ - -#ifdef WIN32 - #if defined MEDMEM_I_EXPORTS || defined MEDMEMImpl_EXPORTS - #if defined WIN32 - #define MEDMEM_I_EXPORT __declspec( dllexport ) - #else - #define MEDMEM_I_EXPORT - #endif - #else - #if defined WIN32 - #define MEDMEM_I_EXPORT __declspec( dllimport ) - #else - #define MEDMEM_I_EXPORT - #endif - #endif -#else - #define MEDMEM_I_EXPORT -#endif - -#endif diff --git a/src/MEDMEM_I/MEDMEM_Med_i.cxx b/src/MEDMEM_I/MEDMEM_Med_i.cxx deleted file mode 100644 index 8bdd5f5f2..000000000 --- a/src/MEDMEM_I/MEDMEM_Med_i.cxx +++ /dev/null @@ -1,909 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Med_i.cxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_i.cxx -//============================================================================= -// -#include - -//#include "MEDMEM_Field.hxx" -#include "MEDMEM_Med_i.hxx" -#include "MEDMEM_Mesh_i.hxx" -#include "MEDMEM_FieldTemplate_i.hxx" -#include "MEDMEM_Support_i.hxx" -#include "MEDMEM_Family_i.hxx" -#include "MEDMEM_Group_i.hxx" -#include "MEDMEM_convert.hxx" - -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Grid.hxx" - -#include "MEDMEM_DriversDef.hxx" -#include "utilities.h" -#include "Utils_CorbaException.hxx" - -using namespace std; -using namespace MEDMEM; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MED_i::MED_i() -{ -} - -//======================================================================= -//function : init -//purpose : * methods -//======================================================================= - -void MED_i::init(SALOMEDS::Study_ptr myStudy,driverTypes /*driverType*/, const string & fileName) -{ - - // we create all IOR from _med - _med.readFileStruct(fileName); - - // MESHES : - vector meshesNames = _med.getMeshNames(); - for (int i=0; i<(int)meshesNames.size(); i++) - { - const MESH * myMesh = 0; - if ( _med.isStructuredMesh( meshesNames[i] )) - myMesh = GRID( MED_DRIVER, fileName, meshesNames[i] ).convertInMESH(); - else - myMesh = new MESH( MED_DRIVER, fileName, meshesNames[i] ); - MESH_i * myMeshI = new MESH_i(const_cast( myMesh )); - SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this(); - _meshes[meshesNames[i]] = myMeshIOR; - _medmem_meshes[meshesNames[i]] = const_cast( myMesh ); - } - - // FAMILIES : - // we add all families - vector familyVector; - vector::iterator familyVectorIt; - // GROUPS : - // we add all groups - vector groupVector; - vector::iterator groupVectorIt; - - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - - // FIELDS : - vector fieldsNames = _med.getFieldNames(); - for (int i=0; i<(int)fieldsNames.size(); i++) - { - string meshName = _med.getMeshName( fieldsNames[i] ); - map::const_iterator name_mesh = _medmem_meshes.find( meshName ); - GMESH* mesh = name_mesh == _medmem_meshes.end() ? (MESH*) 0 : name_mesh->second; - med_type_champ type = _med.getFieldType(fieldsNames[i]); - VEC_DT_IT_ myIteration = _med.getFieldIteration (fieldsNames[i]); - for (int j=0; j<(int)myIteration.size(); j++) - { - SALOME_MED::FIELD_ptr myFieldIOR; - switch (type) - { - case MED_EN::MED_INT32 : - { - FIELD* myField = new FIELD( MED_DRIVER, fileName, fieldsNames[i], - myIteration[j].dt, myIteration[j].it, - mesh); - FIELDTEMPLATE_I *myFieldIntI = new FIELDTEMPLATE_I(myField); - myFieldIOR = myFieldIntI->_this(); - break; - } - - case MED_EN::MED_REEL64: - { - FIELD* myField = new FIELD( MED_DRIVER, fileName, fieldsNames[i], - myIteration[j].dt, myIteration[j].it, - mesh); - FIELDTEMPLATE_I *myFieldDoubleI = new FIELDTEMPLATE_I(myField); - myFieldIOR = myFieldDoubleI->_this(); - break; - } - default: - { - ostringstream stream; - stream << "MED_i::init(driverTypes, const string &)" - <<" * Iteration "< meshesNames = _med.getMeshNames(); - for (int i=0; i<(int)meshesNames.size(); i++) - { - const MESH * myMesh = 0; - if ( _med.isStructuredMesh( meshesNames[i] )) - myMesh = GRID( MED_DRIVER, fileName, meshesNames[i] ).convertInMESH(); - else - myMesh = new MESH( MED_DRIVER, fileName, meshesNames[i] ); - MESH_i * myMeshI = new MESH_i(const_cast( myMesh )); - SALOME_MED::MESH_ptr myMeshIOR = myMeshI->_this(); - _meshes[meshesNames[i]] = myMeshIOR; - _medmem_meshes[meshesNames[i]] = const_cast( myMesh ); - if ( !persistence ) - myMeshI->addInStudy(myStudy,myMeshIOR); - } - - if ( !persistence ) - { - // FAMILIES : - // we add all families in the study - vector familyVector; - vector::iterator familyVectorIt; - // GROUPS : - // we add all groups in the study - vector groupVector; - vector::iterator groupVectorIt; - - MED_EN::MESH_ENTITIES::const_iterator currentEntity; - for (int i=0; i<(int)meshesNames.size(); i++) - { - ::GMESH * ptrMesh = _medmem_meshes[meshesNames[i]]; - - SCRUTE(ptrMesh); - - for (currentEntity = MED_EN::meshEntities.begin(); - currentEntity != MED_EN::meshEntities.end(); - currentEntity++) - { - MESSAGE("initWithFieldType: for entity " << (*currentEntity).first); - // family : - familyVector = ptrMesh->getFamilies((MED_EN::medEntityMesh)(*currentEntity).first); - int nb = familyVector.size(); - MESSAGE("initWithFieldType: there is(are) " << nb << " family(ies)"); - for (familyVectorIt = familyVector.begin(); - familyVectorIt != familyVector.end(); - familyVectorIt++) - { - FAMILY_i * myFamilyI = new FAMILY_i(*familyVectorIt); - SALOME_MED::FAMILY_ptr myFamilyIOR = myFamilyI->_this(); - myFamilyI->addInStudy(myStudy,myFamilyIOR); - } - - // group : - groupVector = ptrMesh->getGroups((MED_EN::medEntityMesh)(*currentEntity).first); - nb = groupVector.size(); - MESSAGE("initWithFieldType: there is(are) " << nb << " group(s)"); - for (groupVectorIt = groupVector.begin(); - groupVectorIt != groupVector.end(); - groupVectorIt++) - { - GROUP_i * myGroupI = new GROUP_i(*groupVectorIt); - SALOME_MED::GROUP_ptr myGroupIOR = myGroupI->_this(); - myGroupI->addInStudy(myStudy,myGroupIOR); - } - } - } - } - - // SUPPORTS on All: - - map > publishedSupportsByMesh; - - map::const_iterator name2mesh = _medmem_meshes.begin(); - for ( ; name2mesh != _medmem_meshes.end(); ++name2mesh ) - { - ::MEDMEM::GMESH* mesh = name2mesh->second; - for ( medEntityMesh entity = 0; entity < MED_ALL_ENTITIES; ++entity ) - { - if ( mesh->getNumberOfElements( entity, MED_ALL_ELEMENTS ) > 0 ) - { - const ::MEDMEM::SUPPORT* sup = mesh->getSupportOnAll( entity ); - SUPPORT_i * mySupportI = new SUPPORT_i( sup ); - SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this(); - try // mySupportI->addInStudy() may throw - { - mySupportI->addInStudy(myStudy,mySupportIOR); - publishedSupportsByMesh[ mesh->getName() ].insert(sup->getName()); - } - catch (...) - { - mySupportIOR->UnRegister(); - } - } - } - } - - // FIELDS : - - vector fieldsNames = _med.getFieldNames(); - for (int i=0; i<(int)fieldsNames.size(); i++) - { - string meshName = _med.getMeshName( fieldsNames[i] ); - map::const_iterator name_mesh = _medmem_meshes.find( meshName ); - GMESH* mesh = name_mesh == _medmem_meshes.end() ? (GMESH*) 0 : name_mesh->second; - - med_type_champ type = _med.getFieldType(fieldsNames[i]); - VEC_DT_IT_ myIteration = _med.getFieldIteration (fieldsNames[i]); - - for (int j=0; j<(int)myIteration.size(); j++) - { - SALOME_MED::FIELD_ptr myFieldIOR; - ::FIELD_ * myField = 0; - switch (type) - { - case MED_EN::MED_INT32 : - { - FIELD* myIntField = new FIELD( MED_DRIVER, fileName, fieldsNames[i], - myIteration[j].dt, myIteration[j].it, - mesh); - FIELDTEMPLATE_I *myFieldIntI = new FIELDTEMPLATE_I(myIntField); - myFieldIOR = myFieldIntI->_this(); - myField = myIntField; - break; - } - - case MED_EN::MED_REEL64: - { - FIELD* myDblField = new FIELD(MED_DRIVER, fileName, fieldsNames[i], - myIteration[j].dt, myIteration[j].it, - mesh); - FIELDTEMPLATE_I *myFieldDoubleI = new FIELDTEMPLATE_I(myDblField); - myFieldIOR = myFieldDoubleI->_this(); - myField = myDblField; - break; - } - default: - { - ostringstream stream; - stream << "MED_i::init(driverTypes, const string &)" - <<" * Iteration "<getSupport()->getName(); - bool supportExists = !publishedSupportsByMesh[ meshName ].insert(supportName).second; - if ( !supportExists ) - { - SUPPORT_i * mySupportI = new SUPPORT_i( myField->getSupport() ); - SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this(); - mySupportI->addInStudy(myStudy,mySupportIOR); - } - } - DT_IT_ dtIt; - dtIt.dt = myIteration[j].dt; - dtIt.it = myIteration[j].it; - _fields[fieldsNames[i]][dtIt] = myFieldIOR; - if ( !persistence ) - myFieldIOR->addInStudy(myStudy,myFieldIOR); - } - } -} - -//======================================================================= -//function : getSupport -//purpose : * \brief Return support -// * \param meshName - name of the mesh the suppotr belongs to -// * \param entity - support entity -// * \retval SALOME_MED::SUPPORT_ptr - found support -// * Raises if support not found -//======================================================================= - -SALOME_MED::SUPPORT_ptr MED_i::getSupport(string meshName, - MED_EN::medEntityMesh entity, - const string name) - throw (SALOME::SALOME_Exception) -{ - // try to find a support of field by a name of support - - const ::MEDMEM::SUPPORT* support = 0; - if ( !name.empty() ) - { - for ( int i = 0; !support && i < (int)_medmem_fields.size(); ++i ) - if ( name == _medmem_fields[i]->getSupport()->getName() && - meshName == _medmem_fields[i]->getSupport()->getMeshName()) - support = _medmem_fields[i]->getSupport(); - if ( !support ) - throw MED_EXCEPTION(STRING("MED_i::getSupport(meshName, entity, supportName) : ") - << "There is no support named |"<< name<<"|" - << " on mesh named |" << meshName << "|"); - } - - if ( !support ) - { - // get support on all elements of given entity - - map::iterator name_mesh = _medmem_meshes.find( meshName ); - if ( name_mesh == _medmem_meshes.end() ) - throw MED_EXCEPTION(STRING("MED_i::getSupport(meshName, entity, supportName) : ") - << "There is no mesh named |" << meshName << "|"); - support = name_mesh->second->getSupportOnAll(entity); - } - if ( ! support ) - throw MED_EXCEPTION(STRING("MED_i::getSupport(meshName, entity, supportName) : ") - << "There is no support on entity " << entity - << " in mesh named |"<< meshName << "|"); - - SUPPORT_i * mySupportI = new SUPPORT_i( support ); - SALOME_MED::SUPPORT_ptr mySupportIOR = mySupportI->_this(); - return mySupportIOR; -} - -//======================================================================= -//function : ~MED_i -//purpose : * Destructor -//======================================================================= - -MED_i::~MED_i() -{ - map::iterator n_m = _medmem_meshes.begin(); - for ( ; n_m != _medmem_meshes.end(); ++ n_m ) - n_m->second->removeReference(); - _medmem_meshes.clear(); - - for ( int i = 0; i < (int)_medmem_fields.size(); ++i ) - _medmem_fields[i]->removeReference(); - _medmem_fields.clear(); -} - -//======================================================================= -//function : getNumberOfMeshes -//purpose : * CORBA: Accessor for Number of meshes -//======================================================================= - -CORBA::Long MED_i::getNumberOfMeshes() -throw (SALOME::SALOME_Exception) -{ - try - { - return _med.getNumberOfMeshes(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the number of meshes in Med Object"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//======================================================================= -//function : getNumberOfFields -//purpose : * CORBA: Accessor for Number of fields -//======================================================================= - -CORBA::Long MED_i::getNumberOfFields() -throw (SALOME::SALOME_Exception) -{ - try - { - return _med.getNumberOfFields(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the number of fields in Med Object"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for meshes names - */ -//============================================================================= -SALOME_TYPES::ListOfString * MED_i::getMeshNames() -throw (SALOME::SALOME_Exception) -{ - SALOME_TYPES::ListOfString_var myseq = new SALOME_TYPES::ListOfString; - try - { - int nbMeshes=_med.getNumberOfMeshes(); - myseq->length(nbMeshes); - string * nameMeshes = new string[nbMeshes]; - _med.getMeshNames(nameMeshes); - for (int i=0;i nameFields = _med.getFieldNames(); - int nbFields = nameFields.size(); - myseq->length(nbFields); - - for (int i=0;i_this(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the specified mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - -} - -//======================================================================= -//function : getMesh -//purpose : * CORBA: Accessor for a specific mesh -//======================================================================= - -SALOME_MED::GMESH_ptr MED_i::getMesh(SALOME_MED::FIELD_ptr fieldPtr) -throw (SALOME::SALOME_Exception) -{ - int ind=fieldPtr->getCorbaIndex(); - SCRUTE(ind); - - SALOME_MED::FIELDINT_var fieldint =SALOME_MED::FIELDINT::_narrow(fieldPtr); - if (CORBA::is_nil(fieldint)) - { - MESSAGE("Double"); - SALOME_MED::FIELDDOUBLE_var fielddouble = - SALOME_MED::FIELDDOUBLE::_narrow(fieldPtr); - ASSERT(!CORBA::is_nil(fielddouble)); - - ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); - - } - else - { - MESSAGE("Integer"); - ASSERT(FIELD_i::fieldMap.find(ind)!=FIELD_i::fieldMap.end()); - } - FIELD_* field = FIELD_i::fieldMap[ind]; - string meshName; - if ( field->getSupport() ) - { - if ( field->getSupport()->getMesh() ) - meshName = field->getSupport()->getMesh()->getName(); - else - field->getSupport()->getMeshName(); - } - SALOME_MED::GMESH_var meshIOR; - if ( _meshes.count( meshName )) - meshIOR = SALOME_MED::GMESH::_duplicate(_meshes[meshName] ); - return meshIOR._retn(); -} - -//======================================================================= -//function : getFieldNumberOfIteration -//purpose : * CORBA: Accessor for Number of iteration of a given field by its name. -//======================================================================= - -CORBA::Long MED_i::getFieldNumberOfIteration(const char* fieldName) - throw (SALOME::SALOME_Exception) -{ - try - { - vector fieldIteration = _med.getFieldIteration(string(fieldName)); - return fieldIteration.size(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the number of iteration of the field " << fieldName << " in Med Object"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for the Corba equivalent DT_IT_ (see MEDMEM direcrtory) - * of a given field by its name and its number (sequence of two long integers). - */ -//============================================================================= -SALOME_TYPES::ListOfLong * MED_i::getFieldIteration(const char* fieldName,CORBA::Long i) - throw (SALOME::SALOME_Exception) -{ - SALOME_TYPES::ListOfLong_var myseq = new SALOME_TYPES::ListOfLong; - try - { - vector fieldIteration = _med.getFieldIteration(string(fieldName)); - int numberOfIteration = fieldIteration.size(); - - if (i < 0 || i >=numberOfIteration) - THROW_SALOME_CORBA_EXCEPTION("The integer i should be geater or equal to 0 and lesser then numberOfIteration", \ - SALOME::INTERNAL_ERROR); - - myseq->length(2); - myseq[0] = fieldIteration[i].dt; - myseq[1] = fieldIteration[i].it; - return myseq._retn(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to get the sequence of DT_IT of the given field"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for the list of Corba equivalent DT_IT_ (see MEDMEM direcrtory) - * of a given field by its name (sequence of two by iteration number long integers). - */ -//============================================================================= -SALOME_TYPES::ListOfLong * MED_i::getFieldIterations(const char* fieldName) - throw (SALOME::SALOME_Exception) -{ - SALOME_TYPES::ListOfLong_var myseq = new SALOME_TYPES::ListOfLong; - try - { - vector fieldIteration = _med.getFieldIteration(string(fieldName)); - int numberOfIteration = fieldIteration.size(); - int size = 2*numberOfIteration; - - myseq->length(size); - - for (int i=0; i::const_iterator itFields = _fields.find(fieldName); - - if ( itFields == _fields.end() ) - THROW_SALOME_CORBA_EXCEPTION("Field not found !", SALOME::INTERNAL_ERROR); - - const MAP_IOR_DT_IT_ & map_dtIt = (*itFields).second; - MAP_IOR_DT_IT_::const_iterator itMap_dtIt = map_dtIt.find(dtIt); - - if ( itMap_dtIt == map_dtIt.end() ) - THROW_SALOME_CORBA_EXCEPTION("Iteration not found !", SALOME::INTERNAL_ERROR); - - return (*itMap_dtIt).second; - -} - -//======================================================================= -//function : addDriver -//purpose : * CORBA: Accessor for a specific field -//======================================================================= - -CORBA::Long MED_i::addDriver(SALOME_MED::medDriverTypes driverType, const char* fileName) -throw (SALOME::SALOME_Exception) -{ - return 0; -} - -//======================================================================= -//function : rmDriver -//purpose : * CORBA: relase the driver (mandatory) -//======================================================================= - -void MED_i::rmDriver(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ -} - -//======================================================================= -//function : readFileStruct -//purpose : * CORBA: read med objects relations -//======================================================================= - -void MED_i::readFileStruct(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ -} - -//======================================================================= -//function : writeFrom -//purpose : * CORBA: write specifics objects f -//======================================================================= - -void MED_i::writeFrom(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ -} - -//======================================================================= -//function : write -//purpose : * CORBA: write objects -//======================================================================= - -void MED_i::write(CORBA::Long i) -throw (SALOME::SALOME_Exception) -{ -} - -//======================================================================= -//function : addMesh -//purpose : * CORBA: Add Mesh in Med objects -//======================================================================= - -void MED_i::addMesh(SALOME_MED::GMESH_ptr ptrMesh) -throw (SALOME::SALOME_Exception) -{ - THROW_SALOME_CORBA_EXCEPTION("MED_i::addMesh() is obsolete method",SALOME::BAD_PARAM); -} - -//======================================================================= -//function : addField -//purpose : * CORBA: Add field in Med objects -//======================================================================= - -void MED_i::addField(SALOME_MED::FIELD_ptr ptrField) -throw (SALOME::SALOME_Exception) -{ - THROW_SALOME_CORBA_EXCEPTION("MED_i::addField() is obsolete method",SALOME::BAD_PARAM); -} - -//======================================================================= -//function : addInStudy -//purpose : * CORBA: Add Med object in Study -//======================================================================= - -void MED_i::addInStudy(SALOMEDS::Study_ptr myStudy, SALOME_MED::MED_ptr myIor) -throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection) -{ - if ( _medId != "" ) - { - MESSAGE("Med already in Study"); - THROW_SALOME_CORBA_EXCEPTION("Med already in Study", \ - SALOME::BAD_PARAM); - }; - - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - myBuilder->NewCommand(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var aIOR; - - // Create SComponent labelled 'MED' if it doesn't already exit - SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); - if ( CORBA::is_nil(medfather) ) - { - THROW_SALOME_CORBA_EXCEPTION("Component Med not found", - SALOME::BAD_PARAM); - }; - - MESSAGE("Add a MED Object under Med"); - SALOMEDS::SObject_var newObj = myBuilder->NewObject(medfather); - - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_var &orb = init(0,0); - CORBA::String_var iorStr = orb->object_to_string(myIor); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.in()); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue("Objet MED"); - _medId = newObj->GetID(); - myBuilder->CommitCommand(); - - // register the Corba pointer: increase the referrence count - MESSAGE("Registering of the Corba Med pointer"); - Register(); - -} - -//============================================================================= -/*! - * CORBA: Add Med object in Study with a name medObjName - * - * FOR PERSISTANCE: if fileName is NULL string, looks for a SObject with a - * suitable name and bad IOR and update the IOR - */ -//============================================================================= -void MED_i::addInStudy (SALOMEDS::Study_ptr myStudy, - SALOME_MED::MED_ptr myIor, - SALOMEDS::SComponent_ptr medfather, - const char * fileName) - throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection) -{ - if ( _medId != "" ) { - MESSAGE("Med already in Study"); - THROW_SALOME_CORBA_EXCEPTION("Med already in Study", SALOME::BAD_PARAM); - }; - - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - myBuilder->NewCommand(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var aIOR; - - // Create SComponent labelled 'MED' if it doesn't already exit - //SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); - if ( CORBA::is_nil(medfather) ) - { - THROW_SALOME_CORBA_EXCEPTION("Component Med not found", - SALOME::BAD_PARAM); - }; - - SALOMEDS::SObject_var medObj; - if ( ! fileName ) - { - // FOR PERSISTANCE: if fileName is a NULL string, - // looks for a SObject with a suitable name and - // bad IOR and update the IOR - SALOMEDS::ChildIterator_var anIter = myStudy->NewChildIterator( medfather ); - for ( ; anIter->More(); anIter->Next()) { - SALOMEDS::SObject_var obj = anIter->Value(); - // check name - CORBA::String_var name = obj->GetName(); - const char* suitableName1 = "MED_OBJECT_FROM_FILE_"; - const char* suitableName2 = "Objet MED"; - if ( strncmp( name, suitableName1, strlen(suitableName1)) == 0 || - strcmp( name, suitableName2 ) == 0 ) { - // check IOR - CORBA::String_var ior = obj->GetIOR(); - if ( strlen( ior ) == 0 ) { - medObj = obj; - break; - } - } - } - if ( medObj->_is_nil() ) - return; // nothing looking like MED found in the study - } - else - { - MESSAGE("Add a MED Object under the medfather"); - - char * medObjName; - string::size_type pos1=string(fileName).rfind('/'); - string::size_type lenFileName = strlen(fileName); - string fileNameShort = string(fileName,pos1+1,lenFileName-pos1-1); - - SCRUTE(fileNameShort); - - int lenName = 21 + strlen(fileNameShort.c_str()) + 1; - medObjName = new char[lenName]; - medObjName = strcpy(medObjName,"MED_OBJECT_FROM_FILE_"); - medObjName = strcat(medObjName,fileNameShort.c_str()); - - string path ("/"); - path += string(medfather->GetName()); - path += string("/"); - path += medObjName; - //string path = string("/Med/") + medObjName; - medObj = myStudy->FindObjectByPath(path.c_str()); - if ( medObj->_is_nil() ) - medObj = myBuilder->NewObject(medfather); - - anAttr = myBuilder->FindOrCreateAttribute(medObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(medObjName); - - delete [] medObjName; - } - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - CORBA::ORB_var &orb = init(0,0); - string iorStr = orb->object_to_string(myIor); - anAttr = myBuilder->FindOrCreateAttribute(medObj, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.c_str()); - - _medId = medObj->GetID(); - myBuilder->CommitCommand(); - - // register the Corba pointer: increase the referrence count - MESSAGE("Registering of the Corba Med pointer"); - Register(); -} diff --git a/src/MEDMEM_I/MEDMEM_Med_i.hxx b/src/MEDMEM_I/MEDMEM_Med_i.hxx deleted file mode 100644 index f38c9b344..000000000 --- a/src/MEDMEM_I/MEDMEM_Med_i.hxx +++ /dev/null @@ -1,134 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Med_i.hxx -// Project : SALOME -// Author : EDF -//============================================================================= -// -#ifndef _MED_MED_I_HXX_ -#define _MED_MED_I_HXX_ - -#include - -#include - -#include - -#include "SALOME_GenericObj_i.hh" -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOMEDS) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - -#include "MEDMEM_MedFileBrowser.hxx" -#include "MEDMEM_GenDriver.hxx" - -namespace MEDMEM { -typedef map MAP_IOR_DT_IT_; - -class GMESH; -class FIELD_; - -class MEDMEM_I_EXPORT MED_i: public POA_SALOME_MED::MED, - public SALOME::GenericObj_i -{ - -private : - -protected: - // C++ object containing values - MEDFILEBROWSER _med; - map _medmem_meshes; - vector< ::MEDMEM::FIELD_* > _medmem_fields; - string _medId; - - map _meshes; // We can't have two MESHes with the same name. - - map > _supports; - - map _fields; // We can't have two FIELDs with the same name. - -public: - // Constructors and associated internal methods - MED_i(); - ~MED_i(); - - // Analyse the file by calling readFileStruct - void init(SALOMEDS::Study_ptr myStudy, driverTypes driverType, const string & fileName); - - // Same method as above but with storage of fields with their type - void initWithFieldType(SALOMEDS::Study_ptr myStudy, driverTypes driverType, - const string & fileName, bool persistence=false); - - void addInStudy(SALOMEDS::Study_ptr myStudy, SALOME_MED::MED_ptr myIor, - SALOMEDS::SComponent_ptr mySComp, const char * medObjName) - throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection); - - SALOME_MED::SUPPORT_ptr getSupport(string meshName, - MED_EN::medEntityMesh entity, - const string name="") - throw (SALOME::SALOME_Exception); - - - // IDL Methods - CORBA::Long getNumberOfMeshes() throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfFields() throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString * getMeshNames() throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfString * getFieldNames() throw (SALOME::SALOME_Exception); - SALOME_MED::GMESH_ptr getMeshByName(const char* meshName) - throw (SALOME::SALOME_Exception); - SALOME_MED::GMESH_ptr getMesh(SALOME_MED::FIELD_ptr fieldPtr) - throw (SALOME::SALOME_Exception); - CORBA::Long getFieldNumberOfIteration(const char* fieldName) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong * getFieldIteration(const char* fieldName, CORBA::Long i) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong * getFieldIterations(const char* fieldName) - throw (SALOME::SALOME_Exception); - SALOME_MED::FIELD_ptr getField(const char* fieldName, - CORBA::Long pasTemps, - CORBA::Long numOrdre) - throw (SALOME::SALOME_Exception); - CORBA::Long addDriver(SALOME_MED::medDriverTypes driverType, - const char* fileName) - throw (SALOME::SALOME_Exception); - void rmDriver(CORBA::Long i) - throw (SALOME::SALOME_Exception); - void readFileStruct(CORBA::Long i) - throw (SALOME::SALOME_Exception); - void writeFrom(CORBA::Long i) - throw (SALOME::SALOME_Exception); - void write(CORBA::Long i) - throw (SALOME::SALOME_Exception); - void addMesh(SALOME_MED::GMESH_ptr ptrMesh) - throw (SALOME::SALOME_Exception); - void addField(SALOME_MED::FIELD_ptr ptrField) - throw (SALOME::SALOME_Exception); - void addInStudy(SALOMEDS::Study_ptr myStudy, - SALOME_MED::MED_ptr myIor) - throw (SALOME::SALOME_Exception, - SALOMEDS::StudyBuilder::LockProtection); -}; -} - -#endif /* _MED_MED_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_Mesh_i.cxx b/src/MEDMEM_I/MEDMEM_Mesh_i.cxx deleted file mode 100644 index f887b62a7..000000000 --- a/src/MEDMEM_I/MEDMEM_Mesh_i.cxx +++ /dev/null @@ -1,504 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Mesh_i.cxx -// Project : SALOME -// Author : EDF -//============================================================================= -// -#include "utilities.h" -#include "Utils_CorbaException.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" - -#include "MEDMEM_convert.hxx" -#include "MEDMEM_Mesh_i.hxx" -#include "MEDMEM_Support_i.hxx" -#include "MEDMEM_Family_i.hxx" -#include "MEDMEM_Group_i.hxx" -#include "MEDMEM_FieldTemplate_i.hxx" - -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_CellModel.hxx" - -#include "SenderFactory.hxx" -#include "MultiCommException.hxx" - -#include - -using namespace MEDMEM; - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -MESH_i::MESH_i():GMESH_i() -{ -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -MESH_i::~MESH_i() -{ -} -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -MESH_i::MESH_i(::MESH * const m ) :GMESH_i(m) -{ -} -//============================================================================= -/*! - * Copy Constructor - */ -//============================================================================= -MESH_i::MESH_i( MESH_i & m) :GMESH_i(m._mesh) -{ -} -//============================================================================= -/*! - * CORBA: boolean indicating if connectivity exists - */ -//============================================================================= -CORBA::Boolean MESH_i::existConnectivity -(SALOME_MED::medConnectivity connectivityType, - SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR); - try - { - return ((::MESH*)_mesh)->existConnectivity(connectivityType, - convertIdlEntToMedEnt(entity)); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces mesh flag existConnectivity"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for a specific coordinate - */ -//============================================================================= -CORBA::Double MESH_i::getCoordinate(CORBA::Long Number, CORBA::Long Axis) - throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR); - try - { - return ((::MESH*)_mesh)->getCoordinate(Number,Axis); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces this coordinate"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: Accessor for Coordinates - */ -//============================================================================= -SALOME_TYPES::ListOfDouble * MESH_i::getCoordinates(SALOME_MED::medModeSwitch typeSwitch) - throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfDouble_var myseq = new SALOME_TYPES::ListOfDouble; - try - { - int spaceDimension=((::MESH*)_mesh)->getSpaceDimension(); - int nbNodes=((::MESH*)_mesh)->getNumberOfNodes(); - const double * coordinates =((::MESH*)_mesh)->getCoordinates( - convertIdlModeToMedMode(typeSwitch)); - - myseq->length(nbNodes*spaceDimension); - for (int i=0; igetSpaceDimension(); - int nbNodes=((::MESH*)_mesh)->getNumberOfNodes(); - const double * coordinates =((::MESH*)_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 connectivities - */ -//============================================================================= -SALOME_TYPES::ListOfLong * MESH_i::getConnectivity(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_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - int nbelements; - int elt1 = ((::MESH*)_mesh)->getNumberOfElements( - convertIdlEntToMedEnt(entity), - convertIdlEltToMedElt(geomElement)); - SCRUTE(elt1); - if ( mode == SALOME_MED::MED_DESCENDING) - { - MESSAGE("MED_DESCENDING"); - int elt2 =(((::MESH*)_mesh)->getCellsTypes(MED_CELL))->getNumberOfConstituents(1); - nbelements= elt2 * elt1; - SCRUTE(elt2); - } - else - { - MESSAGE("MED_NODAL"); - nbelements = ((::MESH*)_mesh)->getConnectivityLength - (convertIdlConnToMedConn(mode), - convertIdlEntToMedEnt(entity), - convertIdlEltToMedElt(geomElement)); - } - SCRUTE(entity); - SCRUTE(geomElement); - SCRUTE(nbelements); - myseq->length(nbelements); - const int * numbers=((::MESH*)_mesh)->getConnectivity(convertIdlConnToMedConn(mode), - convertIdlEntToMedEnt(entity), - convertIdlEltToMedElt(geomElement)); - for (int i=0;igetConnectivityLength(convertIdlConnToMedConn(mode), - convertIdlEntToMedEnt(entity), - convertIdlEltToMedElt(geomElement)); - const int * numbers=((::MESH*)_mesh)->getConnectivity(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 - */ -//============================================================================= -SALOME_TYPES::ListOfLong* MESH_i::getConnectivityIndex(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - int nbelements = ((::MESH*)_mesh)->getNumberOfElements( - convertIdlEntToMedEnt(entity), - MED_ALL_ELEMENTS) + 1; - myseq->length(nbelements); - const int * numbers=((::MESH*)_mesh)->getConnectivityIndex(convertIdlConnToMedConn(mode), - convertIdlEntToMedEnt(entity)); - for (int i=0;igetNumberOfElements( convertIdlEntToMedEnt(entity), - convertIdlEltToMedElt(geomElement)) + 1; - int iType = 0, nbTypes = ((::MESH*)_mesh)->getNumberOfTypes(convertIdlEntToMedEnt(entity)); - const MED_EN::medGeometryElement * types = ((::MESH*)_mesh)->getTypes(convertIdlEntToMedEnt(entity)); - while ( iType < nbTypes && types[iType] != convertIdlEltToMedElt(geomElement)) - ++iType; - int prev_nbelements = ((::MESH*)_mesh)->getGlobalNumberingIndex( convertIdlEntToMedEnt(entity))[iType]-1; - - const int * numbers=((::MESH*)_mesh)->getConnectivityIndex(convertIdlConnToMedConn(mode), - convertIdlEntToMedEnt(entity)) + prev_nbelements; - 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 - */ -//============================================================================= -SALOME_TYPES::ListOfLong* MESH_i::getGlobalNumberingIndex( SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - int nbelements = ((::MESH*)_mesh)->getNumberOfTypes( convertIdlEntToMedEnt(entity)) + 1; - myseq->length(nbelements); - const int * numbers=((::MESH*)_mesh)->getGlobalNumberingIndex( convertIdlEntToMedEnt(entity)); - for (int i=0;igetElementNumber(convertIdlConnToMedConn(mode), - convertIdlEntToMedEnt(entity), - convertIdlEltToMedElt(type), - myConnectivity) ; - } - catch (MEDEXCEPTION &ex) - { - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return result ; -} -//============================================================================= -/*! - * CORBA: Accessor for Ascendant connectivities - * not implemented for MED_ALL_ENTITIES and MED_MAILLE - */ -//============================================================================= -SALOME_TYPES::ListOfLong* MESH_i::getReverseConnectivity(SALOME_MED::medConnectivity mode) - throw (SALOME::SALOME_Exception) -{ - if (_mesh==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Mesh", SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - int nbelements=((::MESH*)_mesh)->getReverseConnectivityLength(convertIdlConnToMedConn(mode)); - SCRUTE(nbelements); - myseq->length(nbelements); - const int * numbers=((::MESH*)_mesh)->getReverseConnectivity(convertIdlConnToMedConn(mode)); - for (int i=0;igetReverseConnectivityIndexLength(convertIdlConnToMedConn(mode)); - myseq->length(nbelements); - const int * numbers=((::MESH*)_mesh)->getReverseConnectivityIndex(convertIdlConnToMedConn(mode)); - for (int i=0;inumberOfNodes = ((::MESH*)_mesh)->getNumberOfNodes(); - - int nbTypes=((::MESH*)_mesh)->getNumberOfTypes(anEntity); - const medGeometryElement * types =((::MESH*)_mesh)->getTypes(anEntity); - all->meshTypes.length(nbTypes); - all->numberOfElements.length(nbTypes); - all->nodalConnectivityLength.length(nbTypes); - all->entityDimension=((::MESH*)_mesh)->getConnectivityptr()->getEntityDimension(); - for (int i=0; imeshTypes[i]=convertMedEltToIdlElt(types[i]); - all->numberOfElements[i]=((::MESH*)_mesh)->getNumberOfElements(anEntity,types[i]); - all->nodalConnectivityLength[i]= - ((::MESH*)_mesh)->getConnectivityLength(MED_EN::MED_NODAL,anEntity,types[i]); - } - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to acces connectivities informations"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return all._retn(); -} diff --git a/src/MEDMEM_I/MEDMEM_Mesh_i.hxx b/src/MEDMEM_I/MEDMEM_Mesh_i.hxx deleted file mode 100644 index aec699678..000000000 --- a/src/MEDMEM_I/MEDMEM_Mesh_i.hxx +++ /dev/null @@ -1,117 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Mesh_i.hxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Mesh_i.hxx -//============================================================================= -// -#ifndef _MED_MESH_I_HXX_ -#define _MED_MESH_I_HXX_ - -#include - -#include -#include - -#include -#include "SALOMEMultiComm.hxx" -#include "SALOME_GenericObj_i.hh" -#include "MEDMEM_GMesh_i.hxx" -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) -#include CORBA_SERVER_HEADER(SALOME_Comm) - -namespace MEDMEM -{ - class MESH; - class MEDMEM_I_EXPORT MESH_i: virtual public POA_SALOME_MED::MESH, - virtual public GMESH_i - { - public: - - // Constructors and associated internal methods - MESH_i(); - MESH_i(::MEDMEM::MESH * const m); - MESH_i(MESH_i & m); - ~MESH_i(); - - // IDL Methods - CORBA::Boolean existConnectivity ( SALOME_MED::medConnectivity connectivityType, - SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfDouble* getCoordinates(SALOME_MED::medModeSwitch typeSwitch) - throw (SALOME::SALOME_Exception); - - SALOME::SenderDouble_ptr getSenderForCoordinates(SALOME_MED::medModeSwitch typeSwitch) - throw (SALOME::SALOME_Exception); - - CORBA::Double getCoordinate(CORBA::Long Number, CORBA::Long Axis) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* getConnectivity(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - - SALOME::SenderInt_ptr getSenderForConnectivity(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* getConnectivityIndex(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - SALOME::SenderInt_ptr getSenderForConnectivityIndex(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* getGlobalNumberingIndex(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - - CORBA::Long getElementNumber(SALOME_MED::medConnectivity mode, - SALOME_MED::medEntityMesh entity, - SALOME_MED::medGeometryElement type, - const SALOME_TYPES::ListOfLong& connectivity) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* getReverseConnectivity(SALOME_MED::medConnectivity mode) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* getReverseConnectivityIndex(SALOME_MED::medConnectivity mode) - throw (SALOME::SALOME_Exception); - - - // Cuisine interne - ::MEDMEM::MESH * constructConstMesh() const; - SALOME_MED::MESH::connectivityInfos * getConnectGlobal (SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); - CORBA::Boolean areEquals(SALOME_MED::MESH_ptr other); - }; -} - -#endif /* _MED_MESH_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_Support_i.cxx b/src/MEDMEM_I/MEDMEM_Support_i.cxx deleted file mode 100644 index 4d9c6c0a5..000000000 --- a/src/MEDMEM_I/MEDMEM_Support_i.cxx +++ /dev/null @@ -1,720 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Support_i.cxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_Support_i.cxx -//============================================================================= -// -#include "utilities.h" -#include "Utils_CorbaException.hxx" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" - -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) - - -#include "MEDMEM_define.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Mesh.hxx" - -#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 -map < int, ::SUPPORT *> SUPPORT_i::supportMap ; -int SUPPORT_i::supportIndex = 0 ; - - -//============================================================================= -/*! - * Default constructor - */ -//============================================================================= -SUPPORT_i::SUPPORT_i() :_support((::SUPPORT *)NULL),_corbaIndex(SUPPORT_i::supportIndex++) -{ -} - -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -SUPPORT_i::SUPPORT_i(const ::SUPPORT * const s) :_support(s), - _corbaIndex(SUPPORT_i::supportIndex++) -{ - if ( _support ) _support->addReference(); - SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support; -} -//============================================================================= -/*! - * Constructor - */ -//============================================================================= -SUPPORT_i::SUPPORT_i(const SUPPORT_i &s) :_support(s._support), - _corbaIndex(SUPPORT_i::supportIndex++) -{ - if ( _support ) _support->addReference(); - SUPPORT_i::supportMap[_corbaIndex]=(::SUPPORT *)_support; -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= - -SUPPORT_i::~SUPPORT_i() -{ - if ( SUPPORT_i::supportMap[_corbaIndex] ) - SUPPORT_i::supportMap[_corbaIndex]->removeReference(); -} -//============================================================================= -/*! - * CORBA: Accessor for Corba Index - */ -//============================================================================= - -CORBA::Long SUPPORT_i::getCorbaIndex() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - return _corbaIndex; -} - -//============================================================================= -/*! - * CORBA: Accessor for Name - */ -//============================================================================= - -char * SUPPORT_i::getName() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - try - { - return CORBA::string_dup(_support->getName().c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access the name of the support "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for Description - */ -//============================================================================= - -char* SUPPORT_i::getDescription() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - try - { - return CORBA::string_dup(_support->getDescription().c_str()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access the description of the support "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for Description and Name - */ -//============================================================================= - -SALOME_MED::SUPPORT::supportInfos * SUPPORT_i::getSupportGlobal() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - SALOME_MED::SUPPORT::supportInfos_var all = new SALOME_MED::SUPPORT::supportInfos; - try - { - all->name = CORBA::string_dup(_support->getName().c_str()); - all->description = CORBA::string_dup(_support->getDescription().c_str()); - const int numberOfTypes = _support->getNumberOfTypes(); - all->numberOfGeometricType = numberOfTypes; - all->entity = _support->getEntity(); - all->isOnAllElements = _support->isOnAllElements(); - all->types.length(numberOfTypes); - all->nbEltTypes.length(numberOfTypes); - all->nodalConnectivityLength.length(numberOfTypes); - const medGeometryElement * types = _support->getTypes(); - const MESH* mesh = _support->getMesh()->convertInMESH(); - for (int i=0;igetNumberOfElements(types[i]); - int connLength = 0; - switch ( types[i] ) - { - case MED_EN::MED_POLYGON: - case MED_EN::MED_POLYHEDRA: -{ - if (_support->isOnAllElements() ) -{ - connLength = mesh->getConnectivityLength(MED_EN::MED_NODAL, - _support->getEntity(),MED_EN::MED_ALL_ELEMENTS); - } - else -{ - const int * index = mesh->getConnectivityIndex(MED_EN::MED_NODAL,_support->getEntity()); - const int * numbers=_support->getNumber(types[i]); - for (int j=0;jtypes[i] = convertMedEltToIdlElt(types[i]); - all->nbEltTypes[i] = nbelements; - all->nodalConnectivityLength[i] = connLength; - } - mesh->removeReference(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access the description of the support "); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } - return all._retn(); -} - - -//============================================================================= -/*! - * CORBA: Accessor for Mesh - */ -//============================================================================= - -SALOME_MED::GMESH_ptr SUPPORT_i::getMesh() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - try - { - const GMESH * mesh = _support->getMesh(); - - SCRUTE(mesh) ; - - GMESH_i * m1 = new GMESH_i(const_cast( mesh )); - SALOME_MED::GMESH_ptr m2 = m1->_this(); - MESSAGE("SALOME_MED::GMESH_ptr SUPPORT_i::getMesh() checking des pointeurs CORBA"); - - SCRUTE(m1); - SCRUTE(m2); - - return (m2); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access the assoicated mesh"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: boolean indicating if support concerns all elements - */ -//============================================================================= - -CORBA::Boolean SUPPORT_i::isOnAllElements() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - try - { - return _support->isOnAllElements(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access the type of the support"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: - */ -//============================================================================= -CORBA::Long SUPPORT_i::getNumberOfTypes() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - try - { - return _support->getNumberOfTypes(); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access number of support different types"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - - -//============================================================================= -/*! - * CORBA: Accessor for type of support's entity - */ -//============================================================================= - -SALOME_MED::medEntityMesh SUPPORT_i::getEntity() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - try - { - return convertMedEntToIdlEnt(_support->getEntity()); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access support s entity"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: Accessor for types of geometry elements - */ -//============================================================================= - -SALOME_MED::medGeometryElement_array * SUPPORT_i::getTypes() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - SALOME_MED::medGeometryElement_array_var myseq = new SALOME_MED::medGeometryElement_array; - try - { - int mySeqLength=_support->getNumberOfTypes(); - myseq->length(mySeqLength); - const medGeometryElement * elemts = _support->getTypes(); - for (int i=0;igetNumberOfElements(convertIdlEltToMedElt(geomElement)); - } - catch (MEDEXCEPTION &ex) - { - MESSAGE("Unable to access the number of support different types"); - THROW_SALOME_CORBA_EXCEPTION(ex.what(), SALOME::INTERNAL_ERROR); - } -} - -//============================================================================= -/*! - * CORBA: get Nodes - */ -//============================================================================= - -SALOME_TYPES::ListOfLong * SUPPORT_i::getNumber(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_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - int nbelements=_support->getNumberOfElements(convertIdlEltToMedElt(geomElement)); - myseq->length(nbelements); - SCRUTE(_support->getName()); - SCRUTE(nbelements); - SCRUTE(convertIdlEltToMedElt(geomElement)); - const int * numbers=_support->getNumber(convertIdlEltToMedElt(geomElement)); - for (int i=0;igetNumberOfElements(convertIdlEltToMedElt(geomElement)); - myseq->length(nbelements); - SCRUTE(_support->getName()); - SCRUTE(nbelements); - SCRUTE(convertIdlEltToMedElt(geomElement)); - const int * numbers=_support->getNumberFromFile(convertIdlEltToMedElt(geomElement)); - for (int i=0;igetNumberOfElements(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) - * CORBA: ?????????????????????????????? - */ -//============================================================================= - -SALOME_TYPES::ListOfLong * SUPPORT_i::getNumberIndex() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - SALOME_TYPES::ListOfLong_var myseq= new SALOME_TYPES::ListOfLong; - try - { - MESSAGE ("Nombre d'elements mis de façon stupide a MED_ALL_ELEMENTS"); - int nbelements=_support->getNumberOfElements(::MED_ALL_ELEMENTS); - myseq->length(nbelements); - const int * numbers=_support->getNumberIndex(); - for (int i=0;igetNumberOfElements(::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: - */ -//============================================================================= - -void SUPPORT_i::getBoundaryElements() - throw (SALOME::SALOME_Exception) -{ - if (_support==NULL) - THROW_SALOME_CORBA_EXCEPTION("No associated Support", SALOME::INTERNAL_ERROR); - try - { - (const_cast< ::SUPPORT *>(_support))->getBoundaryElements(); - } - catch (MEDEXCEPTION &) - { - MESSAGE("Unable to access elements"); - THROW_SALOME_CORBA_EXCEPTION("Unable to acces Support C++ Object", - SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * CORBA: add the Support in the StudyManager - */ -//============================================================================= -void SUPPORT_i::addInStudy (SALOMEDS::Study_ptr myStudy, SALOME_MED::SUPPORT_ptr myIor) - throw (SALOME::SALOME_Exception,SALOMEDS::StudyBuilder::LockProtection) -{ - if ( _supportId != "" ) - { - MESSAGE("Support already in Study"); - THROW_SALOME_CORBA_EXCEPTION("Support already in Study", SALOME::BAD_PARAM); - }; - - if ( CORBA::is_nil(myStudy) ) - { - MESSAGE("Study not found"); - THROW_SALOME_CORBA_EXCEPTION("Study deleted !!!", - SALOME::INTERNAL_ERROR); - } - - - SALOMEDS::StudyBuilder_var myBuilder = myStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var aIOR; - - // Find SComponent labelled 'Med' - MESSAGE(" Find SComponent labelled 'MED'"); - SALOMEDS::SComponent_var medfather = myStudy->FindComponent("MED"); - if ( CORBA::is_nil(medfather) ) - { - MESSAGE("MED not found"); - THROW_SALOME_CORBA_EXCEPTION("SComponent labelled 'Med' not Found",SALOME::INTERNAL_ERROR); - } - - // Find SObject MESH (represent mesh in support) - SALOMEDS::SObject_var medmeshfather = myStudy->FindObjectByPath("/Med/MEDMESH"); - if ( CORBA::is_nil(medmeshfather) ) - { - MESSAGE(" No /Med/MEDMESH Found in study") - THROW_SALOME_CORBA_EXCEPTION("SObject labelled 'MEDMESH' not Found",SALOME::INTERNAL_ERROR); - } - MESSAGE(" Find SObject MESH (represent mesh in support)"); - - string meshName = _support->getMeshName() ; - string meshNameStudy = meshName; - - for (string::size_type pos=0; posFindObject(meshName.c_str()); - if ( CORBA::is_nil(medsupportfather) ) - THROW_SALOME_CORBA_EXCEPTION("SObject Mesh in Support not Found",SALOME::INTERNAL_ERROR); - // perhaps add MESH automatically ? - - MESSAGE("Add a support Object under /Med/MESH/MESHNAME"); - - char * medsupfatherName; - int lenName = 15 + strlen(meshName.c_str()) + 1; - medsupfatherName = new char[lenName]; - medsupfatherName = strcpy(medsupfatherName,"MEDSUPPORTS_OF_"); - medsupfatherName = strcat(medsupfatherName,meshNameStudy.c_str()); - - SCRUTE(medsupfatherName); - - SALOMEDS::SObject_var medsupfather = myStudy->FindObject(medsupfatherName); - if ( CORBA::is_nil(medsupfather) ) - { - MESSAGE("Add Object MEDSUPPORT"); - medsupfather = myBuilder->NewObject(medmeshfather); - anAttr = myBuilder->FindOrCreateAttribute(medsupfather, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(medsupfatherName); -} ; - - //myBuilder->NewCommand(); - - string supportEntryPath = getEntryPath( _support ); - - SALOMEDS::SObject_var supportEntry = myStudy->FindObjectByPath(supportEntryPath.c_str()); - - - - if ( CORBA::is_nil(supportEntry) ) - { - MESSAGE(" supportEntry is a nil corba object and is going to be created"); - // not already in study : we create it ! - SALOMEDS::SObject_var newObj = myBuilder->NewObject(medsupfather); - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init(0,0); - CORBA::String_var iorStr = orb->object_to_string(myIor); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.in()); - anAttr = myBuilder->FindOrCreateAttribute(newObj, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(_support->getName().c_str()); - _supportId = newObj->GetID(); - } - else - { - // already in study : put new AttributeIOR ! - ORB_INIT &init = *SINGLETON_::Instance() ; - ASSERT(SINGLETON_::IsAlreadyExisting()) ; - CORBA::ORB_var &orb = init(0,0); - CORBA::String_var iorStr = orb->object_to_string(myIor); - anAttr = myBuilder->FindOrCreateAttribute(supportEntry, "AttributeIOR"); - aIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aIOR->SetValue(iorStr.in()); - } - myBuilder->CommitCommand(); - - SALOMEDS::SObject_var supportEntryBis = myStudy->FindObjectByPath(supportEntryPath.c_str()); - - MESSAGE("Just for checking, reuse of the corba pointer"); - - if ( CORBA::is_nil(supportEntry) ) - { - MESSAGE("The reuse is OK"); - } - else - { - MESSAGE("well !! the reuse is not OK and there was a problem in the storage in the study"); - } - - delete [] medsupfatherName; - - - // register the Corba pointer: increase the referrence count - MESSAGE("Registering of the Corba Support pointer"); - Register(); -} - -//======================================================================= -//function : getEntryPath -//purpose : -//======================================================================= - -string SUPPORT_i::getEntryPath(const ::MEDMEM::SUPPORT * aSupport) -{ - string meshNameStudy( aSupport->getMeshName() ); - for (string::size_type pos=0; posgetName(); - string supportNameStudy( supportName.c_str(), strlen( supportName.c_str() )); - string supportEntryPath = - "/Med/MEDMESH/MEDSUPPORTS_OF_" + meshNameStudy + "/" + supportNameStudy; - SCRUTE( supportEntryPath ); - - return supportEntryPath; -} diff --git a/src/MEDMEM_I/MEDMEM_Support_i.hxx b/src/MEDMEM_I/MEDMEM_Support_i.hxx deleted file mode 100644 index 379ad1305..000000000 --- a/src/MEDMEM_I/MEDMEM_Support_i.hxx +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_Support_i.hxx -// Project : SALOME -// Author : EDF -// $Header: /export/home/PAL/MED/src/MEDMEM_I/MEDMEM_Support_i.hxx -//============================================================================= -// -#ifndef _MED_SUPPORT_I_HXX_ -#define _MED_SUPPORT_I_HXX_ - -#include "MEDMEM_I.hxx" - -#include -#include - -#include - -#include "SALOMEMultiComm.hxx" -#include "SALOME_GenericObj_i.hh" -#include CORBA_SERVER_HEADER(MED) -#include CORBA_SERVER_HEADER(SALOME_Comm) - -namespace MEDMEM { -class SUPPORT; - -class MEDMEM_I_EXPORT SUPPORT_i: virtual public POA_SALOME_MED::SUPPORT, - virtual public SALOMEMultiComm, - virtual public SALOME::GenericObj_i -{ -public : - static std::map < int,::MEDMEM::SUPPORT *> supportMap; -private : - static int supportIndex; - -protected : - - // C++ object containing values - const ::MEDMEM::SUPPORT * const _support; - const int _corbaIndex ; - std::string _supportId ; - -public: - - SUPPORT_i(); - ~SUPPORT_i(); - - // Constructors and associated internal methods - SUPPORT_i(const ::MEDMEM::SUPPORT * const s); - SUPPORT_i(const SUPPORT_i & s); - - // IDL Methods - char * getName() throw (SALOME::SALOME_Exception); - char * getDescription() throw (SALOME::SALOME_Exception); - SALOME_MED::GMESH_ptr getMesh() throw (SALOME::SALOME_Exception); - CORBA::Boolean isOnAllElements() throw (SALOME::SALOME_Exception); - SALOME_MED::medEntityMesh getEntity() throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfElements(SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfTypes() - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong* getNumber(SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - - SALOME_TYPES::ListOfLong* getNumberFromFile(SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - - SALOME::SenderInt_ptr getSenderForNumber(SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong* getNumberIndex() - throw (SALOME::SALOME_Exception); - SALOME::SenderInt_ptr getSenderForNumberIndex() - throw (SALOME::SALOME_Exception); - CORBA::Long getNumberOfGaussPoint(SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - SALOME_TYPES::ListOfLong* getNumbersOfGaussPoint() - throw (SALOME::SALOME_Exception); - - SALOME_MED::medGeometryElement_array* getTypes() - throw (SALOME::SALOME_Exception); - - void getBoundaryElements() throw (SALOME::SALOME_Exception); - - - // Others - void addInStudy (SALOMEDS::Study_ptr myStudy, - SALOME_MED::SUPPORT_ptr myIor) - throw (SALOME::SALOME_Exception, SALOMEDS::StudyBuilder::LockProtection); - - static std::string getEntryPath (const MEDMEM::SUPPORT * aSupport); - - void release(); - // Cuisine interne - CORBA::Long getCorbaIndex() throw (SALOME::SALOME_Exception); - SALOME_MED::SUPPORT::supportInfos * getSupportGlobal() throw (SALOME::SALOME_Exception); -}; -} - -#endif /* _MED_SUPPORT_I_HXX_ */ diff --git a/src/MEDMEM_I/MEDMEM_TraitsForFields.hxx b/src/MEDMEM_I/MEDMEM_TraitsForFields.hxx deleted file mode 100644 index 6ad5aefb5..000000000 --- a/src/MEDMEM_I/MEDMEM_TraitsForFields.hxx +++ /dev/null @@ -1,124 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEDMEM_TRAITSFORFIELDS_HXX__ -#define __MEDMEM_TRAITSFORFIELDS_HXX__ - -#include CORBA_SERVER_HEADER(MED) -#include "MEDMEM_Tags.hxx" -#include "MEDMEM_InterlacingPolicy.hxx" - -namespace MEDMEM -{ -template < typename T, typename INTERLACING_TAG > -struct FIELDI_TRAITS -{ - typedef typename T::InterfaceForServant InterfaceForServant; - typedef typename T::FieldCorbaPtrType FieldCorbaPtrType; - typedef typename T::SimpleFieldCorbaPtrType SimpleFieldCorbaPtrType; - typedef typename T::SimpleFieldGlobalType SimpleFieldGlobalType; - typedef typename T::SeqType SeqType; - typedef typename T::SeqVarType SeqVarType; - typedef typename T::SenderPtrType SenderPtrType; - typedef typename T::SenderVarType SenderVarType; -}; - -template < > -struct FIELDI_TRAITS -{ - typedef POA_SALOME_MED::FIELDDOUBLEFULL InterfaceForServant; - typedef SALOME_MED::FIELDDOUBLEFULL_ptr FieldCorbaPtrType; - typedef SALOME_MED::FIELDDOUBLE_ptr SimpleFieldCorbaPtrType; - typedef SALOME_MED::FIELDDOUBLE SimpleFieldGlobalType; - typedef SALOME_TYPES::ListOfDouble SeqType; - typedef SALOME_TYPES::ListOfDouble_var SeqVarType; - typedef SALOME::SenderDouble_ptr SenderPtrType; - typedef SALOME::SenderDouble_var SenderVarType; -}; - -template < > -struct FIELDI_TRAITS -{ - typedef POA_SALOME_MED::FIELDDOUBLENO InterfaceForServant; - typedef SALOME_MED::FIELDDOUBLENO_ptr FieldCorbaPtrType; - typedef SALOME_MED::FIELDDOUBLE_ptr SimpleFieldCorbaPtrType; - typedef SALOME_MED::FIELDDOUBLE SimpleFieldGlobalType; - typedef SALOME_TYPES::ListOfDouble SeqType; - typedef SALOME_TYPES::ListOfDouble_var SeqVarType; - typedef SALOME::SenderDouble_ptr SenderPtrType; - typedef SALOME::SenderDouble_var SenderVarType; -}; - -template < > -struct FIELDI_TRAITS -{ - typedef POA_SALOME_MED::FIELDDOUBLENOBYTYPE InterfaceForServant; - typedef SALOME_MED::FIELDDOUBLENOBYTYPE_ptr FieldCorbaPtrType; - typedef SALOME_MED::FIELDDOUBLE_ptr SimpleFieldCorbaPtrType; - typedef SALOME_MED::FIELDDOUBLE SimpleFieldGlobalType; - typedef SALOME_TYPES::ListOfDouble SeqType; - typedef SALOME_TYPES::ListOfDouble_var SeqVarType; - typedef SALOME::SenderDouble_ptr SenderPtrType; - typedef SALOME::SenderDouble_var SenderVarType; -}; - -template < > -struct FIELDI_TRAITS -{ - typedef POA_SALOME_MED::FIELDINTFULL InterfaceForServant; - typedef SALOME_MED::FIELDINTFULL_ptr FieldCorbaPtrType; - typedef SALOME_MED::FIELDINT_ptr SimpleFieldCorbaPtrType; - typedef SALOME_MED::FIELDINT SimpleFieldGlobalType; - typedef SALOME_TYPES::ListOfLong SeqType; - typedef SALOME_TYPES::ListOfLong_var SeqVarType; - typedef SALOME::SenderInt_ptr SenderPtrType; - typedef SALOME::SenderInt_var SenderVarType; -}; - -template < > -struct FIELDI_TRAITS -{ - typedef POA_SALOME_MED::FIELDINTNO InterfaceForServant; - typedef SALOME_MED::FIELDINTNO_ptr FieldCorbaPtrType; - typedef SALOME_MED::FIELDINT_ptr SimpleFieldCorbaPtrType; - typedef SALOME_MED::FIELDINT SimpleFieldGlobalType; - typedef SALOME_TYPES::ListOfLong SeqType; - typedef SALOME_TYPES::ListOfLong_var SeqVarType; - typedef SALOME::SenderInt_ptr SenderPtrType; - typedef SALOME::SenderInt_var SenderVarType; -}; - -template < > -struct FIELDI_TRAITS -{ - typedef POA_SALOME_MED::FIELDINTNOBYTYPE InterfaceForServant; - typedef SALOME_MED::FIELDINTNOBYTYPE_ptr FieldCorbaPtrType; - typedef SALOME_MED::FIELDINT_ptr SimpleFieldCorbaPtrType; - typedef SALOME_MED::FIELDINT SimpleFieldGlobalType; - typedef SALOME_TYPES::ListOfLong SeqType; - typedef SALOME_TYPES::ListOfLong_var SeqVarType; - typedef SALOME::SenderInt_ptr SenderPtrType; - typedef SALOME::SenderInt_var SenderVarType; -}; -} - -#endif diff --git a/src/MEDMEM_I/MEDMEM_convert.cxx b/src/MEDMEM_I/MEDMEM_convert.cxx deleted file mode 100644 index 90126cb7d..000000000 --- a/src/MEDMEM_I/MEDMEM_convert.cxx +++ /dev/null @@ -1,312 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_convert.cxx -// Created : mer fév 20 15:47:57 CET 2002 -// Author : EDF -// Project : SALOME -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_convert.cxx -//============================================================================= -// -#include "utilities.h" -#include "Utils_CorbaException.hxx" - -#include "MEDMEM_convert.hxx" - - -SALOME_MED::medGeometryElement convertMedEltToIdlElt(medGeometryElement element) -throw (SALOME::SALOME_Exception) -{ - switch (element) - { - case MED_NONE : return SALOME_MED::MED_NONE; - case MED_POINT1 : return SALOME_MED::MED_POINT1; - case MED_SEG2 : return SALOME_MED::MED_SEG2; - case MED_SEG3 : return SALOME_MED::MED_SEG3; - case MED_TRIA3 : return SALOME_MED::MED_TRIA3; - case MED_QUAD4 : return SALOME_MED::MED_QUAD4; - case MED_TRIA6 : return SALOME_MED::MED_TRIA6; - case MED_QUAD8 : return SALOME_MED::MED_QUAD8; - case MED_TETRA4 : return SALOME_MED::MED_TETRA4; - case MED_PYRA5 : return SALOME_MED::MED_PYRA5; - case MED_PENTA6 : return SALOME_MED::MED_PENTA6; - case MED_HEXA8 : return SALOME_MED::MED_HEXA8; - case MED_TETRA10 : return SALOME_MED::MED_TETRA10; - case MED_PYRA13 : return SALOME_MED::MED_PYRA13; - case MED_PENTA15 : return SALOME_MED::MED_PENTA15; - case MED_HEXA20 : return SALOME_MED::MED_HEXA20; - case MED_POLYGON : return SALOME_MED::MED_POLYGON; - case MED_POLYHEDRA : return SALOME_MED::MED_POLYHEDRA; - case MED_ALL_ELEMENTS : return SALOME_MED::MED_ALL_ELEMENTS; - default : - { MESSAGE("Unknown Geometry Element"); - THROW_SALOME_CORBA_EXCEPTION("Unknown Geometry Element", - SALOME::INTERNAL_ERROR); - } - } -} - -medGeometryElement convertIdlEltToMedElt(SALOME_MED::medGeometryElement element) -throw (SALOME::SALOME_Exception) -{ - - SCRUTE(element); - - switch (element) - { - case SALOME_MED::MED_NONE : return MED_NONE; - case SALOME_MED::MED_POINT1 : return MED_POINT1; - case SALOME_MED::MED_SEG2 : return MED_SEG2; - case SALOME_MED::MED_SEG3 : return MED_SEG3; - case SALOME_MED::MED_TRIA3 : return MED_TRIA3; - case SALOME_MED::MED_QUAD4 : return MED_QUAD4; - case SALOME_MED::MED_TRIA6 : return MED_TRIA6; - case SALOME_MED::MED_QUAD8 : return MED_QUAD8; - case SALOME_MED::MED_TETRA4 : return MED_TETRA4; - case SALOME_MED::MED_PYRA5 : return MED_PYRA5; - case SALOME_MED::MED_PENTA6 : return MED_PENTA6; - case SALOME_MED::MED_HEXA8 : return MED_HEXA8; - case SALOME_MED::MED_TETRA10 : return MED_TETRA10; - case SALOME_MED::MED_PYRA13 : return MED_PYRA13; - case SALOME_MED::MED_PENTA15 : return MED_PENTA15; - case SALOME_MED::MED_HEXA20 : return MED_HEXA20; - case SALOME_MED::MED_POLYGON : return MED_POLYGON; - case SALOME_MED::MED_POLYHEDRA : return MED_POLYHEDRA; - case SALOME_MED::MED_ALL_ELEMENTS : return MED_ALL_ELEMENTS; - default : - { MESSAGE("unknown Geometry Element"); - THROW_SALOME_CORBA_EXCEPTION("Unknown Geometry Element", - SALOME::INTERNAL_ERROR); - } - } -} - -SALOME_MED::medEntityMesh convertMedEntToIdlEnt(medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - switch (entity) - { - case MED_CELL : return SALOME_MED::MED_CELL; - case MED_FACE : return SALOME_MED::MED_FACE; - case MED_EDGE : return SALOME_MED::MED_EDGE; - case MED_NODE : return SALOME_MED::MED_NODE; - case MED_ALL_ENTITIES : return SALOME_MED::MED_ALL_ENTITIES; - default : - { MESSAGE("Unknown entity element"); - THROW_SALOME_CORBA_EXCEPTION("Unknown Entity Element", - SALOME::INTERNAL_ERROR); - } - } -} - -medEntityMesh convertIdlEntToMedEnt(SALOME_MED::medEntityMesh entity) -throw (SALOME::SALOME_Exception) -{ - switch (entity) - { - case SALOME_MED::MED_CELL : return MED_CELL; - case SALOME_MED::MED_FACE : return MED_FACE; - case SALOME_MED::MED_EDGE : return MED_EDGE; - case SALOME_MED::MED_NODE : return MED_NODE; - case SALOME_MED::MED_ALL_ENTITIES : return MED_ALL_ENTITIES; - default : - { MESSAGE("Unknown Entity Element"); - THROW_SALOME_CORBA_EXCEPTION("Unknown Entity Element", - SALOME::INTERNAL_ERROR); - } - } -} - -medModeSwitch convertIdlModeToMedMode(SALOME_MED::medModeSwitch mode) -throw (SALOME::SALOME_Exception) -{ - switch (mode) - { - case SALOME_MED::MED_FULL_INTERLACE : return MED_FULL_INTERLACE; - case SALOME_MED::MED_NO_INTERLACE : return MED_NO_INTERLACE; - case SALOME_MED::MED_NO_INTERLACE_BY_TYPE : return MED_NO_INTERLACE_BY_TYPE; - default : - { MESSAGE("Unknown interlace mode"); - THROW_SALOME_CORBA_EXCEPTION("Unknown interlace mode", - SALOME::INTERNAL_ERROR); - } - } -} - -SALOME_MED::medModeSwitch convertMedModeToIdlMode(medModeSwitch mode) -throw (SALOME::SALOME_Exception) -{ - switch (mode) - { - case MED_FULL_INTERLACE : return SALOME_MED::MED_FULL_INTERLACE; - case MED_NO_INTERLACE : return SALOME_MED::MED_NO_INTERLACE; - case MED_NO_INTERLACE_BY_TYPE : return SALOME_MED::MED_NO_INTERLACE_BY_TYPE; - default : - { MESSAGE("Unknown interlace mode"); - THROW_SALOME_CORBA_EXCEPTION("Unknown interlace mode", - SALOME::INTERNAL_ERROR); - } - } -} -SALOME_MED::medConnectivity convertMedConnToIdlConn(medConnectivity connectivite) -throw (SALOME::SALOME_Exception) -{ - switch (connectivite) - { - case MED_NODAL : return SALOME_MED::MED_NODAL; - case MED_DESCENDING : return SALOME_MED::MED_DESCENDING; - default : - { MESSAGE("Unknown connectivity type"); - THROW_SALOME_CORBA_EXCEPTION("Unknown connectivity type", - SALOME::INTERNAL_ERROR); - } - } -} -medConnectivity convertIdlConnToMedConn(SALOME_MED::medConnectivity connectivite) -throw (SALOME::SALOME_Exception) -{ - switch (connectivite) - { - case SALOME_MED::MED_NODAL : return MED_NODAL; - case SALOME_MED::MED_DESCENDING : return MED_DESCENDING; - default : - { MESSAGE("Unknown connectivity type"); - THROW_SALOME_CORBA_EXCEPTION("Unknown connectivity type", - SALOME::INTERNAL_ERROR); - } - } -} -SALOME_MED::medDriverTypes convertMedDriverToIdlDriver(MEDMEM::driverTypes driverType) -throw (SALOME::SALOME_Exception) -{ - switch (driverType) - { - case MEDMEM::MED_DRIVER : return SALOME_MED::MED_DRIVER; - case MEDMEM::VTK_DRIVER : return SALOME_MED::VTK_DRIVER; - case MEDMEM::NO_DRIVER : return SALOME_MED::NO_DRIVER; - default : - { MESSAGE("Unknown driver type"); - THROW_SALOME_CORBA_EXCEPTION("Unknown driver type", - SALOME::INTERNAL_ERROR); - } - } -} - -MEDMEM::driverTypes convertIdlDriverToMedDriver(SALOME_MED::medDriverTypes driverType) -throw (SALOME::SALOME_Exception) -{ - switch (driverType) - { - case SALOME_MED::MED_DRIVER : return MEDMEM::MED_DRIVER; - case SALOME_MED::VTK_DRIVER : return MEDMEM::VTK_DRIVER; - case SALOME_MED::NO_DRIVER : return MEDMEM::NO_DRIVER; - default : - { MESSAGE("Unknown driver type"); - THROW_SALOME_CORBA_EXCEPTION("Unknown driver type", - SALOME::INTERNAL_ERROR); - } - } -} -bool verifieParam (SALOME_MED::medEntityMesh entity,SALOME_MED::medGeometryElement geomElement) -throw (SALOME::SALOME_Exception) -{ - SCRUTE(entity); - SCRUTE(geomElement); - bool coherent=false; - switch (entity) - { - case SALOME_MED::MED_FACE : - { - switch (geomElement) - { - case SALOME_MED::MED_TRIA3 : coherent=true; - case SALOME_MED::MED_QUAD4 : coherent=true; - case SALOME_MED::MED_TRIA6 : coherent=true; - case SALOME_MED::MED_QUAD8 : coherent=true; - case SALOME_MED::MED_POLYGON : coherent=true; - } - break; - } - case SALOME_MED::MED_CELL : - { - switch (geomElement) - { - case SALOME_MED::MED_POINT1 : coherent=true; - case SALOME_MED::MED_SEG2 : coherent=true; - case SALOME_MED::MED_SEG3 : coherent=true; - case SALOME_MED::MED_TRIA3 : coherent=true; - case SALOME_MED::MED_TRIA6 : coherent=true; - case SALOME_MED::MED_QUAD4 : coherent=true; - case SALOME_MED::MED_QUAD8 : coherent=true; - case SALOME_MED::MED_TETRA4 : coherent=true; - case SALOME_MED::MED_TETRA10 : coherent=true; - case SALOME_MED::MED_HEXA8 : coherent=true; - case SALOME_MED::MED_HEXA20 : coherent=true; - case SALOME_MED::MED_PENTA6 : coherent=true; - case SALOME_MED::MED_PENTA15 : coherent=true; - case SALOME_MED::MED_PYRA5 : coherent=true; - case SALOME_MED::MED_PYRA13 : coherent=true; - case SALOME_MED::MED_POLYGON : coherent=true; - case SALOME_MED::MED_POLYHEDRA: coherent=true; - } - break; - } - case SALOME_MED::MED_EDGE : - { - switch (geomElement) - { - case SALOME_MED::MED_SEG2 : coherent=true; - case SALOME_MED::MED_SEG3 : coherent=true; - } - break; - } - case SALOME_MED::MED_NODE : - { - switch (geomElement) - { - case SALOME_MED::MED_POINT1 : coherent=true; - } - break; - } - case SALOME_MED::MED_ALL_ENTITIES : - { - switch (geomElement) - { - case SALOME_MED::MED_NONE : coherent=true; - } - break; - } - default : - { MESSAGE("Unknown geometric entity"); - THROW_SALOME_CORBA_EXCEPTION("Unknown geometric entity", - SALOME::INTERNAL_ERROR); - } - break; - } - - switch (geomElement) - { - case SALOME_MED::MED_ALL_ELEMENTS : coherent=true; - } - return coherent; -} diff --git a/src/MEDMEM_I/MEDMEM_convert.hxx b/src/MEDMEM_I/MEDMEM_convert.hxx deleted file mode 100644 index 42c375714..000000000 --- a/src/MEDMEM_I/MEDMEM_convert.hxx +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -//============================================================================= -// File : MEDMEM_convert.hxx -// Created : mer fév 20 15:47:57 CET 2002 -// Author : EDF -// Project : SALOME -// $Header: /export/home/PAL/MED_SRC/src/MEDMEM_I/MEDMEM_convert.hxx -//============================================================================= -// -# if ! defined ( __CONVERT_H__ ) -# define __CONVERT_H__ - -#include "MEDMEM_I.hxx" - -#include -#include CORBA_SERVER_HEADER(MED) -#include "MEDMEM_define.hxx" - -using namespace MED_EN; - -#include "MEDMEM_GenDriver.hxx" - -MEDMEM_I_EXPORT SALOME_MED::medGeometryElement convertMedEltToIdlElt(medGeometryElement element) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT SALOME_MED::medEntityMesh convertMedEntToIdlEnt(medEntityMesh entity) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT SALOME_MED::medModeSwitch convertMedModeToIdlMode(medModeSwitch mode) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT SALOME_MED::medDriverTypes convertMedDriverToIdlDriver(MEDMEM::driverTypes driverType) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT SALOME_MED::medConnectivity convertMedConnToIdlConn(medConnectivity connectivite) - throw (SALOME::SALOME_Exception); - -MEDMEM_I_EXPORT medGeometryElement convertIdlEltToMedElt (SALOME_MED::medGeometryElement element) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT medEntityMesh convertIdlEntToMedEnt(SALOME_MED::medEntityMesh entity) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT medModeSwitch convertIdlModeToMedMode(SALOME_MED::medModeSwitch mode) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT MEDMEM::driverTypes convertIdlDriverToMedDriver(SALOME_MED::medDriverTypes driverType) - throw (SALOME::SALOME_Exception); -MEDMEM_I_EXPORT medConnectivity convertIdlConnToMedConn(SALOME_MED::medConnectivity connectivite) - throw (SALOME::SALOME_Exception); - - -MEDMEM_I_EXPORT bool verifieParam (SALOME_MED::medEntityMesh entity, SALOME_MED::medGeometryElement geomElement) - throw (SALOME::SALOME_Exception); - -# endif /* # if ! defined ( __CONVERT_H__ ) */ diff --git a/src/MEDMEM_I/Makefile.am b/src/MEDMEM_I/Makefile.am deleted file mode 100644 index 5340a2a37..000000000 --- a/src/MEDMEM_I/Makefile.am +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MEDMEM_I : MED idl descriptions implementation based on the classes of MEDMEM -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -lib_LTLIBRARIES= libMEDMEMImpl.la - -salomeinclude_HEADERS= \ - MEDMEM_convert.hxx \ - MEDMEM_Med_i.hxx \ - MEDMEM_Family_i.hxx \ - MEDMEM_FieldTemplate_i.hxx \ - MEDMEM_TraitsForFields.hxx \ - MEDMEM_Field_i.hxx \ - MEDMEM_Group_i.hxx \ - MEDMEM_Mesh_i.hxx \ - MEDMEM_Support_i.hxx \ - MEDMEM_I.hxx \ - MEDMEM_GMesh_i.hxx - -dist_libMEDMEMImpl_la_SOURCES= \ - MEDMEM_Med_i.cxx \ - MEDMEM_Family_i.cxx \ - MEDMEM_Field_i.cxx \ - MEDMEM_Group_i.cxx \ - MEDMEM_Mesh_i.cxx \ - MEDMEM_Support_i.cxx \ - MEDMEM_convert.cxx \ - MEDMEM_GMesh_i.cxx - -libMEDMEMImpl_la_CPPFLAGS= \ - $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) $(MED3_INCLUDES) $(HDF5_INCLUDES) ${KERNEL_CXXFLAGS} \ - -I$(srcdir)/../MEDMEM \ - -I$(top_builddir)/idl \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/GaussPoints \ - -I$(srcdir)/../INTERP_KERNEL - -libMEDMEMImpl_la_LDFLAGS= \ - ../../idl/libSalomeIDLMED.la \ - ../MEDMEM/libmedmem.la \ - ${KERNEL_LDFLAGS} -lSalomeLifeCycleCORBA -lSALOMELocalTrace -lSalomeCommunication -lSalomeGenericObj -lSalomeNS -lOpUtil \ - $(MED3_LIBS_C_ONLY) \ - $(HDF5_LIBS) diff --git a/src/MEDMEM_I/README b/src/MEDMEM_I/README deleted file mode 100644 index 4db505ab6..000000000 --- a/src/MEDMEM_I/README +++ /dev/null @@ -1,15 +0,0 @@ -Users Guide - -1. You can see file med_test2.cxx for an example of using library - -2. To get meshes and fields from an MED file, the simplest way is to create a MED object with argument string filename. It scan MED file to get all meshes and fields in it. After you could say to MED object to read a particular mesh or field and get it with appropriate method of MED object (see MED.hxx and med_test2.cxx) - -3. When you have a Mesh object (or Field object), you could get information in using get_... methods (see Mesh.hxx, Support.hxx, Field.hxx and med_test2.cxx) - -I work on documentation with doxygen tool. - - -Patrick GOLDBRONN -DEN/DM2S/SFME/LGLS -patrick.goldbronn@cea.fr -tel : 0169087355 diff --git a/src/MEDMEM_SWIG/CMakeLists.txt b/src/MEDMEM_SWIG/CMakeLists.txt deleted file mode 100644 index 71f9c2416..000000000 --- a/src/MEDMEM_SWIG/CMakeLists.txt +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(${SWIG_USE_FILE}) - -SET_SOURCE_FILES_PROPERTIES(libMEDMEM_Swig.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(libMEDMEM_Swig.i PROPERTIES SWIG_DEFINITIONS "-shadow") -SET_SOURCE_FILES_PROPERTIES(libMEDMEM_SwigPYTHON_wrap.cxx PROPERTIES COMPILE_FLAGS "${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") - -INCLUDE_DIRECTORIES( - ${PYTHON_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${XDR_INCLUDE_DIRS} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints - ) - -SWIG_ADD_MODULE(libMEDMEM_Swig python libMEDMEM_Swig.i) -SWIG_LINK_LIBRARIES(libMEDMEM_Swig ${PYTHON_LIBS} medmem) -SET_TARGET_PROPERTIES(_libMEDMEM_Swig PROPERTIES COMPILE_FLAGS "${PLATFORM_DEFINITIONS}") - -IF(${MACHINE} STREQUAL WINDOWS) - SET_TARGET_PROPERTIES(_libMEDMEM_Swig PROPERTIES DEBUG_OUTPUT_NAME _libMEDMEM_Swig_d) -ENDIF(${MACHINE} STREQUAL WINDOWS) -INSTALL(TARGETS _libMEDMEM_Swig DESTINATION ${MED_salomepythondir}) - -INSTALL(FILES libMEDMEM_Swig.i my_typemap.i MEDMEM_SWIG_Templates.hxx DESTINATION ${MED_salomeinclude_HEADERS}) -INSTALL(FILES medutilities.py ${CMAKE_CURRENT_BINARY_DIR}/libMEDMEM_Swig.py DESTINATION ${MED_salomepythondir}) -SET(SCRIPTS - medmem.py - med_test1.py - med_test2.py - med_test3.py - med_test_grid.py - med_test_skin.py - medMeshing_test.py - med_field_anal.py - med_opfield_test.py - med_opsupp_test.py - test_gibi.py - test_porflow.py - testDriverAscii.py - testGaussLocalization.py - test_profil_MedFieldDriver.py - testWriteAndFam.py - testMedMemGeneral.py - testMedMemCxxTests.py - dumpMEDMEM.py - ensightMedEnsight_test.py - medEnsightMed_test.py - medNumPy_test.py - med2sauv - sauv2med - avs2med -) -INSTALL(FILES ${SCRIPTS} DESTINATION ${MED_salomescript_PYTHON} - PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) diff --git a/src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx b/src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx deleted file mode 100644 index d6ba3197a..000000000 --- a/src/MEDMEM_SWIG/MEDMEM_SWIG_Templates.hxx +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef MEDMEM_SWIG_TEMPLATES_HXX_ -#define MEDMEM_SWIG_TEMPLATES_HXX_ - -#include "MEDMEM_Exception.hxx" - -#ifdef WITH_NUMPY -#include -#endif - -template - struct Binding { -// static T Checker(PyObject *a); -// static T Traducer(PyObject *a); - }; - -template<> - struct Binding { - //const char *TypeBuild="d"; - static int Checker(PyObject *a) { return PyFloat_Check(a); } - static double Traducer(PyObject *a) { return PyFloat_AsDouble(a); } - static PyObject * Traducer( double value ) { return Py_BuildValue("d", value ); } - static double Functor(PyObject *func, double value) - { return Traducer( PyObject_CallFunction( func, (char *)"f", value )); } -#ifdef WITH_NUMPY - static NPY_TYPES numpy_type() { return NPY_DOUBLE; } -#endif - }; - -template<> - struct Binding { - //const char *TypeBuild="i"; - static int Checker(PyObject *a) { return PyInt_Check(a); } - static int Traducer(PyObject *a) { return (int) PyInt_AsLong(a); } - static PyObject * Traducer( int value ) { return Py_BuildValue("i", value ); } - static int Functor(PyObject *func, int value) - { return Traducer( PyObject_CallFunction( func, (char *)"i", value )); } -#ifdef WITH_NUMPY - static NPY_TYPES numpy_type() { return NPY_INT; } -#endif - }; - -template - class MyFunction { - public: - static PyObject *_pyFunc; - static int _nbOfComponent; - static int _spaceDim; - static void EvalPy2Cpp(const U *coord, T* outputValues) - { - int i=0,err; - PyObject * tuple=PyTuple_New(_spaceDim); - for(i=0;i<_spaceDim;i++) - { - err=PyTuple_SetItem(tuple,i,Binding::Traducer(coord[i])); - if (err != 0) - throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic"); - } - PyObject * function_ret = PyObject_CallObject(_pyFunc,tuple); - if ( !function_ret ) - { - throw MEDMEM::MEDEXCEPTION(MEDMEM::STRING("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (possibly wrong nb of arguments that must be equal to space dimension = ")<< _spaceDim << ")"); - } - err = PyList_Check(function_ret); - if (!err) - { - Py_DECREF(function_ret); - throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (its return value must be a list"); - } - int size=PyList_Size(function_ret); - if (size!=_nbOfComponent) - { - Py_DECREF(function_ret); - throw MEDMEM::MEDEXCEPTION(MEDMEM::STRING("Internal Error in createFieldIntFromAnalytic : the call to the user callable fonction has failed (its return value must be a list of size equal to _nbOfComponent = ") << _nbOfComponent << ")"); - } - for(i=0;i<_nbOfComponent;i++) - { - PyObject * tmp=PyList_GetItem(function_ret,i); - err = Binding::Checker(tmp); - if (!err) - { - Py_DECREF(function_ret); - throw MEDMEM::MEDEXCEPTION("Internal Error in createFieldDoubleFromAnalytic : the call to the user callable fonction has failed (check its return value type)"); - } - outputValues[i]=Binding::Traducer(tmp); - } - } - }; - -template -PyObject *MyFunction::_pyFunc=0; - -template -int MyFunction::_nbOfComponent=0; - -template -int MyFunction::_spaceDim=0; - -#endif diff --git a/src/MEDMEM_SWIG/Makefile.am b/src/MEDMEM_SWIG/Makefile.am deleted file mode 100644 index 35c6bfd16..000000000 --- a/src/MEDMEM_SWIG/Makefile.am +++ /dev/null @@ -1,104 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MEDMEM_SWIG : binding of C++ implementation and Python -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -salomepython_PYTHON = libMEDMEM_Swig.py -salomepyexec_LTLIBRARIES = _libMEDMEM_Swig.la - -salomeinclude_HEADERS = \ - libMEDMEM_Swig.i \ - my_typemap.i \ - MEDMEM_SWIG_Templates.hxx - -if MED_SWIG_1_3_21 -SWIG_DEF = libMEDMEM_Swig.i dummy.i - -dummy_wrap.cxx: libMEDMEM_Swig_wrap.cxx - sed -e 's/SwigValueWrapper< vector >/vector/g' libMEDMEM_Swig_wrap.cxx > toto - mv toto libMEDMEM_Swig_wrap.cxx - sed -e 's/SwigValueWrapper< vector const >/vector/g' libMEDMEM_Swig_wrap.cxx > toto - mv toto libMEDMEM_Swig_wrap.cxx - touch dummy_wrap.cxx -else !MED_SWIG_1_3_21 -SWIG_DEF = libMEDMEM_Swig.i -endif - -SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) - -dist__libMEDMEM_Swig_la_SOURCES = libMEDMEM_Swig.i -nodist__libMEDMEM_Swig_la_SOURCES = libMEDMEM_Swig_wrap.cxx -libMEDMEM_Swig.py: libMEDMEM_Swig_wrap.cxx - -libMEDMEM_Swig_wrap.cxx: $(SWIG_DEF) - $(SWIG) $(SWIG_FLAGS) -o $@ $< - -_libMEDMEM_Swig_la_CPPFLAGS = \ - $(PYTHON_INCLUDES) $(MED3_INCLUDES) $(HDF5_INCLUDES) $(XDR_CPPFLAGS) @CXXTMPDPTHFLAGS@ \ - -I$(srcdir)/../MEDMEM \ - -I$(srcdir)/../INTERP_KERNEL \ - -I$(srcdir)/../INTERP_KERNEL/Bases \ - -I$(srcdir)/../INTERP_KERNEL/GaussPoints - -_libMEDMEM_Swig_la_LDFLAGS = -module $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) $(PYTHON_LIBS) $(XDR_LIBS) \ - ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la - -CLEANFILES = libMEDMEM_Swig_wrap.cxx libMEDMEM_Swig.py - -dist_salomescript_DATA = \ - medmem.py \ - med_test1.py \ - med_test2.py \ - med_test3.py \ - med_test_grid.py \ - med_test_skin.py \ - medMeshing_test.py \ - med_field_anal.py \ - med_opfield_test.py \ - med_opsupp_test.py \ - test_gibi.py \ - test_porflow.py \ - testDriverAscii.py \ - testGaussLocalization.py \ - test_profil_MedFieldDriver.py \ - testWriteAndFam.py \ - testMedMemGeneral.py \ - testMedMemCxxTests.py \ - dumpMEDMEM.py \ - ensightMedEnsight_test.py \ - medEnsightMed_test.py \ - medNumPy_test.py - -dist_salomescript_SCRIPTS = \ - med2sauv \ - sauv2med \ - avs2med - -dist_salomepython_DATA = \ - medutilities.py - -#TESTS = medMeshing_test.py medNumPy_test.py -#TESTS_ENVIRONMENT = $(PYTHON) - -install-data-hook: - @for f in $(dist_salomescript_SCRIPTS) ; do \ - chmod -f a+x $(DESTDIR)$(salomescriptdir)/$$f ; \ - done diff --git a/src/MEDMEM_SWIG/avs2med b/src/MEDMEM_SWIG/avs2med deleted file mode 100755 index cd7f2db28..000000000 --- a/src/MEDMEM_SWIG/avs2med +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# -- -# Copyright (C) 2009-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Erwan ADAM (CEA) -# -- - -from sys import argv -d = argv[0] -from os.path import dirname -d = dirname(d) -from os.path import abspath -d = abspath(d+'/../lib') -from sys import path -if d not in path: - path.insert(0, d) - pass - -from medutilities import avs2med -from sys import argv -avs2med(*argv[1:]) diff --git a/src/MEDMEM_SWIG/dumpMEDMEM.py b/src/MEDMEM_SWIG/dumpMEDMEM.py deleted file mode 100644 index 62acaa3d9..000000000 --- a/src/MEDMEM_SWIG/dumpMEDMEM.py +++ /dev/null @@ -1,496 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -############################################################################ -# This file provides utilities to dump content of MEDMEM objects: mesh, -# field, group, family, nodal connectivity, node coordinates. -############################################################################ -# -from libMEDMEM_Swig import * - -import os - -theEntityName = { MED_CELL :"CELL", - MED_FACE :"FACE", - MED_EDGE :"EDGE", - MED_NODE :"NODE", - MED_ALL_ENTITIES:"ALL_ENTITIES" } - -theTypeName = {MED_NONE :"NONE", - MED_POINT1 :"POINT1", - MED_SEG2 :"SEG2", - MED_SEG3 :"SEG3", - MED_TRIA3 :"TRIA3", - MED_QUAD4 :"QUAD4", - MED_TRIA6 :"TRIA6", - MED_QUAD8 :"QUAD8", - MED_TETRA4 :"TETRA4", - MED_PYRA5 :"PYRA5", - MED_PENTA6 :"PENTA6", - MED_HEXA8 :"HEXA8", - MED_TETRA10 :"TETRA10", - MED_PYRA13 :"PYRA13", - MED_PENTA15 :"PENTA15", - MED_HEXA20 :"HEXA20", - MED_POLYGON :"POLYGON", - MED_POLYHEDRA :"POLYHEDRA", - MED_ALL_ELEMENTS:"ALL_ELEMENTS"} - -medModeSwitch = { 0:"FULL_INTERLACE", - 1:"NO_INTERLACE", - 3:"UNDEFINED_INTERLACE" }; - -med_type_champ = { 6 : "REEL64", - 24: "INT32", - 26: "INT64", - 0 : "UNDEFINED_TYPE" } ; - -tab=" " - -debugShowConn=True -debugShowConn=False - -SHOW_ALL = -1 - -# private -def _showNodalConnectivity(mesh,entity,type,elems,tablevel,showOnly=SHOW_ALL): - if debugShowConn: print "ELEMENTS:",elems - tab1 = tab*tablevel - tab2 = tab*(tablevel+1) - typeName = theTypeName[type] - nbElem = len( elems ) - if showOnly > 0: - elems = elems[:showOnly] - nbShow = len( elems ) - connectivity = mesh.getConnectivity(MED_NODAL,entity,MED_ALL_ELEMENTS) - index = mesh.getConnectivityIndex(MED_NODAL,entity) - if debugShowConn: print "CONN:",connectivity,"\nIND:",index - elemShift = 0 - types = mesh.getTypes( entity ) - for t in types: - if t != type: - elemShift += mesh.getNumberOfElements(entity,t) - else: - break - pass - for i in elems: - elem = i + elemShift - print tab1,typeName,i,":",connectivity[index[elem-1]-1 : index[elem]-1] - pass - nbSkip = nbElem - nbShow - if nbSkip > 0: - print tab1,"...",nbSkip,"elements not shown" - pass - pass - -#private -def _showSupport(support, tablevel,showElems=0): - tab1 = tab*(tablevel+0) - tab2 = tab*(tablevel+1) - tab3 = tab*(tablevel+3) - entity = support.getEntity() - types = support.getTypes() - nbOfTypes = support.getNumberOfTypes() - onAll = support.isOnAllElements() - print tab1,"-Entity:",theEntityName[entity] - print tab1,"-Types :",types - print tab1,"-Elements" - if onAll: - print tab2,"<< Is on all elements >>" - else: - for type in types: - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - number.sort() - print tab2,"* Type:",theTypeName[type] - print tab3,". Nb elements:",nbOfElmtsOfType - print tab3,". Numbers:",number[:min(100,nbOfElmtsOfType)], - if nbOfElmtsOfType > 100: - print "...skip", nbOfElmtsOfType-100 - else: - print - pass - if entity != MED_NODE and showElems: - print tab3,". Nodal connectivity" - _showNodalConnectivity(support.getMesh(),entity,type,number,tablevel+4,showElems) - pass - pass - pass - print - return - -## Dump i-th family of given entity in mesh. -## Optionally dump nodal connectivity of first elements. -## Use showElems=SHOW_ALL to dump connectivity of all elements. - -def ShowFamily(mesh, entity, i, showElems=0): - family = mesh.getFamily(entity,i) - familyName = family.getName() - familyDescription = family.getDescription() - entity = family.getEntity() - familyBool = family.isOnAllElements() - print "\nFAMILY", i, "on", theEntityName[entity] - print tab*1,"-Name :",familyName - print tab*1,"-Description:",familyDescription - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print tab*1,"-Identifier :",familyIdentifier - print tab*1,"-Attributes" - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print tab*2,"* Id :",attributesids[k] - print tab*2,"* Value :",attributesvals[k] - print tab*2,"* Description:",family.getAttributeDescription(k+1) - pass - nbOfGrp = family.getNumberOfGroups() - print tab*1,"-Nb Of Groups:",nbOfGrp - print tab*1,"-Groups:" - for k in range(nbOfGrp): - print tab*2,k+1,":",family.getGroupName(k+1) - pass - _showSupport(family,1,showElems) - return - -## Dump all families in mesh. -## Optionally dump nodal connectivity of first elements of each family. -## Use showElems=SHOW_ALL to dump connectivity of all elements. - -def ShowFamilies(mesh, showElems=0): - line = "families in mesh <" + mesh.getName() + ">" - print "\n",line,"\n","-"*len(line) - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - for i in range(nbFam): - ShowFamily(mesh,entity,i+1,showElems) - pass - print - -## Dump a GROUP. -## Optionally dump nodal connectivity of first elements of the group. -## Use showElems=SHOW_ALL to dump connectivity of all elements. - -def ShowGroup(group, showElems): - groupName = group.getName() - groupDescription = group.getDescription() - nbOfFam = group.getNumberOfFamilies() - print "\nGROUP on",theEntityName[group.getEntity()] - print tab*1,"-Name :",groupName - print tab*1,"-Description :",groupDescription - print tab*1,"-Nb Of Families:",nbOfFam - print tab*1,"-Families" - for k in range(nbOfFam): - print tab*2,k+1,":",group.getFamily(k+1).getName() - pass - _showSupport(group,1,showElems) - return - -## Dump all GROUP's in mesh. -## Optionally dump nodal connectivity of first elements of each group. -## Use showElems=SHOW_ALL to dump connectivity of all elements. - -def ShowGroups(mesh, showElems=0): - line = "groups in mesh <" + mesh.getName() + ">" - print "\n",line,"\n","-"*len(line) - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbGrp = mesh.getNumberOfGroups(entity) - if nbGrp > 0: - for j in range(nbGrp): - group = mesh.getGroup(entity,j+1) - ShowGroup(group,showElems) - pass - pass - pass - -## Dump mesh general information. -## Optionally dump node coordinates of first nodes. -## gives number of elements to dump nodal connectivity by -## entities: [, , ]. -## Use SHOW_ALL to dump all elements or node coordinates. - -def ShowMesh(mesh, nodes2Show=0, entity2Show=[0,0,0]): - print "---------------------- MESH -------------------------" - meshName = mesh.getName() - spaceDim = mesh.getSpaceDimension() - meshDim = mesh.getMeshDimension() - print "The mesh <%s> is a %dD mesh on a %dD geometry" % (meshName,meshDim,spaceDim) - nbNodes = mesh.getNumberOfNodes() - print "There are",nbNodes,"MED_NODE's" - coordSyst = mesh.getCoordinatesSystem() - print "The Coordinates :" - coordNames = [] - coordUnits = [] - for isd in range(spaceDim): - coordNames.append(mesh.getCoordinateName(isd)) - coordUnits.append(mesh.getCoordinateUnit(isd)) - pass - print tab,"system:",coordSyst - print tab,"names:", coordNames - print tab,"units:", coordUnits - ## coordinates - if nodes2Show: - print tab,"values:" - coordinates = mesh.getCoordinates(MED_FULL_INTERLACE) - nbCoord = nodes2Show - maxNbCoord = len( coordinates ) / spaceDim - if nbCoord < 0: nbCoord = maxNbCoord - else: nbCoord = min( nbCoord, maxNbCoord ) - for k in range( nbCoord ): - n = k*spaceDim - print tab*2,k+1,coordinates[n:n+spaceDim] - pass - if nbCoord < maxNbCoord: print tab*2,"... %d nodes skipped" % (maxNbCoord-nbCoord) - pass - # elem types - print "The Elements :" - i = -1 - for entity in [MED_CELL,MED_FACE,MED_EDGE]: - i += 1 - entityName = theEntityName[ entity ] - if mesh.getNumberOfElements(entity,MED_ALL_ELEMENTS) < 1: continue - nbTypes = mesh.getNumberOfTypes( entity ) - try: - types = mesh.getTypes( entity ) - except: - continue - print tab,"%s types:" % entityName - for type in types: - nbElemType = mesh.getNumberOfElements(entity,type) - print tab*2,"%s: \t %d elements" % ( theTypeName[ type ], nbElemType ) - pass - # nodal connectivity - if i >= len( entity2Show ): break - if not entity2Show[ i ]: continue - print tab,"%s nodal connectivity:" % entityName - for type in types: - typeName = theTypeName[ type ] - nbElemType = mesh.getNumberOfElements(entity,type) - if nbElemType == 0: - continue - d = 1 - number = range (d, nbElemType+d) - _showNodalConnectivity(mesh,entity,type,number,2,entity2Show[ i ]) - pass - pass - - print "----------------------Groups, Families-------------------------" - nbF = 0 - nbG = 0 - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - nbGrp = mesh.getNumberOfGroups(entity) - nbElem= mesh.getNumberOfElements(entity, MED_ALL_ELEMENTS); - nbF += nbFam - nbG += nbGrp - if (entity == MED_NODE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)" - if (nbElem> 0) : print "This mesh has",nbElem,"Node Element(s)" - pass - elif (entity == MED_CELL) : - if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)" - if (nbElem> 0) : print "This mesh has",nbElem,"Cell Element(s)" - pass - elif (entity == MED_FACE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)" - if (nbElem> 0) : print "This mesh has",nbElem,"Face Element(s)" - pass - elif (entity == MED_EDGE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)" - if (nbElem> 0) : print "This mesh has",nbElem,"Edge Element(s)" - pass - pass - print "Total nbF", nbF,"nbG",nbG - return - -## Dump all FIELD's in MED. -## Optionally dump first values. -## Use showValues=SHOW_ALL to dump all values. - -def ShowFields( fields, showValues=0 ): - nbFields = len(fields) - print "---------------------- Fields-------------------------" - print "Nb fields", nbFields - for (iField, f ) in enumerate( fields ): - sup = f.getSupport() - name = f.getName() - desc = f.getDescription() - itnb = f.getIterationNumber() - time = f.getTime() - order = f.getOrderNumber() - ftype = f.getValueType() - mode = f.getInterlacingType() - nbcomp = f.getNumberOfComponents() - nbval = f.getNumberOfValues() - nbelem = sup.getNumberOfElements(MED_ALL_ELEMENTS) - nbOfTypes = sup.getNumberOfTypes() - types = sup.getTypes() - isOnAll = sup.isOnAllElements() - print '\nFIELD',iField - print tab*1,'-Name : "%s"' % name - print tab*1,'-Description : "%s"' % desc - print tab*1,'-IterationNumber : %s' % itnb - print tab*1,'-Time : %s' % time - print tab*1,'-OrderNumber : %s' % order - print tab*1,'-Nb Values : %s' % nbval - print tab*1,'-Nb Supp. Elements: %s' % nbelem - print tab*1,'-Nb Componenets : %s' % nbcomp - print tab*1,'-ValueType : %s' % med_type_champ[ftype] - print tab*1,'-Interlace : %s' % medModeSwitch[mode] - print tab*1,'-Conponents' - for k in range(nbcomp): - kp1 = k+1 - compName = f.getComponentName(kp1) - compDesc = f.getComponentDescription(kp1) - compUnit = f.getMEDComponentUnit(kp1) - print tab*2,kp1,'*Name : "%s"' % compName - try: - print tab*2,' *Description: "%s"' % compDesc - except: - print 'INVALID' - pass - try: - print tab*2,' *Unit : "%s"' % compUnit - except: - print 'INVALID' - pass - pass - print tab*1,'-MESH : "%s"' % sup.getMeshName() - print tab*1,'-SUPPORT : "%s"' % sup.getName() - print tab*1,'-On all elements : %s' % bool(isOnAll) - print tab*1,'-Types : %s' % types - - if ftype == MED_REEL64: - if mode == MED_FULL_INTERLACE: - f = createFieldDoubleFromField(f) - else: - f = createFieldDoubleNoInterlaceFromField( f ) - pass - pass - elif ftype == MED_INT32: - if mode == MED_FULL_INTERLACE: - f = createFieldIntFromField(f) - else: - f = createFieldIntNoInterlaceFromField( f ) - pass - pass - else: - print tab*1,'<< Unknown field type >>:',ftype - continue - nbGauss = 1 - hasGauss = False - if nbcomp == 0: - nbGauss = 0 - else: - hasGauss = f.getGaussPresence() - pass - if hasGauss: - nbGaussByType = f.getNumberOfGaussPoints() - pass - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = sup.getNumberOfElements(type) - if hasGauss: nbGauss = nbGaussByType[ k ] - if type == 0: type = MED_POINT1 - print tab*2,k+1,theTypeName[type],':',nbOfElmtsOfType, 'elements,',\ - nbGauss,'gauss point(s)' - pass - nbOf = sup.getNumberOfElements(MED_ALL_ELEMENTS) - elements = [] - if not isOnAll: - elements = sup.getNumber(MED_ALL_ELEMENTS) - pass - if nbcomp == 0: - nbOf = 0 - print tab*1,'-Nb Values :',nbOf - #value = f.getValue(MED_FULL_INTERLACE) - #print value[0: min( 100, len(value)-1 )] - - toShow = min( nbOf, showValues ) - if toShow < 0: toShow = nbOf - for I in range( toShow ): - if elements: - i = elements[ I ] - else: - i = I+1 - if mode == MED_FULL_INTERLACE: - valueI = f.getRow(i) - else: - valueI = [] - for j in range( nbcomp ): - for k in range( f.getNbGaussI( i ) ): - valueI.append( f.getValueIJK(i,j+1,k+1) ) - print ' ',i,' - ',valueI #[:nbcomp] - pass - if nbOf > toShow: - print ' ...skip',nbOf - toShow,'values' - pass - pass - pass - -## Read all fields in MED - -def ReadFields(med): - nbFields = med.getNumberOfFields() - if (nbFields>0): - print 'READ FIELDs ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++' - med.updateSupport() - for i in range(nbFields): - field_name = med.getFieldName(i) - nbOfIt = med.getFieldNumberOfIteration(field_name) - print ' The field is',field_name,'with',nbOfIt,'iteration(s)' - for j in range(nbOfIt): - dtitfield = med.getFieldIteration(field_name,j) - dt = dtitfield.getdt() - it = dtitfield.getit() - field = med.getField(field_name,dt,it) - type = field.getValueType() - print ' * Iteration:',dt,'Order number:',it,'Type:',type - mode = field.getInterlacingType() - if type == MED_INT32: - if mode == MED_FULL_INTERLACE: - fieldint = createFieldIntFromField(field) - else: - fieldint = createFieldIntNoInterlaceFromField( field ) - print ' Reading',fieldint.getName(),'...' - fieldint.read() - elif type == MED_REEL64: - if mode == MED_FULL_INTERLACE: - f = createFieldDoubleFromField(field) - else: - f = createFieldDoubleNoInterlaceFromField( field ) - print ' Reading',f.getName(),'...' - f.read() - else: - print ' !!!! Bad type of Field !!!!' - -# Remove a file if it exists - -def supprimer(f): - if os.access(f, os.F_OK): - os.remove(f) - -# Remove a file if it exists - -def deleteFile( f ): - supprimer( f ) diff --git a/src/MEDMEM_SWIG/ensightMedEnsight_test.py b/src/MEDMEM_SWIG/ensightMedEnsight_test.py deleted file mode 100644 index 2de1c999e..000000000 --- a/src/MEDMEM_SWIG/ensightMedEnsight_test.py +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -############################################################################ -# This script tests conversion of EnSight to MEDMEM by performing following -# operations on all available EnSight files: -# - read EnSight file into MEDMEM and breifly dump it's content; -# - store MEDMEM to med file; -# - write EnSight file in different formats: Gold and EnSight6, ASCII and binary; -# - checks generated EnSight files using ens_checker utility (if available). -# EnSight samples are in EXAMPLES salome CVS repository, in directory SAMPLES_SRC/EnSight. -# DATA_DIR should contain path to SAMPLES_SRC -############################################################################ -# -from medmem import * -from dumpMEDMEM import * -from re import search -import sys - -ASCII = False -Binary = True -formats = [ - (ENSIGHT_GOLD,ASCII) - ,(ENSIGHT_GOLD,Binary) - ,(ENSIGHT_6,ASCII) - ,(ENSIGHT_6,Binary) - ] - -dataDir = os.getenv("DATA_DIR") -tmpDir = os.getenv("TMP") -if not tmpDir: - tmpDir = os.getenv("TMPDIR", "/tmp") - -# EnSight samples are in EXAMPLES CVS repository, in directory SAMPLES_SRC/EnSight. -# DATA_DIR should contain path to SAMPLES_SRC -inDir = os.path.join( dataDir, "EnSight") -if not os.access(inDir, os.F_OK): - raise RuntimeError, "Path to EnSight files not found, check DATA_DIR environment" - -outDir = os.path.join( tmpDir,"Ensight_out") -if not os.access(outDir, os.F_OK): - os.mkdir( outDir ) - pass - -# find out if ens_checker is available -has_ens_checker = False -tmpFile = os.path.join( outDir, "has_ens_checker" ) -os.system("ens_checker _.case > %s 2>&1" % tmpFile) -tmpFile = open( tmpFile ).read() -if search("EnSight Data Format Checker", tmpFile): - has_ens_checker = True -else: - print "\nWarning: ens_checker utility NOT available" - pass - - -dumpMesh = False -dumpMesh = True - -dumpField= False -dumpField= True - -def check_ens(casefile, logfile): - if not has_ens_checker: - return - cmd = "(cd %s; ens_checker %s > %s 2>&1)" % (outDir, casefile, logfile) - err = os.system( cmd ) - if os.access(logfile, os.F_OK): - log = open(logfile).read() - if search("bummer", log): - print log - raise RuntimeError, "cd %s; ens_checker %s" % (outDir, casefile) - if search("Warning:", log): - print log - pass - pass - -def compatibilityPb(): - "Print traceback and return true if exception is due to EnSight-MEDMEM incompatibility" - isCompatibilityPb = ( sys.exc_value.__str__().find("compatibility problem") > 0 ) - if isCompatibilityPb: - print '$$$$$$$$$$$$$$$$$$$$ COMPATIBILITY PROBLEM $$$$$$$$$$$$$$$$$$$$$$$$' - print sys.exc_value, "\n" - else: - import traceback - traceback.print_exc() - return isCompatibilityPb - -from dircache import listdir - -inFiles = [ - "frame.case" -# ,"blow1_bin.case" -# ,"zmat2d_esca.case" -# ,"dyna.case" -# ,"en6.case" -# ,"engold.case" -# ,"engoldup.case" -# ,"frame.case" -# ,"ghost_structured.case" -# ,"ghost_unstructured.case" -# ,"ironProt_ascii.case" -# ,"ironProt_bin.case" -# ,"mandelbrot1.case" -# ,"mandelbrot2.case" -# ,"naca.bin.case" -# ,"office6_bin.case" -# ,"office_ascii.case" -# ,"office_bin.case" -# ,"performance.case" -# ,"range_structured.case" -# ,"x29.case" -# ,"RectGrid_ascii.case" -# ,"RectGrid_bin.case" -# ,"ami.case" -# ,"ami6.case" -# ,"anim.case" -# ,"blow2_ascii.case" -# ,"blow2_bin.case" -# ,"blow3_bin.case" -# ,"blow4_bin.case" -# ,"blow5_ascii.case" -# ,"crash.case" -# ,"cube.case" -# ,"cubeE.case" - ] -inFiles = listdir( inDir ) - - -for inFile in inFiles: # loop on all files in inDir - - # filter .case files - basename, ext = os.path.splitext( inFile ) - if ext != ".case": continue - - # read EnSight into MEDMEM - - setIgnoreIncompatibility(0) - - ensFile = os.path.join( inDir, inFile ) - print "\nreading",ensFile - incompatible = False - meshes = [] - fields = [] - try: - medFromEns = ENSIGHT_MED_RDONLY_DRIVER(ensFile); - fields = medFromEns.read() - if not fields: - mesh = MESH(ENSIGHT_DRIVER,ensFile,""); - meshes.append( mesh ) - else: - meshNames = [] - for f in fields: - mesh = f.getSupport().getMesh() - if mesh and not mesh.getName() in meshNames: - meshes.append( mesh ) - meshNames.append( mesh.getName() ) - pass - pass - pass - pass - except: - if not compatibilityPb(): - sys.exit(1) - else: - continue - - # show MEDMEM contents - mesh = meshes[0] - if dumpMesh: - ShowMesh( mesh, 10, [10,10,10] ) - ShowGroups( mesh ) - pass - if dumpField: - ShowFields( fields, 10 ) - - # write MEDMEM into MED - - medFile = os.path.join( outDir, basename + ".med" ) - deleteFile(medFile) - print "write",medFile - for m in meshes: - m.write( MED_DRIVER,medFile ) - pass - for f in fields: - fTyped = f.castToTypedField() - fTyped.write(MED_DRIVER,medFile) - pass - - # write MEDMEM into EnSight - - for format,bin in formats: - ensFile = os.path.join( outDir, basename ) - if format == ENSIGHT_GOLD: - formatName = "ENSIGHT GOLD" - ensFile += ".g" - else: - formatName = "ENSIGHT 6" - ensFile += '.6' - pass - if bin: - formatName += " Binary" - ensFile += 'b' - else: - formatName += " ASCII" - ensFile += 'a' - pass - ensFile += ".case" - print '*'*80 - print "Format: \t",formatName - print '*'*80 - - setEnSightFormatForWriting( format, bin ) - - print "writting", ensFile - incompatible = False - try: - if fields: - medEnsDriver = ENSIGHT_MED_WRONLY_DRIVER (ensFile, fields) - medEnsDriver.write() - else: - mesh2EnsDriver = ENSIGHT_MESH_WRONLY_DRIVER( ensFile, mesh ) - mesh2EnsDriver.write() - except: - if not compatibilityPb(): - sys.exit(1) - pass - # try to write anayway, maybe it will be ok - incompatible = True - setIgnoreIncompatibility(1) - try: - if fields: - medEnsDriver.write() - else: - mesh2EnsDriver.write() - except: - if not compatibilityPb(): - sys.exit(1) - pass - continue - pass - - # check generated EnSight - try: - checkFile = os.path.join( outDir, basename + ".ens_checker" ) - check_ens(ensFile, checkFile) - except: - if incompatible: - # Ok I was warned about it - continue - sys.exit(1) - pass - pass - print "\n\n\n" - - -# remove created files -for f in listdir( outDir ): - deleteFile( os.path.join( outDir, f )) diff --git a/src/MEDMEM_SWIG/libMEDMEM_Swig.i b/src/MEDMEM_SWIG/libMEDMEM_Swig.i deleted file mode 100644 index 13380262d..000000000 --- a/src/MEDMEM_SWIG/libMEDMEM_Swig.i +++ /dev/null @@ -1,2331 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module libMEDMEM_Swig - -%{ -#include -#include -#include "MEDMEM_CellModel.hxx" -#include "MEDMEM_GenDriver.hxx" -#include "MEDMEM_MedMeshDriver.hxx" -#include "MEDMEM_GibiMeshDriver.hxx" -#include "MEDMEM_PorflowMeshDriver.hxx" -#include "MEDMEM_Connectivity.hxx" -#include "MEDMEM_Group.hxx" -#include "MEDMEM_SkyLineArray.hxx" -#include "MEDMEM_Coordinate.hxx" -#include "MEDMEM_Array.hxx" -#include "MEDMEM_Mesh.hxx" -#include "MEDMEM_define.hxx" -#include "MEDMEM_Exception.hxx" -#include "MEDMEM_STRING.hxx" -#include "MEDMEM_DriversDef.hxx" -#include "MEDMEM_MedFieldDriver.hxx" -#include "MEDMEM_Support.hxx" -#include "MEDMEM_Family.hxx" -#include "MEDMEM_Unit.hxx" -#include "MEDMEM_Field.hxx" -#include "MEDMEM_FieldConvert.hxx" -#include "MEDMEM_Grid.hxx" -#include "MEDMEM_Meshing.hxx" -#include "MEDMEM_DriverFactory.hxx" -#include "MEDMEM_GaussLocalization.hxx" -#include "MEDMEM_EnsightMedDriver.hxx" -#include "MEDMEM_EnsightMeshDriver.hxx" -#include "MEDMEM_EnsightFieldDriver.hxx" -#include "MEDMEM_ArrayInterface.hxx" -#include "MEDMEM_MedFileBrowser.hxx" -#include "PointLocator.hxx" -#include "MEDMEM_VtkMedDriver.hxx" - -#include "MEDMEM_SWIG_Templates.hxx" -#ifdef WITH_NUMPY - template< typename T > - PyObject * TYPEMAP_OUTPUT_PY_ARRAY(const T* value, int size) - { - npy_intp dim = (npy_intp) size; - return PyArray_SimpleNewFromData(1,&dim, Binding::numpy_type(),(T*)value); - } -#endif - - using namespace MEDMEM; - using namespace MED_EN; - using namespace INTERP_KERNEL; - typedef FIELD FIELDDOUBLE; - typedef FIELD FIELDINT; - typedef FIELD FIELDDOUBLENOINTERLACE; - typedef FIELD FIELDINTNOINTERLACE; - typedef FIELD FIELDDOUBLENOINTERLACEBYTYPE; - typedef FIELD FIELDINTNOINTERLACEBYTYPE; - - // to keep old scripts working - typedef enum {MED_LECT=RDONLY, MED_ECRI=WRONLY, MED_REMP=RDWR} med_mode_acces_old; - -%} - -/* - SWIG needs these typedefs to wrap FIELDDOUBLE*, for ex., to something like - instance at _d0709808_p_FIELDDOUBLE>, not to - which has no attributes -*/ - -typedef FIELD FIELDDOUBLE; -typedef FIELD FIELDINT; -typedef FIELD FIELDDOUBLENOINTERLACE; -typedef FIELD FIELDINTNOINTERLACE; -typedef FIELD FIELDDOUBLENOINTERLACEBYTYPE; -typedef FIELD FIELDINTNOINTERLACEBYTYPE; - -%include "typemaps.i" -%include "my_typemap.i" - -%typecheck(SWIG_TYPECHECK_POINTER) double *, const double *, - const double * const, int *, const int *, const int * const, string *, - const string *, const string * const, medGeometryElement *, - const medGeometryElement *, const medGeometryElement * const -{ - $1 = ($input != 0); -} - -/* - mapping between stl string and python string -*/ - -%include "std_string.i" - - -/* - managing C++ exception in the Python API -*/ - -%exception -{ - //class PyAllowThreadsGuard { - // public: - // PyAllowThreadsGuard() { _save = PyEval_SaveThread(); } - // ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); } - // private: - // PyThreadState *_save; - //}; - - try - { - //PyAllowThreadsGuard guard; - $action - } - catch(MEDEXCEPTION& exception) - { - PyErr_SetString(PyExc_RuntimeError,exception.what()); - return NULL; - } -} - -/* - managing the use of operator= of any class by renaming it assign() - because assignment can't be overloaded in python. - - In python, you would then use - - a.assign(b) # a = b -*/ - -%rename(assign) *::operator=; - -/* - typemap in for PyObject * fonction Python wrapping of a - double or int fonction pointeur -*/ - -#if defined(SWIGPYTHON) -%typemap(in) PyObject * double_function, PyObject * integer_function -{ - /* typemap in for double or integer callable fonction pointeur */ - /* Check if it is a callable fonction pointer */ - - if(PyCallable_Check($input) == 0) - { - const char * message = "Error in typemap(python,in) for double or integer callable fonction pointeur : the argument should be a callable object"; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } - - $1 = $input; -} -#endif - -/* - MACRO converting C++ MEDMEM::FIELD_ pointer into a PyObject pointer rightly - casted following its value type (int or double) and its interlacing mode - (FullInterlace or NoInterlace) by calling the function SWIG_NewPointer with - the appropriate $descriptor(...) -*/ - -%define TYPEMAP_OUTPUT_FIELDT(myField) -{ - FIELD_ *arg1=myField; - PyObject *myResult=NULL; - if(arg1) - { - FIELD *try1=dynamic_cast *>(arg1); - if(try1) - myResult = SWIG_NewPointerObj((void *) try1, $descriptor(FIELD *), 0); - else - { - FIELD *try2=dynamic_cast *>(arg1); - if(try2) - myResult = SWIG_NewPointerObj((void *) try2, $descriptor(FIELD *), 0); - else - { - FIELD *try3=dynamic_cast *>(arg1); - if(try3) - myResult = SWIG_NewPointerObj((void *) try3, $descriptor(FIELD *), 0); - else - { - FIELD *try4=dynamic_cast *>(arg1); - if(try4) - myResult = SWIG_NewPointerObj((void *) try4, $descriptor(FIELD *), 0); - else - { - myResult = SWIG_NewPointerObj((void *) arg1, $descriptor(FIELD_ *), 0); - } - } - } - } - } - return myResult; -} -%enddef - -/* - MACRO converting C array of length into a PyList - by calling type_converter() for each array element. - It reports error in in failure case -*/ - -%define TYPEMAP_OUTPUT_ARRAY(arrayvar, size, type_converter, method) -{ - PyObject *py_list = PyList_New(size); - for (int i=0; i < int(size); i++) - { - int err = PyList_SetItem(py_list, i, type_converter( arrayvar[ i ])); - if(err) - { - const char * message = "Error in " #method; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } - } - - PyObject * result = Py_BuildValue("O", py_list); - Py_DECREF(py_list); - return result; -} -%enddef - -/* - Helper function to be used as type_converter in TYPEMAP_OUTPUT_ARRAY -*/ - -%{ - PyObject *PyString_FromStdString(const std::string &str) - { - return PyString_FromString(str.c_str()); - } -%} - -/************************************************** - IN typemaps for some std::vector's -**************************************************/ - -/* MACRO: IN typemap for std::vector C++ object */ -%define TYPEMAP_INPUT_VECTOR_BY_VALUE( TYPE ) -{ - /* typemap in for vector */ - /* Check if is a list */ - if (PyList_Check($input)) - { - int size = PyList_Size($input); - vector< TYPE > tmpVec(size); - - for (int i=0; i < size; i++) - { - PyObject * tmp = PyList_GetItem($input,i); - TYPE elem; - - int err = SWIG_ConvertPtr(tmp, (void **) &elem, $descriptor(TYPE), - SWIG_POINTER_EXCEPTION); - if (err == -1) - { - const char * message = "Error in typemap(python,in) for vector" - "each component should be a TYPE"; - PyErr_SetString(PyExc_RuntimeError, message); - return NULL; - } - tmpVec[i] = elem; - } - $1 = tmpVec; - } - else - { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} -%enddef - -#if defined(SWIGPYTHON) -%typemap(in) vector< FAMILY* >, const vector< FAMILY* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( FAMILY * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(in) vector< SUPPORT* >, const vector< SUPPORT* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( SUPPORT * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(in) vector< FIELDDOUBLE* >, const vector< FIELDDOUBLE* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDDOUBLE * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(in) vector< FIELD_* >, const vector< FIELD_* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELD_ * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(in) vector< const FIELD_* >, const vector< const FIELD_* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( const FIELD_ * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(in) vector< FIELDINT* >, const vector< FIELDINT* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDINT * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(in) vector< FIELDDOUBLENOINTERLACE* >, const vector< FIELDDOUBLENOINTERLACE* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDDOUBLENOINTERLACE * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(in) vector< FIELDINTNOINTERLACE* >, const vector< FIELDINTNOINTERLACE* > -{ TYPEMAP_INPUT_VECTOR_BY_VALUE( FIELDINTNOINTERLACE * ) } -#endif - -/************************************************** - OUT typemaps for some std::vector's -**************************************************/ - -/* MACRO: OUT typemap for std::vector C++ object */ -%define TYPEMAP_OUTPUT_VECTOR_BY_VALUE( TYPE ) -{ - /* typemap out for vector */ - int size = $1.size(); - $result = PyList_New(size); - - for (int i=0;i -{ TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FAMILY * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(out) vector< SUPPORT* > -{ TYPEMAP_OUTPUT_VECTOR_BY_VALUE( SUPPORT * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(out) vector< FIELDDOUBLE* > -{ TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDDOUBLE * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(out) vector< FIELDINT* > -{ TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDINT * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(out) vector< FIELDDOUBLENOINTERLACE* > -{ TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDDOUBLENOINTERLACE * ) } -#endif - -#if defined(SWIGPYTHON) -%typemap(out) vector< FIELDINTNOINTERLACE* > -{ TYPEMAP_OUTPUT_VECTOR_BY_VALUE( FIELDINTNOINTERLACE * ) } -#endif - - -/* - enum of the C++ MED used in the Python API -*/ - -typedef enum {MED_CARTESIAN, MED_POLAR, MED_BODY_FITTED} med_grid_type; - -typedef enum {MED_FULL_INTERLACE, MED_NO_INTERLACE} medModeSwitch; - -typedef enum {RDONLY, WRONLY, RDWR} med_mode_acces; -typedef enum {MED_LECT, MED_ECRI, MED_REMP} med_mode_acces_old;// to keep old scripts working - -typedef enum {ASCENDING=7,DESCENDING=77} med_sort_direc; - -typedef enum {MED_CELL, MED_FACE, MED_EDGE, MED_NODE, - MED_ALL_ENTITIES} medEntityMesh; - -typedef enum {MED_NONE=0, MED_POINT1=1, MED_SEG2=102, MED_SEG3=103, - MED_TRIA3=203, MED_QUAD4=204, MED_TRIA6=206, MED_QUAD8=208, - MED_TETRA4=304, MED_PYRA5=305, MED_PENTA6=306, - MED_HEXA8=308, MED_TETRA10=310, MED_PYRA13=313, - MED_PENTA15=315, MED_HEXA20=320, MED_POLYGON = 400, MED_POLYHEDRA = 500, - MED_ALL_ELEMENTS=999} medGeometryElement; - -typedef enum {MED_NODAL, MED_DESCENDING} medConnectivity ; - -typedef enum {MED_DRIVER=0, GIBI_DRIVER=1, PORFLOW_DRIVER = 2, VTK_DRIVER=254, - NO_DRIVER=255, ASCII_DRIVER = 3, ENSIGHT_DRIVER = 250 } driverTypes; - -typedef enum {MED_REEL64=6, MED_INT32=24, MED_INT64=26} med_type_champ; - -typedef struct { int dt; int it; } DT_IT_; - -typedef enum {V21 = 26, V22 = 75} medFileVersion; - -%feature("unref") SUPPORT "$this->removeReference();" -%feature("unref") GMESH "$this->removeReference();" -%feature("unref") MESH "$this->removeReference();" -%feature("unref") FIELDDOUBLE "$this->removeReference();" -%feature("unref") FIELDINT "$this->removeReference();" -%feature("unref") FIELDDOUBLENOINTERLACE "$this->removeReference();" -%feature("unref") FIELDINTNOINTERLACE "$this->removeReference();" -%feature("unref") FIELDDOUBLENOINTERLACEBYTYPE "$this->removeReference();" -%feature("unref") FIELDINTNOINTERLACEBYTYPE "$this->removeReference();" - -%extend DT_IT_ { - int getdt() - { - return self->dt; - } - - int getit() - { - return self->it; - } -} - -%typecheck(SWIG_TYPECHECK_POINTER) vector< SUPPORT * >, const vector< SUPPORT * >, vector< const FIELD_* > -{ - $1 = ($input != 0); -} - -/* - Class et methodes du MED++ que l'on utilise dans l'API Python -*/ - -class CELLMODEL -{ - public: - CELLMODEL(); - - CELLMODEL(medGeometryElement t); - - CELLMODEL(const CELLMODEL &m); - - int getNumberOfVertexes(); - - int getNumberOfNodes(); - - int getDimension(); - - medGeometryElement getType(); - - int getNumberOfConstituents(int dim); - - int getNodeConstituent(int dim,int num,int nodes_index); - - medGeometryElement getConstituentType(int dim,int num); - - int getNumberOfConstituentsType(); - - std::string getName() const; - - ~CELLMODEL(); - - %extend { - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing CELLMODEL : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class SUPPORT -{ - public: - SUPPORT(); - - SUPPORT(const SUPPORT & m); - - ~SUPPORT(); - - void update ( void ); - - MESH * getMesh() const; - - std::string getMeshName() const; - - void setMesh(MESH * Mesh) const; - - medEntityMesh getEntity() const; - - void setEntity(medEntityMesh Entity); - - bool isOnAllElements() const; - - void setAll(bool All); - - int getNumberOfTypes() const; - - void setNumberOfGeometricType(int NumberOfGeometricType); - - int getNumberOfElements(medGeometryElement GeometricType) const; - - void setGeometricType(medGeometryElement *GeometricType); - - void setNumberOfElements(int *NumberOfElements); - - void getBoundaryElements(); - - void setNumber(const int * index, const int* value); - - bool deepCompare(const SUPPORT &support) const; - - void setpartial(std::string Description, int NumberOfGeometricType, - int TotalNumberOfElements, medGeometryElement *GeometricType, - int *NumberOfElements, int *NumberValue); - - std::string getName() const; - - void setName(std::string Name); - - std::string getDescription(); - - void setDescription(std::string Description); - - MESH* makeMesh(); - - SUPPORT* buildSupportOnNode(); - - %extend { - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing SUPPORT : " << *self << endl; - char * tmp = const_cast (mess.str().c_str()); - char * returned = strdup(tmp); - return returned; - } - - PyObject * getTypes() - { - const medGeometryElement * types = self->getTypes(); - int size = self->getNumberOfTypes(); - TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, SUPPORT::getTypes); - } - - PyObject * getNumber(medGeometryElement GeometricType) - { - const int * number = self->getNumber(GeometricType); - int size = self->getNumberOfElements(GeometricType); - TYPEMAP_OUTPUT_ARRAY(number, size, PyInt_FromLong, - SUPPORT::getNumber); - } - - PyObject * getNumberIndex() - { - const int * numberindex = self->getNumberIndex(); - int size = (self->getNumberOfTypes())+1; - TYPEMAP_OUTPUT_ARRAY(numberindex, size, PyInt_FromLong, - SUPPORT::getNumberIndex); - } - - %newobject getComplement() const; - SUPPORT *getComplement() const - { - return self->getComplement(); - } - - %newobject substract(const SUPPORT& other) const; - SUPPORT *substract(const SUPPORT& other) const - { - return self->substract(other); - } - - %newobject getBoundaryElements(medEntityMesh Entity) const; - SUPPORT *getBoundaryElements(medEntityMesh Entity) const - { - return self->getBoundaryElements(Entity); - } - } -}; - -class FAMILY : public SUPPORT -{ - public: - FAMILY(); - - FAMILY(const FAMILY & m); - - ~FAMILY(); - - FAMILY & operator=(const FAMILY &fam); - - void setIdentifier(int Identifier); - - void setNumberOfAttributes(int NumberOfAttribute); - - void setAttributesIdentifiers(int * AttributeIdentifier); - - void setAttributesValues(int * AttributeValue); - - void setAttributesDescriptions(std::string * AttributeDescription); - - void setNumberOfGroups(int NumberOfGroups); - - void setGroupsNames(std::string * GroupName); - - int getIdentifier() const; - - int getNumberOfAttributes() const; - - int getNumberOfGroups() const; - - FAMILY(MESH* Mesh, int Identifier, std::string Name, int NumberOfAttribute, - int *AttributeIdentifier, int *AttributeValue, - std::string AttributeDescription, int NumberOfGroup, - std::string GroupName, int * MEDArrayNodeFamily, - int ** MEDArrayCellFamily, int ** MEDArrayFaceFamily, - int ** MEDArrayEdgeFamily); - - std::string getAttributeDescription(int i); - - std::string getGroupName(int i); - - %extend { - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing Family : " << *self << endl; - return strdup(mess.str().c_str()); - } - - PyObject * getAttributesIdentifiers() - { - const int * attributesids = self->getAttributesIdentifiers(); - int size = self->getNumberOfAttributes(); - TYPEMAP_OUTPUT_ARRAY(attributesids,size,PyInt_FromLong, - FAMILY::getAttributesIdentifiers); - } - - PyObject * getAttributesValues() - { - const int * attributesvals = self->getAttributesValues(); - int size = self->getNumberOfAttributes(); - TYPEMAP_OUTPUT_ARRAY(attributesvals,size,PyInt_FromLong, - FAMILY::getAttributesValues); - } - } -}; - -class GENDRIVER -{ - GENDRIVER(); -public: - void open(); - void write(); - void read (); - void close(); - - std::string getFileName () const; - void setFileName ( const std::string & fileName); - - void setMeshName ( const std::string & meshName); - std::string getMeshName(); - - void setFieldName ( const std::string & fieldName); - std::string getFieldName() const; - -}; - -class FIELD_ -{ -public: - FIELD_(const SUPPORT * Support, const int NumberOfComponents); - - ~FIELD_(); - - void rmDriver(int index=0); - - void read (driverTypes driverType, const std::string & fileName); - void read (const GENDRIVER &); - void read(int index=0); - - void write(const GENDRIVER& driver, med_mode_acces medMode=RDWR); - void write(driverTypes driverType, const char* filename, - med_mode_acces medMode=RDWR); - void write(int index=0); - - void writeAppend(int index=0, const std::string& driverName=""); - - void setIterationNumber (int IterationNumber); - int getIterationNumber() const; - - void setTime(double Time); - double getTime() const; - - void setOrderNumber (int OrderNumber); - int getOrderNumber() const; - - med_type_champ getValueType() ; - - medModeSwitch getInterlacingType(); - - SUPPORT * getSupport(); - void setSupport(SUPPORT * support); - - void setNumberOfComponents(int NumberOfComponents); - int getNumberOfComponents() const; - - void setNumberOfValues(int NumberOfValues); - int getNumberOfValues() const; - - std::string getName() const; - - std::string getDescription() const; - - std::string getComponentName(int i) const; - - std::string getComponentDescription(int i) const; - - std::string getMEDComponentUnit(int i) const; - - void setName(std::string Name); - - void setComponentName(int i, std::string ComponentName); - - void setMEDComponentUnit(int i, std::string MEDComponentUnit); - - void setDescription(std::string Description); - - void setComponentDescription(int i, std::string ComponentDescription); - - int addDriver(driverTypes driverType, - const std::string& fileName="Default File Name.med", - const std::string& driverName="Default Field Name", - med_mode_acces access=RDWR); - - %extend { - %newobject getSupportAndOwner(); - SUPPORT * getSupportAndOwner() - { - return (SUPPORT *)self->getSupport(); - } - PyObject* castToTypedField() - { - if ( self->getValueType() == MED_REEL64 ) - switch( self->getInterlacingType() ) { - case MED_FULL_INTERLACE: - return SWIG_NewPointerObj((void *)self, $descriptor(FIELDDOUBLE *), 0); - case MED_NO_INTERLACE: - return SWIG_NewPointerObj((void *)self, $descriptor(FIELDDOUBLENOINTERLACE *), 0); - case MED_NO_INTERLACE_BY_TYPE: - return SWIG_NewPointerObj((void *)self, $descriptor(FIELDDOUBLENOINTERLACEBYTYPE *), 0); - default: - PyErr_SetString(PyExc_RuntimeError,"Invalid interlacing type of a field"); - return NULL; - } - else - switch( self->getInterlacingType() ) { - case MED_FULL_INTERLACE: - return SWIG_NewPointerObj((void *)self, $descriptor(FIELD *), 0); - case MED_NO_INTERLACE: - return SWIG_NewPointerObj((void *)self, $descriptor(FIELD *), 0); - case MED_NO_INTERLACE_BY_TYPE: - return SWIG_NewPointerObj((void *)self, $descriptor(FIELD *), 0); - default: - PyErr_SetString(PyExc_RuntimeError,"Invalid interlacing type of a field"); - return NULL; - } - return NULL; - } - } -}; - -/* - Class FIELD has now two template parameters: T1 is a double or an int, - INTERLACING_TAG is FullInterlace or NoInterlace -*/ - -template class FIELD : public FIELD_ -{ -public: - ~FIELD(); - - FIELD(const SUPPORT * Support, const int NumberOfComponents); - - FIELD(); - - FIELD(const FIELD & m); - - FIELD(const SUPPORT * Support, driverTypes driverType, - const std::string& fileName, const std::string& fieldName, - const int iterationNumber, const int orderNumber); - - FIELD(driverTypes driverType, const char* fileName, const char* fieldName, - int iterationNumber, int orderNumber, GMESH* mesh=0); - - T1 getValueIJ(int i,int j) const; - - T1 getValueIJK(int i,int j, int k) const; - - T1 getValueIJByType(int i,int j, int type) const; - - T1 getValueIJKByType(int i,int j, int k, int type) const; - - void setValue(T1* value); - - void setRow( int i, T1 * value); - - void setColumn( int i, T1 * value); - - void setValueIJ(int i, int j, T1 value); - - void setValueIJK(int i, int j, int k, T1 value); - - void setValueIJByType(int i, int j, int type, T1 value); - - void setValueIJKByType(int i, int j, int k, int type, T1 value); - - void allocValue(const int NumberOfComponents); - - void deallocValue(); - - void applyLin(T1 a, T1 n); - - void applyPow(T1 scalar); - - double normMax(); - - double norm2(); - - double normL2(int component,const FIELD * - p_field_volume=NULL) const; - - double normL2(const FIELD * - p_field_volume=NULL) const; - - double normL1(int component, const FIELD * - p_field_volume=NULL) const; - - double normL1(const FIELD * - p_field_volume=NULL) const; - - double integral(const SUPPORT* subSupport=0); - - bool getGaussPresence(); - - GAUSS_LOCALIZATION * getGaussLocalizationPtr(medGeometryElement geomElement); - - int getNbGaussI(int i); - - %extend { - - /*! - * \brief create a field with default gauss localizations - */ - FIELD(const SUPPORT * support, const int numberOfComponents, const int* nbGaussByType) - { - FIELD* f = new FIELD(support,numberOfComponents); - - int nbtypegeo = support->getNumberOfTypes(); - vector nbelgeoc (nbtypegeo+1,0); - const int * nbElemByType = support->getNumberOfElements(); - for (int iType = 0; iType < nbtypegeo; ++iType) - { - nbelgeoc [ iType+1 ] = nbelgeoc[ iType ] + nbElemByType[ iType ]; - MED_EN::medGeometryElement type = support->getTypes()[ iType ]; - ostringstream locname; - locname << nbGaussByType[iType] << "points_on" << type << "geomType"; - f->setGaussLocalization - ( type, - GAUSS_LOCALIZATION_::makeDefaultLocalization( locname.str(), - type, - nbGaussByType[ iType ])); - } - typedef MEDMEM_ArrayInterface::Array Array; - Array* array = new Array(numberOfComponents, - support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS), - support->getNumberOfTypes(), - &nbelgeoc[0], - nbGaussByType-1); - f->setArray( array ); - return f; - } - - PyObject * getNumberOfGaussPoints() - { - int size = self->getNumberOfGeometricTypes(); - - const int * value = self->getNumberOfGaussPoints(); - TYPEMAP_OUTPUT_ARRAY(value, size, PyInt_FromLong, FIELD::getNumberOfGaussPoints()); - } - - - - PyObject * applyPyFunc( PyObject * func ) - { - MESSAGE_MED("Appel de applyPyFunc"); - if (!PyCallable_Check(func)) { - PyErr_SetString(PyExc_TypeError, "FIELD.applyPyFunc prend en argument une fonction"); - return NULL; - } - - int nComp=self->getNumberOfComponents(); - int nVal=self->getNumberOfValues(); - for (int i=1; i!=nVal+1; ++i) - for ( int j=1 ;j!=nComp+1 ;++j ) - { - self->setValueIJ(i,j, Binding::Functor( func, self->getValueIJ(i,j) ) ); - } - - PyObject * result = Binding::Traducer(nComp*nVal); - return result; - } - - %newobject execFunc( int nbOfCompo, PyObject * func ); - FIELD *execFunc( int nbOfCompo, PyObject *func ) - { - MyFunction::_pyFunc=func; - MyFunction::_nbOfComponent=nbOfCompo; - MyFunction::_spaceDim=self->getNumberOfComponents(); - return self->execFunc(nbOfCompo, MyFunction::EvalPy2Cpp); - } - - %newobject __add__(const FIELD & ); - FIELD * __add__(const FIELD & m) - { - MESSAGE_MED("operator + : Creation of the addition of two FIELDs"); - - FIELD* result = - FIELD::add( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - %newobject __sub__(const FIELD & ); - FIELD * __sub__(const FIELD & m) - { - MESSAGE_MED("operator - : Creation of the substraction of two FIELDs"); - FIELD* result = - FIELD::sub( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - %newobject __mul__(const FIELD & ); - FIELD * __mul__(const FIELD & m) - { - MESSAGE_MED("operator * : Creation of the multiplication of two FIELDs"); - FIELD* result = - FIELD::mul( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - %newobject __div__(const FIELD & ); - FIELD * __div__(const FIELD & m) - { - MESSAGE_MED("operator / : Creation of the division of two FIELDs"); - FIELD* result = - FIELD::div( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - %newobject addDeep(const FIELD & ); - FIELD * addDeep(const FIELD & m) - { - MESSAGE_MED("operator + : Creation of the addition of two FIELDINTs"); - FIELD* result = - FIELD::addDeep( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - %newobject subDeep(const FIELD & ); - FIELD * subDeep(const FIELD & m) - { - MESSAGE_MED("operator - : Creation of the substraction of two FIELDs"); - FIELD* result = - FIELD::subDeep( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - %newobject mulDeep(const FIELD & ); - FIELD * mulDeep(const FIELD & m) - { - MESSAGE_MED("operator * : Creation of the multiplication of two FIELDs"); - FIELD* result = - FIELD::mulDeep( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - %newobject divDeep(const FIELD & ); - FIELD * divDeep(const FIELD & m) - { - MESSAGE_MED("operator / : Creation of the division of two FIELDs"); - FIELD* result = - FIELD::divDeep( *(FIELD*)self , - (FIELD&)m ); - return (FIELD*) result; - } - - PyObject * getValue() - { - int size = self->getValueLength(); - - const T1 * value = self->getValue(); - -#ifdef WITH_NUMPY - return TYPEMAP_OUTPUT_PY_ARRAY( value, size ); -#else - TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,FIELD::getValue); -#endif - } - - // returns values for geom type in NoInterlaceByType mode - PyObject * getValueByType(int type) - { - int size = self->getValueByTypeLength(type); - - const T1 * value = self->getValueByType(type); - -#ifdef WITH_NUMPY - return TYPEMAP_OUTPUT_PY_ARRAY( value, size ); -#else - TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer,FIELD::getValueByType()); -#endif - } - - // this method replaces getValueI() in FullInterlace mode - PyObject * getRow(int index) - { - int size = self->getNumberOfComponents() * self->getNbGaussI( index ); - - const T1 * value = self->getRow(index); - - TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer, - FIELD::getRow); - } - - // this method replaces getValueI() in NoInterlace mode - PyObject * getColumn(int index) - { - int size = (self->getSupport())->getNumberOfElements(MED_ALL_ELEMENTS); - - const T1 * value = self->getColumn(index); - - TYPEMAP_OUTPUT_ARRAY(value, size, Binding< T1 >::Traducer, - FIELD::getColumn); - } - - void allocValue2(int NumberOfComponents, int LengthValue) - { - self->allocValue(NumberOfComponents, LengthValue); - } - - %newobject extract(const SUPPORT *subSupport); - FIELD *extract(const SUPPORT *subSupport) - { - FIELD* result=self->extract(subSupport); - return (FIELD *)result; - } - } -}; - -%template(FIELDDOUBLE) FIELD; -%template(FIELDDOUBLENOINTERLACE) FIELD; -%template(FIELDDOUBLENOINTERLACEBYTYPE) FIELD; -%template(FIELDINT) FIELD; -%template(FIELDINTNOINTERLACE) FIELD; -%template(FIELDINTNOINTERLACEBYTYPE) FIELD; - -class GROUP : public SUPPORT -{ -public: - GROUP(); - - ~GROUP(); - - void setNumberOfFamilies(int numberOfFamilies); - void setFamilies(vector< FAMILY * > Family); - - int getNumberOfFamilies() const ; - vector< FAMILY * > getFamilies() const ; - FAMILY * getFamily(int i) const ; -}; - -class GMESH -{ -public : - int addDriver(driverTypes driverType, - const char * fileName="Default File Name.med", - const char * driverName="Default Mesh Name", - med_mode_acces access=RDWR); - - void rmDriver(int index=0); - - void read(int index=0); - void read(const GENDRIVER & genDriver); - void read(driverTypes driverType, - const std::string& filename, - const std::string& meshname); - - void write(int index=0); - void write(const GENDRIVER & driver, - med_mode_acces medMode=WRONLY); - void write(driverTypes driverType, - const std::string& filename, - const std::string& meshname="", - med_mode_acces medMode=WRONLY); - - void setName(char * name); - - int getSpaceDimension(); - - int getMeshDimension(); - - int getNumberOfNodes(); - - bool getIsAGrid(); - - int getNumberOfTypes(medEntityMesh Entity); - - int getNumberOfElements(medEntityMesh Entity,medGeometryElement Type); - - int getNumberOfFamilies(medEntityMesh Entity); - - FAMILY* getFamily(medEntityMesh Entity,int i); - - int getNumberOfGroups(medEntityMesh Entity); - - GROUP * getGroup(medEntityMesh Entity,int i); - GROUP* getGroup(char* name); - - medGeometryElement getElementType(medEntityMesh Entity,int Number); - - SUPPORT * getSupportOnAll(medEntityMesh Entity); - - std::string getName() const; - - std::string getCoordinatesSystem(); - - %extend { - - PyObject* convertInMESH() - { - const MESH* mesh = self->convertInMESH(); - return SWIG_NewPointerObj((void *)mesh, $descriptor(MESH *), self->getIsAGrid() ); - } - - %newobject getBoundaryElements(medEntityMesh ); - SUPPORT * getBoundaryElements(medEntityMesh Entity) - { - return self->getBoundaryElements(Entity); - } - - %newobject getSkin(const SUPPORT * ); - SUPPORT * getSkin(const SUPPORT * Support3D) - { - return self->getSkin(Support3D); - } - - %newobject mergeSupports(const vector< SUPPORT * > ); - SUPPORT * mergeSupports(const vector< SUPPORT * > Supports) - { - return self->mergeSupports(Supports); - } - - %newobject intersectSupports(const vector< SUPPORT * > ); - SUPPORT * intersectSupports(const vector< SUPPORT * > Supports) - { - return self->intersectSupports(Supports); - } - - %newobject mergeFieldsDouble(const vector< FIELDDOUBLE* > others); - FIELD * mergeFieldsDouble(const vector< FIELDDOUBLE* > others) - { - return (FIELD *)self->mergeFields(others); - } - - %newobject mergeFieldsInt(const vector< FIELDINT* > others); - FIELD * mergeFieldsInt(const vector< FIELDINT* > others) - { - return (FIELD *)self->mergeFields(others); - } - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing GMESH : " << *self << endl; - return strdup(mess.str().c_str()); - } - - %newobject getCoordinateName(int ); - const char * getCoordinateName(int i) - { - string tmp_str = self->getCoordinatesNames()[i]; - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - - %newobject getCoordinateUnit(int ); - const char * getCoordinateUnit(int i) - { - string tmp_str = self->getCoordinatesUnits()[i]; - char * tmp = new char[strlen(tmp_str.c_str())+1]; - strcpy(tmp,tmp_str.c_str()); - return tmp; - } - - PyObject * getCoordinatesNames() - { - const string * array = self->getCoordinatesNames(); - int size = self->getSpaceDimension(); - TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString, - MESH::getCoordinatesNames); - } - - PyObject * getCoordinatesUnits() - { - const string * array = self->getCoordinatesUnits(); - int size = self->getSpaceDimension(); - TYPEMAP_OUTPUT_ARRAY(array, size, PyString_FromStdString, - MESH::getCoordinatesUnits); - } - - PyObject * getTypes(medEntityMesh Entity) - { - const medGeometryElement * types = self->getTypes(Entity); - int size = self->getNumberOfTypes(Entity); - TYPEMAP_OUTPUT_ARRAY(types, size, PyInt_FromLong, MESH::getTypes); - } - - %newobject getVolume(const SUPPORT * , bool ); - FIELD * getVolume(const SUPPORT * Support, bool isAbs = true) - { - return (FIELD *) self->getVolume(Support,isAbs); - } - - %newobject getArea(const SUPPORT * ); - FIELD * getArea(const SUPPORT * Support) - { - return (FIELD *) self->getArea(Support); - } - - %newobject getLength(const SUPPORT * ); - FIELD * getLength(const SUPPORT * Support) - { - return (FIELD *) self->getLength(Support); - } - - %newobject getNormal(const SUPPORT * ); - FIELD * getNormal(const SUPPORT * Support) - { - return (FIELD *) self->getNormal(Support); - } - - %newobject getBarycenter(const SUPPORT * ); - FIELD * getBarycenter(const SUPPORT * Support) - { - return (FIELD *) self->getBarycenter(Support); - } - } -private: - GMESH(); // prohibit SWIG to generate a default constructor - -}; - -class MESH : public GMESH -{ -public : - MESH(); - MESH(MESH &m); - MESH (driverTypes driverType, const char* fileName, const char* meshName); - - ~MESH(); - - void convertToPoly(); - - const double getCoordinate(int Number, int Axis); - - void calculateConnectivity(medConnectivity ConnectivityType,medEntityMesh Entity); - - int getElementNumber(medConnectivity ConnectivityType, medEntityMesh Entity, medGeometryElement Type, int * connectivity); - - CELLMODEL * getCellsTypes(medEntityMesh Entity); - - int getElementContainingPoint(const double *coord); - - %extend { - - CELLMODEL getCellType(medEntityMesh Entity,int i) - { - return self->getCellsTypes(Entity)[i]; - } - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MESH : " << *self << endl; - return strdup(mess.str().c_str()); - } - - PyObject * getCoordinates(medModeSwitch Mode) - { - const double * array = self->getCoordinates(Mode); - int size = (self->getSpaceDimension())*(self->getNumberOfNodes()); -#ifdef WITH_NUMPY - return TYPEMAP_OUTPUT_PY_ARRAY( array, size ); -#else - TYPEMAP_OUTPUT_ARRAY(array, size, PyFloat_FromDouble,MESH::getCoordinates); -#endif - } - - PyObject * getConnectivity(medConnectivity ConnectivityType, - medEntityMesh Entity, - medGeometryElement Type) - { - const int * connectivity = self->getConnectivity(ConnectivityType, Entity,Type); - int size = self->getConnectivityLength(ConnectivityType,Entity,Type); -#ifdef WITH_NUMPY - return TYPEMAP_OUTPUT_PY_ARRAY( connectivity, size ); -#else - TYPEMAP_OUTPUT_ARRAY(connectivity, size, PyInt_FromLong,MESH::getConnectivity ); -#endif - } - - PyObject * getConnectivityIndex(medConnectivity ConnectivityType, - medEntityMesh Entity) - { - const int * index = self->getConnectivityIndex(ConnectivityType,Entity); - int size = (self->getNumberOfElements(Entity,MED_ALL_ELEMENTS))+1; -#ifdef WITH_NUMPY - return TYPEMAP_OUTPUT_PY_ARRAY( index, size ); -#else - TYPEMAP_OUTPUT_ARRAY(index,size,PyInt_FromLong,MESH::getConnectivityIndex); -#endif - } - - PyObject * getReverseConnectivity(medConnectivity ConnectivityType, - medEntityMesh Entity=MED_CELL) - { - const int * conn = self->getReverseConnectivity(ConnectivityType,Entity); - int size = self->getReverseConnectivityLength(ConnectivityType,Entity); -#ifdef WITH_NUMPY - return TYPEMAP_OUTPUT_PY_ARRAY( conn, size ); -#else - TYPEMAP_OUTPUT_ARRAY(conn, size, PyInt_FromLong,MESH::getReverseConnectivity); -#endif - } - - PyObject * getReverseConnectivityIndex(medConnectivity ConnectivityType, - medEntityMesh Entity=MED_CELL) - { - const int * index = self->getReverseConnectivityIndex(ConnectivityType,Entity); - int size=self->getReverseConnectivityIndexLength(ConnectivityType,Entity); -#ifdef WITH_NUMPY - return TYPEMAP_OUTPUT_PY_ARRAY( index, size ); -#else - TYPEMAP_OUTPUT_ARRAY(index,size, PyInt_FromLong,MESH::getReverseConnectivityIndex); -#endif - } - - PyObject * getGlobalNumberingIndex(medEntityMesh Entity) - { - const int * numberingIndex = self->getGlobalNumberingIndex(Entity); - int nbOfTypes = self->getNumberOfTypes(Entity); - int size = nbOfTypes+1; - TYPEMAP_OUTPUT_ARRAY(numberingIndex, size, PyInt_FromLong, - MESH::getGlobalNumberingIndex); - } - } -} ; - -class MESHING: public MESH -{ -public : - MESHING(); - ~MESHING(); - - void setCoordinates (const int SpaceDimension, - const int NumberOfNodes, - const double * Coordinates, - std::string System, - const medModeSwitch Mode) ; - void setCoordinatesNames (const std::string * names) ; - void setCoordinateName (const std::string name, const int i) ; - void setCoordinatesUnits (const std::string * units); - void setCoordinateUnit (const std::string unit, const int i) ; - - void setNumberOfTypes (const int NumberOfTypes, - const medEntityMesh Entity) ; - - void setTypes (const medGeometryElement * Types, - const medEntityMesh Entity) ; - - void setNumberOfElements (const int * NumberOfElements, - const medEntityMesh Entity) ; - - void setConnectivity (const medEntityMesh Entity, - const medGeometryElement Type, - const int * Connectivity, - const int * ConnectivityIndex=0) ; - - void addGroup (const GROUP & Group) ; - -}; - -class GRID : public GMESH -{ - public: - GRID(); - - GRID(driverTypes driverType, const char * fileName, const char * meshName); - - GRID(const GRID &m); - - ~GRID(); - - int getNodeNumber(const int i, const int j=0, const int k=0) const ; - - int getCellNumber(const int i, const int j=0, const int k=0) const ; - - int getEdgeNumber(const int Axis, const int i, const int j=0, const int k=0) const ; - - int getFaceNumber(const int Axis, const int i, const int j=0, const int k=0) const ; - - med_grid_type getGridType(); - - int getArrayLength( const int Axis ); - - const double getArrayValue (const int Axis, const int i); - - void setGridType(med_grid_type gridType); - - %extend { - - PyObject * getEntityPosition(const medEntityMesh Entity, const int Number) - { - int ijk[3], Axis; - int i=0, size = self->getSpaceDimension(); - int j=0; - switch (Entity) { - case MED_CELL: - self->getCellPosition(Number, ijk[0], ijk[1], ijk[2]); - break; - case MED_NODE: - self->getNodePosition(Number, ijk[0], ijk[1], ijk[2]); - break; - case MED_FACE: - self->getFacePosition(Number, Axis, ijk[0], ijk[1], ijk[2]); - size++; - i++; - break; - case MED_EDGE: - self->getEdgePosition(Number, Axis, ijk[0], ijk[1], ijk[2]); - size++; - i++; - break; - default: - const char * message = "Error in GRID::getEntityPosition: wrong Entity"; - PyErr_SetString(PyExc_RuntimeError, (char *)message); - return NULL; - } - PyObject *py_list = PyList_New( size ); - for (; i < size; ++i) - { - int err = PyList_SetItem(py_list, i, - Py_BuildValue("i", ijk[j++])); - if(err) - { - const char * message = "Error in GRID::getNodePosition"; - PyErr_SetString(PyExc_RuntimeError, (char *)message); - return NULL; - } - } - if (Entity == MED_FACE || Entity == MED_EDGE) - PyList_SetItem(py_list, 0, Py_BuildValue("i", Axis)); - - PyObject * result = Py_BuildValue("O", py_list); - Py_DECREF(py_list); - return result; - } - } -}; - -class PointLocator -{ -public: - PointLocator(const MESH& mesh); - virtual ~PointLocator(); - %extend{ - PyObject* locate(const double* x) - { - std::list mylist = self->locate(x); - if (mylist.size()>10) - { - const char * message = "Error in PointLocator : SWIG interface limits the number of cells to 10"; - PyErr_SetString(PyExc_RuntimeError, (char *)message); - return NULL; - } - - int array[10]; // maximum number of cells in which the point lies - int index=0; - for (list::const_iterator iter= mylist.begin(); - iter != mylist.end(); - iter++) - array[index++]= *iter; - TYPEMAP_OUTPUT_ARRAY(array, mylist.size(), PyInt_FromLong, - PointLocator::locate); - } - } -}; - -class MEDFILEBROWSER -{ - public: - MEDFILEBROWSER(); - MEDFILEBROWSER (const std::string & fileName); - void readFileStruct(const std::string & fileName); - - std::string getFileName(); - - int getNumberOfMeshes (); - int getNumberOfFields (); - - bool isStructuredMesh(const std::string & meshName); - - med_type_champ getFieldType (const std::string & fieldName); - std::string getMeshName (const std::string & fieldName); - - %extend { - - std::string getMeshName(int i) - { - return self->getMeshNames().at(i); - } - - std::string getFieldName(int i) - { - return self->getFieldNames().at(i); - } - - PyObject *getMeshNames() - { - std::vector< std::string > names = self->getMeshNames(); - std::string* array = &names[0]; - TYPEMAP_OUTPUT_ARRAY(array, names.size(), PyString_FromStdString, - MEDFILEBROWSER::getMeshNames); - } - - - PyObject *getFieldNames() - { - std::vector< std::string > names = self->getFieldNames(); - std::string* array = &names[0]; - TYPEMAP_OUTPUT_ARRAY(array, names.size(), PyString_FromStdString, - MEDFILEBROWSER::getMeshNames); - } - - PyObject* getFieldIteration (char* fieldName) - { - VEC_DT_IT_ vec_dtit = self->getFieldIteration (fieldName); - PyObject *py_list = PyList_New(vec_dtit.size()); - for (unsigned i=0; i < vec_dtit.size(); i++) - { - DT_IT_* dtit = new DT_IT_(vec_dtit[i]); - PyObject * pyDTIT= SWIG_NewPointerObj((void *) dtit, $descriptor(DT_IT_*), 1); - int err = PyList_SetItem(py_list, i, pyDTIT); - if(err) - { - PyErr_SetString(PyExc_RuntimeError, "Error in getFieldIteration"); - return NULL; - } - } - - PyObject * result = Py_BuildValue("O", py_list); - Py_DECREF(py_list); - return result; - - } - } -}; - -/* - API de GIBI_MESH_[RDONLY,WRONLY,RDWR]_DRIVER -*/ - -class GIBI_MESH_RDONLY_DRIVER : public GENDRIVER -{ -public : - GIBI_MESH_RDONLY_DRIVER() ; - - GIBI_MESH_RDONLY_DRIVER(const GIBI_MESH_RDONLY_DRIVER & driver) ; - - GIBI_MESH_RDONLY_DRIVER(const char* fileName, MESH * ptrMesh); - - ~GIBI_MESH_RDONLY_DRIVER() ; - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing GIBI_MESH_RDONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class GIBI_MESH_WRONLY_DRIVER : public GENDRIVER -{ -public : - GIBI_MESH_WRONLY_DRIVER() ; - - GIBI_MESH_WRONLY_DRIVER(const GIBI_MESH_WRONLY_DRIVER & driver) ; - - GIBI_MESH_WRONLY_DRIVER(const char* fileName, GMESH * ptrMesh); - - ~GIBI_MESH_WRONLY_DRIVER() ; - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing GIBI_MESH_WRONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class GIBI_MESH_RDWR_DRIVER : public virtual GIBI_MESH_RDONLY_DRIVER, - public virtual GIBI_MESH_WRONLY_DRIVER -{ -public : - GIBI_MESH_RDWR_DRIVER() ; - - GIBI_MESH_RDWR_DRIVER(const GIBI_MESH_RDWR_DRIVER & driver) ; - - GIBI_MESH_RDWR_DRIVER(const char* fileName, MESH * ptrMesh); - - ~GIBI_MESH_RDWR_DRIVER() ; - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing GIBI_MESH_RDWR_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class GIBI_MED_RDONLY_DRIVER : public GENDRIVER -{ -public : - GIBI_MED_RDONLY_DRIVER() ; - - GIBI_MED_RDONLY_DRIVER(const GIBI_MED_RDONLY_DRIVER & driver) ; - - MESH* getMesh(); - - %extend { - GIBI_MED_RDONLY_DRIVER(char * fileName) - { - std::vector< FIELD_* > fields; - return new GIBI_MED_RDONLY_DRIVER(string(fileName), fields) ; - } - - PyObject * read ( void ) - { - std::vector< FIELD_* > fields; - GIBI_MED_RDONLY_DRIVER tmp( self->getFileName(), fields) ; - tmp.open(); - tmp.read(); - tmp.close(); - *self = tmp; - tmp.getMesh(); - - PyObject* py_list = PyList_New(fields.size()); - - for (unsigned i=0;i fields, - GMESH * ptrMesh) ; - - %extend { - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing GIBI_MED_WRONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - - } -}; - -/*! - * \brief set/get format of vtk file - */ -bool getVtkBinaryFormatForWriting(); - -void setVtkBinaryFormatForWriting(bool isBinary); - -%{ - bool getVtkBinaryFormatForWriting() - { - return DRIVERFACTORY::getVtkBinaryFormatForWriting(); - } - void setVtkBinaryFormatForWriting(bool isBinary) - { - DRIVERFACTORY::setVtkBinaryFormatForWriting(isBinary); - } -%} -/*! - * \brief Driver to write fields to vtk file - */ -class VTK_MED_DRIVER : public GENDRIVER -{ -public: - VTK_MED_DRIVER(const char* fileName, vector< const FIELD_* > fields); -}; - -/* - API de PORFLOW_MESH_[RDONLY,WRONLY,RDWR]_DRIVER -*/ - -class PORFLOW_MESH_RDONLY_DRIVER : public GENDRIVER -{ -public : - PORFLOW_MESH_RDONLY_DRIVER() ; - - PORFLOW_MESH_RDONLY_DRIVER(const PORFLOW_MESH_RDONLY_DRIVER & driver) ; - - PORFLOW_MESH_RDONLY_DRIVER(const char* fileName, MESH * ptrMesh); - - ~PORFLOW_MESH_RDONLY_DRIVER() ; - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing PORFLOW_MESH_RDONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class PORFLOW_MESH_WRONLY_DRIVER : public GENDRIVER -{ -public : - PORFLOW_MESH_WRONLY_DRIVER() ; - - PORFLOW_MESH_WRONLY_DRIVER(const PORFLOW_MESH_WRONLY_DRIVER & driver) ; - - PORFLOW_MESH_WRONLY_DRIVER(char * fileName, GMESH * ptrMesh); - - ~PORFLOW_MESH_WRONLY_DRIVER() ; - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing PORFLOW_MESH_WRONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class PORFLOW_MESH_RDWR_DRIVER : public virtual PORFLOW_MESH_RDONLY_DRIVER, - public virtual PORFLOW_MESH_WRONLY_DRIVER -{ -public : - PORFLOW_MESH_RDWR_DRIVER() ; - - PORFLOW_MESH_RDWR_DRIVER(const PORFLOW_MESH_RDWR_DRIVER & driver) ; - - PORFLOW_MESH_RDWR_DRIVER(const char * fileName, MESH * ptrMesh); - - ~PORFLOW_MESH_RDWR_DRIVER() ; - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing PORFLOW_MESH_RDWR_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -/* - API de MED_MESH_[RDONLY,WRONLY,RDWR]_DRIVER -*/ - -class MED_MESH_RDONLY_DRIVER : public GENDRIVER -{ - public : - - MED_MESH_RDONLY_DRIVER(const char * fileName, GMESH * ptrMesh); - - ~MED_MESH_RDONLY_DRIVER(); - - void desactivateFacesComputation(); - - void activateFacesComputation(); - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_MESH_RDONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class MED_MESH_WRONLY_DRIVER : public GENDRIVER -{ - public : - ~MED_MESH_WRONLY_DRIVER(); - - MED_MESH_WRONLY_DRIVER(const char * fileName, GMESH * ptrMesh); - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_MESH_WRONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -class MED_MESH_RDWR_DRIVER : public virtual MED_MESH_RDONLY_DRIVER, - public virtual MED_MESH_WRONLY_DRIVER -{ - public : - - ~MED_MESH_RDWR_DRIVER(); - - MED_MESH_RDWR_DRIVER(const char * fileName, GMESH * ptrMesh); - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_MESH_RDWR_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; - -/* - API de MED_FIELD_[RDONLY,WRONLY,RDWR]_DRIVER -*/ - -template< class T1 > -class MED_FIELD_RDONLY_DRIVER : public GENDRIVER -{ -public: - - MED_FIELD_RDONLY_DRIVER(const char * fileName, FIELD * ptrField); - - ~MED_FIELD_RDONLY_DRIVER(); - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_FIELD_RDONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; -%template ( MED_FIELDDOUBLE_RDONLY_DRIVER ) MED_FIELD_RDONLY_DRIVER< double >; -%template ( MED_FIELDINT_RDONLY_DRIVER ) MED_FIELD_RDONLY_DRIVER< int >; - - -template < class T1 > -class MED_FIELD_WRONLY_DRIVER : public GENDRIVER -{ -public: - - MED_FIELD_WRONLY_DRIVER(const char * fileName, FIELD * ptrField); - - ~MED_FIELD_WRONLY_DRIVER(); - - %extend { - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_FIELD_WRONLY_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; -%template ( MED_FIELDDOUBLE_WRONLY_DRIVER ) MED_FIELD_WRONLY_DRIVER< double >; -%template ( MED_FIELDINT_WRONLY_DRIVER ) MED_FIELD_WRONLY_DRIVER< int >; - - -template< class T1 > -class MED_FIELD_RDWR_DRIVER : public virtual MED_FIELD_RDONLY_DRIVER< T1 >, public virtual MED_FIELD_WRONLY_DRIVER< T1 > -{ -public: - - MED_FIELD_RDWR_DRIVER(const char * fileName, FIELD * ptrField); - - ~MED_FIELD_RDWR_DRIVER(); - - %extend { - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing MED_FIELD_RDWR_DRIVER : " << *self << endl; - return strdup(mess.str().c_str()); - } - } -}; -%template ( MED_FIELDDOUBLE_RDWR_DRIVER ) MED_FIELD_RDWR_DRIVER< double >; -%template ( MED_FIELDINT_RDWR_DRIVER ) MED_FIELD_RDWR_DRIVER< int >; - - -template< class T1 > -class ASCII_FIELD_DRIVER : public GENDRIVER -{ -public: - ASCII_FIELD_DRIVER(const char *fileName, FIELD * ptrField, med_sort_direc direction, const char *priority); - ~ASCII_FIELD_DRIVER(); -}; - -%template (ASCII_FIELDDOUBLE_DRIVER) ASCII_FIELD_DRIVER< double >; -%template (ASCII_FIELDINT_DRIVER) ASCII_FIELD_DRIVER< int >; - -//======================================================================= -/* - EnSight drivers -*/ -// --------------------------------------------------------------- -//!< supported formats -enum EnSightFormat { ENSIGHT_6, ENSIGHT_GOLD }; - -// --------------------------------------------------------------- -//!< set writing format - -void setEnSightFormatForWriting (EnSightFormat format, bool isBinary); - -// --------------------------------------------------------------- -//!< To raise or not if MEDMEM-EnSight incompatibility encounters or suspected. -// See MEDMEM_EnsightUtils.hxx for raison why - -void setIgnoreIncompatibility(bool toIgnore=true); - -// --------------------------------------------------------------- -//!< EnSight reading driver reads all meshes and fields - -class ENSIGHT_MED_RDONLY_DRIVER : public GENDRIVER -{ -public: - - %extend { - ENSIGHT_MED_RDONLY_DRIVER(const std::string & fileName) - { - vector< FIELD_* > fields; - return new ENSIGHT_MED_RDONLY_DRIVER(fileName,fields); - } - - PyObject * read() - { - std::vector< FIELD_* > fields; - ENSIGHT_MED_RDONLY_DRIVER tmp( self->getFileName(), fields) ; - tmp.read(); - - PyObject* py_list = PyList_New(fields.size()); - - for (unsigned i=0;i fields); - void write(); -}; -// --------------------------------------------------------------- -//!< EnSight mesh reading driver - -class ENSIGHT_MESH_RDONLY_DRIVER : public GENDRIVER -{ -public : - //!< to read mesh of index-th time step - ENSIGHT_MESH_RDONLY_DRIVER(const std::string & fileName, MESH * ptrMesh, int index=1); - void read(); -}; -// --------------------------------------------------------------- -//!< Writing EnSight mesh driver. - -class ENSIGHT_MESH_WRONLY_DRIVER : public GENDRIVER -{ -public : - ENSIGHT_MESH_WRONLY_DRIVER(const std::string & fileName, GMESH * ptrMesh, bool append=false); - void write(); -}; -// --------------------------------------------------------------- -//!< EnSight field reading driver - -class ENSIGHT_FIELD_RDONLY_DRIVER : public GENDRIVER -{ -public : - //!< Set the name of the FIELD in EnSight file - void setFieldName(const std::string & fieldName); - //!< read the field of a specified name and index-th time step. - ENSIGHT_FIELD_RDONLY_DRIVER(const std::string & fileName, FIELD_ * ptrField, int step=1); - void read(); -}; -// --------------------------------------------------------------- -//!< Writing EnSight field driver. - -class ENSIGHT_FIELD_WRONLY_DRIVER : public GENDRIVER -{ -public : - //!< Set the name of the FIELD in EnSight file - void setFieldName(const std::string & fieldName); - ENSIGHT_FIELD_WRONLY_DRIVER(const std::string & fileName, FIELD_ * ptrField); - //!< Write FIELD, the mesh is supposed to be written in this file. - void write(); -}; -// end of EnSight drivers -//======================================================================= - - -template class GAUSS_LOCALIZATION -{ - public: - - GAUSS_LOCALIZATION(); - - ~GAUSS_LOCALIZATION(); - - std::string getName() const ; - - medGeometryElement getType() const ; - - int getNbGauss() const ; - - medModeSwitch getInterlacingType() const; - - %extend { - GAUSS_LOCALIZATION(char * locName, - const medGeometryElement - typeGeo, - const int nGauss, - const double * cooRef, - const double * cooGauss, - const double * wg) - { - return new GAUSS_LOCALIZATION(string(locName), - typeGeo, nGauss, cooRef, - cooGauss, wg); - } - - %newobject __str__(); - const char* __str__() - { - ostringstream mess; - mess << "Python Printing GAUSS_LOCALIZATION : " << *self << endl; - return strdup(mess.str().c_str()); - } - - PyObject * getRefCoo () const - { - typedef MEDMEM_ArrayInterface::Array ArrayNoGauss; - - ArrayNoGauss cooRef = self->getRefCoo(); - int size = cooRef.getArraySize(); - double * cooRefPtr = cooRef.getPtr(); - TYPEMAP_OUTPUT_ARRAY(cooRefPtr, size, PyFloat_FromDouble, - GAUSS_LOCALIZATION::getRefCoo); - } - - PyObject * getGsCoo () const - { - typedef MEDMEM_ArrayInterface::Array ArrayNoGauss; - ArrayNoGauss cooGauss = self->getGsCoo(); - int size = cooGauss.getArraySize(); - double * cooGaussPtr = cooGauss.getPtr(); - TYPEMAP_OUTPUT_ARRAY(cooGaussPtr, size, PyFloat_FromDouble, - GAUSS_LOCALIZATION::getGsCoo); - } - - PyObject * getWeight () const - { - vector wg = self->getWeight(); - double * wgPtr = &wg[0]; - TYPEMAP_OUTPUT_ARRAY(wgPtr, wg.size(), PyFloat_FromDouble, - GAUSS_LOCALIZATION::getWeight); - } - } -}; - -%template (GAUSS_LOCALIZATION_FULL) GAUSS_LOCALIZATION ; -%template (GAUSS_LOCALIZATION_NO) GAUSS_LOCALIZATION ; - -%{ - template - FIELD * createFieldScalarProduct(FIELD * field1, - FIELD * field2) - { - return (FIELD *) - FIELD::scalarProduct((FIELD)*field1, - (FIELD)*field2); - } - - template - FIELD * createFieldScalarProductDeep(FIELD * field1, - FIELD * field2) - { - return (FIELD*) FIELD::scalarProduct((FIELD)*field1, - (FIELD)*field2, true); - } - - template - FIELD * createTypedFieldFromField(FIELD_ * field) - { - MESSAGE_MED("createTypedFieldFromField : Constructor (for Python API) FIELD with parameter FIELD_"); - MESSAGE_MED("Its returns a proper cast of the input pointer :: FIELD_ --> FIELD"); - if ( field ) { - if (field->getInterlacingType() != SET_INTERLACING_TYPE::_interlacingType) - throw MEDEXCEPTION("cast to wrong medModeSwitch (_interlacingType)"); - if (field->getValueType() != SET_VALUE_TYPE::_valueType) - throw MEDEXCEPTION("cast to wrong med_type_champ (_valueType)"); - } - return (FIELD *) field; - } - - template FIELD * - createTypedFieldConvertFullInterlace(const FIELD & field ) - { - return FieldConvert(field); - } - - template FIELD * - createTypedFieldConvertNoInterlace(const FIELD & field ) - { - return FieldConvert(field); - } -%} - -template FIELD * createTypedFieldFromField(FIELD_ * field); -%template ( createFieldDoubleFromField ) createTypedFieldFromField < double, FullInterlace>; -%template ( createFieldIntFromField ) createTypedFieldFromField < int, FullInterlace >; -%template ( createFieldDoubleNoInterlaceFromField ) createTypedFieldFromField < double, NoInterlace>; -%template ( createFieldIntNoInterlaceFromField ) createTypedFieldFromField < int, NoInterlace >; -%template ( createFieldDoubleNoInterlaceByTypeFromField ) createTypedFieldFromField < double, NoInterlaceByType>; -%template ( createFieldIntNoInterlaceByTypeFromField ) createTypedFieldFromField < int, NoInterlaceByType >; - -template FIELD * createFieldScalarProduct(FIELD * field1, FIELD * field2); -%newobject createFieldDoubleScalarProduct ; -%newobject createFieldIntScalarProduct ; -%newobject createFieldDoubleNoInterlaceScalarProduct ; -%newobject createFieldIntNoInterlaceScalarProduct ; -%newobject createFieldDoubleNoInterlaceByTypeScalarProduct ; -%newobject createFieldIntNoInterlaceByTypeScalarProduct ; -%template ( createFieldDoubleScalarProduct ) createFieldScalarProduct < double, FullInterlace >; -%template ( createFieldIntScalarProduct ) createFieldScalarProduct < int, FullInterlace >; -%template ( createFieldDoubleNoInterlaceScalarProduct ) createFieldScalarProduct < double, NoInterlace >; -%template ( createFieldIntNoInterlaceScalarProduct ) createFieldScalarProduct < int, NoInterlace >; -%template ( createFieldDoubleNoInterlaceByTypeScalarProduct ) createFieldScalarProduct < double, NoInterlaceByType >; -%template ( createFieldIntNoInterlaceByTypeScalarProduct ) createFieldScalarProduct < int, NoInterlaceByType >; - -template FIELD * createFieldScalarProductDeep(FIELD * field1, FIELD * field2); -%newobject createFieldDoubleScalarProductDeep ; -%newobject createFieldIntScalarProductDeep ; -%newobject createFieldDoubleNoInterlaceScalarProductDeep ; -%newobject createFieldIntNoInterlaceScalarProductDeep ; -%newobject createFieldDoubleNoInterlaceByTypeScalarProductDeep ; -%newobject createFieldIntNoInterlaceByTypeScalarProductDeep ; -%template ( createFieldDoubleScalarProductDeep ) createFieldScalarProductDeep < double, FullInterlace >; -%template ( createFieldIntScalarProductDeep ) createFieldScalarProductDeep < int, FullInterlace >; -%template ( createFieldDoubleNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < double, NoInterlace >; -%template ( createFieldIntNoInterlaceScalarProductDeep ) createFieldScalarProductDeep < int, NoInterlace >; -%template ( createFieldDoubleNoInterlaceByTypeScalarProductDeep ) createFieldScalarProductDeep < double, NoInterlaceByType >; -%template ( createFieldIntNoInterlaceByTypeScalarProductDeep ) createFieldScalarProductDeep < int, NoInterlaceByType >; - -template FIELD * createFieldFromAnalytic(SUPPORT * Support, int NumberOfComponents, PyObject * double_function); - -template FIELD * createTypedFieldConvertFullInterlace(const FIELD & field ); - -%template (createFieldDoubleConvertFullInterlace) createTypedFieldConvertFullInterlace; - -%template (createFieldIntConvertFullInterlace) createTypedFieldConvertFullInterlace; - -template FIELD * createTypedFieldConvertNoInterlace(const FIELD & field ); -//template FIELD * createTypedFieldConvertNoInterlace(const FIELD & field ); - -%template (createFieldDoubleConvertNoInterlace) createTypedFieldConvertNoInterlace; - -%template (createFieldIntConvertNoInterlace) createTypedFieldConvertNoInterlace; - -%newobject createFieldDoubleConvertFullInterlace ; -%newobject createFieldIntConvertFullInterlace ; - -%newobject createFieldDoubleConvertNoInterlace ; -%newobject createFieldIntConvertNoInterlace ; - -GRID * createGridFromMesh( MESH * aMesh ); - -%{ - GRID * createGridFromMesh( MESH * aMesh ) - { - MESSAGE_MED("createGridFromMesh : Constructor (for Python API) GRID with parameter MESH *"); - MESSAGE_MED("Its returns a proper cast of the input pointer :: MESH --> GRID"); - - if (aMesh->getIsAGrid()) - return (GRID *) aMesh; - - const char * message = "Error in GRID(mesh): mesh is not a grid"; - PyErr_SetString(PyExc_RuntimeError, (char *)message); - return NULL; - } - - template - FIELD * createFieldFromAnalytic(SUPPORT * Support, - int NumberOfComponents, - PyObject * double_function) - { - MESSAGE_MED("createFieldFromAnalytic : Constructor (for Python API) FIELD from an analytic fonction"); - - FIELD * fieldAnalytic = - new FIELD(Support, NumberOfComponents); - - MyFunction::_pyFunc=double_function; - MyFunction::_nbOfComponent=NumberOfComponents; - MyFunction::_spaceDim=Support->getMesh()->getSpaceDimension(); - fieldAnalytic->fillFromAnalytic(MyFunction::EvalPy2Cpp); - return fieldAnalytic; - } -%} - -%template (createFieldDoubleFromAnalytic) createFieldFromAnalytic; -%template (createFieldIntFromAnalytic) createFieldFromAnalytic; -%template (createFieldDoubleNoInterlaceFromAnalytic) createFieldFromAnalytic; -%template (createFieldIntNoInterlaceFromAnalytic) createFieldFromAnalytic; diff --git a/src/MEDMEM_SWIG/med2sauv b/src/MEDMEM_SWIG/med2sauv deleted file mode 100755 index fe3c79e1c..000000000 --- a/src/MEDMEM_SWIG/med2sauv +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# -- -# Copyright (C) 2009-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Erwan ADAM (CEA) -# -- - -from sys import argv -d = argv[0] -from os.path import dirname -d = dirname(d) -from os.path import abspath -d = abspath(d+'/../lib') -from sys import path -if d not in path: - path.insert(0, d) - pass - -from medutilities import med2sauv -from sys import argv -med2sauv(*argv[1:]) diff --git a/src/MEDMEM_SWIG/medEnsightMed_test.py b/src/MEDMEM_SWIG/medEnsightMed_test.py deleted file mode 100644 index df6ab7abf..000000000 --- a/src/MEDMEM_SWIG/medEnsightMed_test.py +++ /dev/null @@ -1,342 +0,0 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -############################################################################ -# This script tests conversion of MEDMEM to EnSight by performing following -# operations on available med files: -# - read med file into MEDMEM and breifly dump it's content; -# - write EnSight file in different formats: Gold and EnSight6, ASCII and binary; -# - checks generated EnSight files using ens_checker utility (if available); -# - read generated EnSight file into MEDMEM and breifly dump it's content; -# - store MEDMEM to med file. -############################################################################ -# -from medmem import * -from dumpMEDMEM import * -from re import search -import sys - -ASCII = False -Binary = True -formats = [ - (ENSIGHT_GOLD,ASCII) - ,(ENSIGHT_GOLD,Binary) - ,(ENSIGHT_6,ASCII) - ,(ENSIGHT_6,Binary) - ] - -tmpDir = os.getenv("TMP") -if not tmpDir: - tmpDir = os.getenv("TMPDIR","/tmp") - -inDir = os.path.join(os.getenv("MED_ROOT_DIR"), "share","salome","resources","med") -if not os.access(inDir, os.F_OK): - raise RuntimeError, "Path to med files not found, MED_ROOT_DIR incorrect?" - -outDir = os.path.join( tmpDir,"Ensight_out") -if not os.access(outDir, os.F_OK): - os.mkdir( outDir ) - pass - -# find out if ens_checker is present -has_ens_checker = False -tmpFile = os.path.join( outDir, "has_ens_checker" ) -os.system("ens_checker _.case > %s 2>&1" % tmpFile) -tmpFile = open( tmpFile ).read() -if search("EnSight Data Format Checker", tmpFile): - has_ens_checker = True -else: - print "\nWarning: ens_checker utility NOT available" - pass - -dumpMesh = False -dumpMesh = True - -dumpField= False -dumpField= True - -def check_ens(casefile, logfile): - cmd = "(cd %s; ens_checker %s > %s 2>&1)" % (outDir, casefile, logfile) - err = os.system( cmd ) - if os.access(logfile, os.F_OK): - log = open(logfile).read() - if search("bummer", log): - print log - raise RuntimeError, "cd %s; ens_checker %s" % (outDir, casefile) - if search("Warning:", log): - print log - pass - pass - -def compatibilityPb(): - "Print traceback and return true if exception is due to EnSight-MEDMEM incompatibility" - isCompatibilityPb = ( sys.exc_value.__str__().find("compatibility problem") > 0 ) - if isCompatibilityPb: - print '$$$$$$$$$$$$$$$$$$$$ COMPATIBILITY PROBLEM $$$$$$$$$$$$$$$$$$$$$$$$' - print sys.exc_value, "\n" - else: - import traceback - traceback.print_exc() - return isCompatibilityPb - -from dircache import listdir - -# all files sorted by size increasing -medFiles = [ - "ChampsDarcy.med" -# ,"Old_maillage_chemvalIV_cas1_40elts.med" -# ,"maillage_UniSegFam.med" -# ,"champ1.med" -# ,"carre_en_quad4.med" -# ,"poly3D.med" -# ,"Old_Deff_fdt_5.8_castem_vf_diff_conc_dom.med" -# ,"Old_Deff_fdt_5.8_castem_efmh_diff_conc_dom.med" -# ,"test18.med" -# ,"cas_defaut_domaine_fluide.med" -# ,"carre_en_quad4_seg2.med" -# ,"polyedres.med" -# ,"Fields_group3D.med" -# ,"maillage_5_5_5.med" -# ,"cube_hexa8.med" -# ,"new_pointe.med" -# ,"mesh.med" -# ,"cube_hexa8_quad4.med" -# ,"jurassique.med" -# ,"test_2D.med" -# ,"pointe_4fields.med" -# ,"pointe.med" -# ,"test19.med" -# ,"extendedtransport53_triangles.med" -# ,"recoll_bord.med" -# ,"polygones.med" -# ,"zzzz121b_without_tr6.med" -# ,"trio_2D.med" -# ,"essaiminimail.med" -# ,"maill.0.med" -# ,"elle_3D_HPr_2x2x2_2.med" -# ,"maill.00_nofield.med" -# ,"elle_3D_HPr_4x4x4_2.med" -# ,"maill.00_nomesh.med" -# ,"fra1.med" -# ,"fra.med" -# ,"maill.00_without_seg2.med" -# ,"freebord.med" -# ,"maill.00.med" -# ,"zzzz121b.med" -# ,"ResOK_0000.med" -# ,"Darcy3_3D_H_10x10x10_2.med" -# ,"maill.0_volumes.med" -# ,"Old_darcy_1.3_resTRACES.med" -# ,"Old_darcy_1.3_resCASTEM.med" -# ,"darcy_1.3_resTRACES.med" -# ,"darcy_1.3_resCASTEM.med" -# ,"geomMesh22.med" -# ,"geomMesh21.med" -# ,"Old_darcy_1.3_resPORFLOW.med" -# ,"darcy_1.3_resPORFLOW.med" -# ,"test_hydro_darcy1a_out.med" -# ,"maillage_2D.med" -# ,"elle_3D_HPr_10x10x10_2.med" -# ,"Old_darcy_1.1_res.med" -# ,"darcy_1.1_res.med" -# ,"maill.1.med" -# ,"clo.med" -# ,"clo2.med" -# ,"Old_H_Traces_Se79_COUPLEX1.med" -# ,"Old_H_Traces_I129_COUPLEX1.med" -# ,"Old_H_PorfPorf_Se79_COUPLEX1.med" -# ,"Old_H_PorfPorf_I129_COUPLEX1.med" -# ,"Old_H_PorfCast_EFMH_Se79_COUPLEX1.med" -# ,"Old_H_PorfCast_EFMH_I129_COUPLEX1.med" -# ,"Old_H_CastPorf_Se79_COUPLEX1.med" -# ,"Old_H_CastPorf_I129_COUPLEX1.med" -# ,"Old_H_CastCast_VF_Se79_COUPLEX1.med" -# ,"Old_H_CastCast_VF_I129_COUPLEX1.med" -# ,"Old_H_CastCast_EFMH_I129_COUPLEX1.med" -# ,"H_Traces_Se79_COUPLEX1.med" -# ,"H_Traces_I129_COUPLEX1.med" -# ,"H_PorfPorf_I129_COUPLEX1.med" -# ,"H_PorfCast_EFMH_Se79_COUPLEX1.med" -# ,"H_PorfCast_EFMH_I129_COUPLEX1.med" -# ,"H_CastPorf_Se79_COUPLEX1.med" -# ,"H_CastPorf_I129_COUPLEX1.med" -# ,"H_CastCast_VF_Se79_COUPLEX1.med" -# ,"H_CastCast_VF_I129_COUPLEX1.med" -# ,"H_CastCast_EFMH_I129_COUPLEX1.med" -# ,"puitsinst.med" -# ,"Old_darcy2_Castem_EFMH.med" -# ,"darcy2_Castem_EFMH.med" -# ,"Old_darcy2_Castem_qua_VF.med" -# ,"Old_darcy2_Castem_qua_EFMH.med" -# ,"darcy2_Castem_qua_VF.med" -# ,"darcy2_Castem_qua_EFMH.med" -# ,"maillage_migr3d.med" -# ,"Mistrat.med" -# ,"Old_ChampsDarcy.med" -# ,"ChampsDarcy.med" -# ,"resu.2.med" -# ,"maill.2.med" -# ,"TimeStamps.med" -# ,"hexa_28320_ELEM.med" - ] - -badFiles = [ # files that can't be read by MEDMEM - "Deff_fdt_5.8_castem_efmh_diff_conc_dom.med" - ,"Deff_fdt_5.8_castem_vf_diff_conc_dom.med" - ] - -medFiles = listdir( inDir ) - - -for medFile in medFiles: # loop on med files in inDir - - basename, ext = os.path.splitext( medFile ) - if ext != ".med" or medFile in badFiles: continue - - # read MED file - medFile = os.path.join( inDir, medFile ) - print "reading",medFile - fields = [] - try: - med = MEDFILEBROWSER(medFile) - if med.getNumberOfMeshes() < 1: continue - m2m_nom = med.getMeshNames()[0] - if med.isStructuredMesh(m2m_nom): - mesh = GRID(MED_DRIVER,medFile,m2m_nom); - else: - mesh = MESH(MED_DRIVER,medFile,m2m_nom); - pass - - for f_name in med.getFieldNames(): - if med.getMeshName(f_name) != mesh.getName(): continue - dtit_list = med.getFieldIteration( f_name ) - for dtit in dtit_list: - if med.getFieldType( f_name ) == MED_REEL64: - field = FIELDDOUBLE(MED_DRIVER, medFile, f_name, dtit.dt, dtit.it, mesh ) - else: - field = FIELDINT(MED_DRIVER, medFile, f_name, dtit.dt, dtit.it, mesh ) - pass - fields.append( field ) - except: - print sys.exc_value - continue - - ShowMesh( mesh ) - print "Nb Fields",len(fields) - #ShowGroups( mesh ) - #ShowFields( fields, 10 ) - - basename = os.path.join( outDir, basename ) + '.' - checkFile = basename + "ens_checker" - - for format,bin in formats: - if format == ENSIGHT_GOLD: - formatName = "ENSIGHT GOLD" - formatSuffix = "g" - else: - formatName = "ENSIGHT 6" - formatSuffix = '6' - pass - if bin: - formatName += " Binary" - formatSuffix += 'b' - else: - formatName += " ASCII" - formatSuffix += 'a' - pass - ensFile = basename + formatSuffix + ".case" - print '*'*80 - print "Format: \t",formatName - print '*'*80 - - setEnSightFormatForWriting( format, bin ) - - # write a mesh to EnSight - # print "write a mesh to EnSight" - # myMeshDriver = ENSIGHT_MESH_WRONLY_DRIVER(ensFile,mesh) - # myMeshDriver.write() - - # if med.getNumberOfFields() > 0: - # fName = med.getFieldName( 0 ) - # dt_it_= med.getFieldIteration( fName, 0 ) - # field = med.getField( fName, dt_it_.dt, dt_it_.it ) - # print "add a field to EnSight" - # myFieldDriver = ENSIGHT_FIELD_WRONLY_DRIVER(ensFile,field); - # myFieldDriver.write(); - - # check_ens(ensFile, checkFile) - - # write EnSight - print "writting", ensFile - try: - if fields: - medEnsDriver = ENSIGHT_MED_WRONLY_DRIVER (ensFile, fields) - medEnsDriver.write() - else: - mesh.write( ENSIGHT_DRIVER, ensFile ) - except: - if not compatibilityPb(): - sys.exit(1) - continue - - # check generated EnSight - check_ens(ensFile, checkFile) - - # read generated EnSight into MEDMEM - print "reading",ensFile - if fields: - medFromEns = ENSIGHT_MED_RDONLY_DRIVER(ensFile) - fields = medFromEns.read() - mesh = fields[0].getSupport().getMesh() - else: - mesh = MESH(ENSIGHT_DRIVER, ensFile, "") - - # dump generated EnSight - if dumpMesh: - #ShowMesh( mesh ) - ShowMesh( mesh, 10, [10,10,10] ) - #ShowGroups( mesh ) - pass - if dumpField: - ShowFields( fields, 10 ) - pass - - # write EnSight to MED - wFile = basename + formatSuffix + ".med" - deleteFile(wFile) - print "write",wFile - try: - mesh.write( MED_DRIVER,wFile ) - for f in fields: - fTyped = f.castToTypedField() - fTyped.write(MED_DRIVER,wFile) - except: - import traceback - traceback.print_exc() - pass - pass - - print "\n\n\n" - - -# remove created files -for f in listdir( outDir ): - deleteFile( os.path.join( outDir, f )) diff --git a/src/MEDMEM_SWIG/medMeshing_test.py b/src/MEDMEM_SWIG/medMeshing_test.py deleted file mode 100644 index b82e07c08..000000000 --- a/src/MEDMEM_SWIG/medMeshing_test.py +++ /dev/null @@ -1,496 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -# This Python script uses the wrapped C++ class MESHING to buid a mesh from only -# primitive data like coordinates (Pythoin double array) and connectivity (Python -# integer arrays). It is the Python equivalent of the C++ program -# test_MEDMEM_Meshing.cxx in the ../MEDMEM directory of the SALOME distribution -################################################################################### -# -from libMEDMEM_Swig import * - -# files name to save the generated MESH(ING) in different format -# Med V2.2 and vtk - -med22FileName = "toto22.med" - -vtkFileName = "toto.vtk" - -myMeshing = MESHING() - -myMeshing.setName("meshing") - -# definition of the coordinates - -spaceDimension = 3 - -numberOfNodes = 19 - -coordinates = [ - 0.0, 0.0, 0.0 , - 0.0, 0.0, 1.0 , - 2.0, 0.0, 1.0 , - 0.0, 2.0, 1.0 , - -2.0, 0.0, 1.0 , - 0.0, -2.0, 1.0 , - 1.0, 1.0, 2.0 , - -1.0, 1.0, 2.0 , - -1.0, -1.0, 2.0, - 1.0, -1.0, 2.0 , - 1.0, 1.0, 3.0 , - -1.0, 1.0, 3.0 , - -1.0, -1.0, 3.0, - 1.0, -1.0, 3.0 , - 1.0, 1.0, 4.0 , - -1.0, 1.0, 4.0 , - -1.0, -1.0, 4.0, - 1.0, -1.0, 4.0 , - 0.0, 0.0, 5.0] - -myMeshing.setCoordinates(spaceDimension,numberOfNodes,coordinates,"CARTESIAN",MED_FULL_INTERLACE) - -for i in range(spaceDimension): - unit = "cm " - if (i == 0): - name = "X " - elif (i == 1): - name = "Y " - elif (i == 2): - name = "Z " - - myMeshing.setCoordinateName(name,i) - myMeshing.setCoordinateUnit(unit,i) - -# definition of connectivities -# cell part - -numberOfTypes = 3 -entity = MED_CELL - -types = [] -numberOfElements = [] - -types.append(MED_TETRA4) -numberOfElements.append(12) - -types.append(MED_PYRA5) -numberOfElements.append(2) - -types.append(MED_HEXA8) -numberOfElements.append(2) - -myMeshing.setNumberOfTypes(numberOfTypes,entity) -myMeshing.setTypes(types,entity) -myMeshing.setNumberOfElements(numberOfElements,entity) - -connectivityTetra = [1,2,3,6, - 1,2,4,3 , - 1,2,5,4 , - 1,2,6,5 , - 2,7,4,3 , - 2,8,5,4 , - 2,9,6,5 , - 2,10,3,6, - 2,7,3,10, - 2,8,4,7 , - 2,9,5,8 , - 2,10,6,9] - -myMeshing.setConnectivity(entity,types[0],connectivityTetra) - -connectivityPyra = [ - 7,8,9,10,2, - 15,18,17,16,19] - -myMeshing.setConnectivity(entity,types[1],connectivityPyra) - -connectivityHexa = [ - 11,12,13,14,7,8,9,10, - 15,16,17,18,11,12,13,14] - -myMeshing.setConnectivity(entity,types[2],connectivityHexa) - -# face part - -numberOfTypes = 2 -entity = MED_FACE - -types = [] -numberOfElements = [] - -types.append(MED_TRIA3) -numberOfElements.append(4) - -types.append(MED_QUAD4) -numberOfElements.append(4) - -myMeshing.setNumberOfTypes(numberOfTypes,entity) -myMeshing.setTypes(types,entity) -myMeshing.setNumberOfElements(numberOfElements,entity) - -connectivityTria = [ - 1,4,3, - 1,5,4, - 1,6,5, - 1,3,6] - -myMeshing.setConnectivity(entity,types[0],connectivityTria) - -connectivityQuad = [ - 7,8,9,10 , - 11,12,13,14, - 11,7,8,12 , - 12,8,9,13] - -myMeshing.setConnectivity(entity,types[1],connectivityQuad) - -# edge part - -# adding GROUPs -# on Node - -myGroup = GROUP() -myGroup.setName("SomeNodes") -myGroup.setMesh(myMeshing) -myGroup.setEntity(MED_NODE) -myGroup.setNumberOfGeometricType(1) - -myTypes = [MED_NONE] -myGroup.setGeometricType(myTypes) - -myNumberOfElements = [4] -myGroup.setNumberOfElements(myNumberOfElements) - -index = [1,5] -values = [1,4,5,7] -myGroup.setNumber(index,values) - -myMeshing.addGroup(myGroup) - -myGroup = GROUP() -myGroup.setName("OtherNodes") -myGroup.setMesh(myMeshing) -myGroup.setEntity(MED_NODE) -myGroup.setNumberOfGeometricType(1) - -myTypes = [MED_NONE] -myGroup.setGeometricType(myTypes) - -myNumberOfElements = [3] -myGroup.setNumberOfElements(myNumberOfElements) - -index = [1,4] -values = [2,3,6] -myGroup.setNumber(index,values) - -myMeshing.addGroup(myGroup) - -# on Cell - -myGroup = GROUP() -myGroup.setName("SomeCells") -myGroup.setMesh(myMeshing) -myGroup.setEntity(MED_CELL) -myGroup.setNumberOfGeometricType(3) - -myTypes = [MED_TETRA4,MED_PYRA5,MED_HEXA8] -myGroup.setGeometricType(myTypes) - -myNumberOfElements = [4,1,2] -myGroup.setNumberOfElements(myNumberOfElements) - -index = [1,5,6,8] -values = [ - 2,7,8,12, - 13, - 15,16 - ] -myGroup.setNumber(index,values) - -myMeshing.addGroup(myGroup) - -myGroup = GROUP() -myGroup.setName("OtherCells") -myGroup.setMesh(myMeshing) -myGroup.setEntity(MED_CELL) -myGroup.setNumberOfGeometricType(2) - -myTypes = [MED_TETRA4,MED_PYRA5] -myGroup.setGeometricType(myTypes) - -myNumberOfElements = [4,1] -myGroup.setNumberOfElements(myNumberOfElements) - -index = [1,5,6] -values = [ - 3,4,5,9, - 14 - ] -myGroup.setNumber(index,values) - -myMeshing.addGroup(myGroup) - -# on Face - -myGroup = GROUP() -myGroup.setName("SomeFaces") -myGroup.setMesh(myMeshing) -myGroup.setEntity(MED_FACE) -myGroup.setNumberOfGeometricType(2) - -myTypes = [MED_TRIA3,MED_QUAD4] -myGroup.setGeometricType(myTypes) - -myNumberOfElements = [2,3] -myGroup.setNumberOfElements(myNumberOfElements) - -index = [1,3,6] -values = [ - 2,4, - 5,6,8 - ] -myGroup.setNumber(index,values) - -myMeshing.addGroup(myGroup) - -myGroup = GROUP() -myGroup.setName("OtherFaces") -myGroup.setMesh(myMeshing) -myGroup.setEntity(MED_FACE) -myGroup.setNumberOfGeometricType(1) - -myTypes = [MED_TRIA3] -myGroup.setGeometricType(myTypes) - -myNumberOfElements = [2] -myGroup.setNumberOfElements(myNumberOfElements) - -index = [1,3] -values = [ - 1,3 - ] -myGroup.setNumber(index,values) - -myMeshing.addGroup(myGroup) - -# saving of the generated mesh in MED and VTK format - -driver = MED_MESH_WRONLY_DRIVER( med22FileName, myMeshing ) -myMeshing.write(driver) - -myMeshing.write(VTK_DRIVER,vtkFileName) - -# we build now 8 fields : 4 fields double (integer) : -# 2 fields on nodes (cells) : -# 1 scalar (vector) - -supportOnNodes = myMeshing.getSupportOnAll(MED_NODE) -numberOfNodes = supportOnNodes.getNumberOfElements(MED_ALL_ELEMENTS) - -supportOnCells = myMeshing.getSupportOnAll(MED_CELL) -numberOfCells = supportOnCells.getNumberOfElements(MED_ALL_ELEMENTS) - -fieldDoubleScalarOnNodes = FIELDDOUBLE(supportOnNodes,1) -fieldDoubleScalarOnNodes.setName("fieldScalarDoubleNode") -fieldDoubleScalarOnNodes.setIterationNumber(-1) -fieldDoubleScalarOnNodes.setOrderNumber(-1) -fieldDoubleScalarOnNodes.setTime(0.0) - -fieldDoubleScalarOnNodes.setComponentName(1,"Vx") -fieldDoubleScalarOnNodes.setComponentDescription(1,"comp1") -fieldDoubleScalarOnNodes.setMEDComponentUnit(1,"unit1") - -fieldDoubleVectorOnNodes = FIELDDOUBLE(supportOnNodes,spaceDimension) -fieldDoubleVectorOnNodes.setName("fieldVectorDoubleNode") -fieldDoubleVectorOnNodes.setIterationNumber(-1) -fieldDoubleVectorOnNodes.setOrderNumber(-1) -fieldDoubleVectorOnNodes.setTime(0.0) - -fieldDoubleVectorOnNodes.setComponentName(1,"Vx") -fieldDoubleVectorOnNodes.setComponentDescription(1,"comp1") -fieldDoubleVectorOnNodes.setMEDComponentUnit(1,"unit1") -fieldDoubleVectorOnNodes.setComponentName(2,"Vy") -fieldDoubleVectorOnNodes.setComponentDescription(2,"comp2") -fieldDoubleVectorOnNodes.setMEDComponentUnit(2,"unit2") -fieldDoubleVectorOnNodes.setComponentName(3,"Vz") -fieldDoubleVectorOnNodes.setComponentDescription(3,"comp3") -fieldDoubleVectorOnNodes.setMEDComponentUnit(3,"unit3") - -fieldDoubleScalarOnCells = FIELDDOUBLE(supportOnCells,1) -fieldDoubleScalarOnCells.setName("fieldScalarDoubleCell") -fieldDoubleScalarOnCells.setIterationNumber(-1) -fieldDoubleScalarOnCells.setOrderNumber(-1) -fieldDoubleScalarOnCells.setTime(0.0) - -fieldDoubleScalarOnCells.setComponentName(1,"Vx") -fieldDoubleScalarOnCells.setComponentDescription(1,"comp1") -fieldDoubleScalarOnCells.setMEDComponentUnit(1,"unit1") - -fieldDoubleVectorOnCells = FIELDDOUBLE(supportOnCells,spaceDimension) -fieldDoubleVectorOnCells.setName("fieldVectorrDoubleCell") -fieldDoubleVectorOnCells.setIterationNumber(-1) -fieldDoubleVectorOnCells.setOrderNumber(-1) -fieldDoubleVectorOnCells.setTime(0.0) - -fieldDoubleVectorOnCells.setComponentName(1,"Vx") -fieldDoubleVectorOnCells.setComponentDescription(1,"comp1") -fieldDoubleVectorOnCells.setMEDComponentUnit(1,"unit1") -fieldDoubleVectorOnCells.setComponentName(2,"Vy") -fieldDoubleVectorOnCells.setComponentDescription(2,"comp2") -fieldDoubleVectorOnCells.setMEDComponentUnit(2,"unit2") -fieldDoubleVectorOnCells.setComponentName(3,"Vz") -fieldDoubleVectorOnCells.setComponentDescription(3,"comp3") -fieldDoubleVectorOnCells.setMEDComponentUnit(3,"unit3") - -fieldIntScalarOnNodes = FIELDINT(supportOnNodes,1) -fieldIntScalarOnNodes.setName("fieldScalarIntNode") -fieldIntScalarOnNodes.setIterationNumber(-1) -fieldIntScalarOnNodes.setOrderNumber(-1) -fieldIntScalarOnNodes.setTime(0.0) - -fieldIntScalarOnNodes.setComponentName(1,"Vx") -fieldIntScalarOnNodes.setComponentDescription(1,"comp1") -fieldIntScalarOnNodes.setMEDComponentUnit(1,"unit1") - -fieldIntVectorOnNodes = FIELDINT(supportOnNodes,spaceDimension) -fieldIntVectorOnNodes.setName("fieldVectorIntNode") -fieldIntVectorOnNodes.setIterationNumber(-1) -fieldIntVectorOnNodes.setOrderNumber(-1) -fieldIntVectorOnNodes.setTime(0.0) - -fieldIntVectorOnNodes.setComponentName(1,"Vx") -fieldIntVectorOnNodes.setComponentDescription(1,"comp1") -fieldIntVectorOnNodes.setMEDComponentUnit(1,"unit1") -fieldIntVectorOnNodes.setComponentName(2,"Vy") -fieldIntVectorOnNodes.setComponentDescription(2,"comp2") -fieldIntVectorOnNodes.setMEDComponentUnit(2,"unit2") -fieldIntVectorOnNodes.setComponentName(3,"Vz") -fieldIntVectorOnNodes.setComponentDescription(3,"comp3") -fieldIntVectorOnNodes.setMEDComponentUnit(3,"unit3") - -fieldIntScalarOnCells = FIELDINT(supportOnCells,1) -fieldIntScalarOnCells.setName("fieldScalarIntCell") -fieldIntScalarOnCells.setIterationNumber(-1) -fieldIntScalarOnCells.setOrderNumber(-1) -fieldIntScalarOnCells.setTime(0.0) - -fieldIntScalarOnCells.setComponentName(1,"Vx") -fieldIntScalarOnCells.setComponentDescription(1,"comp1") -fieldIntScalarOnCells.setMEDComponentUnit(1,"unit1") - -fieldIntVectorOnCells = FIELDINT(supportOnCells,spaceDimension) -fieldIntVectorOnCells.setName("fieldVectorrIntCell") -fieldIntVectorOnCells.setIterationNumber(-1) -fieldIntVectorOnCells.setOrderNumber(-1) -fieldIntVectorOnCells.setTime(0.0) - -fieldIntVectorOnCells.setComponentName(1,"Vx") -fieldIntVectorOnCells.setComponentDescription(1,"comp1") -fieldIntVectorOnCells.setMEDComponentUnit(1,"unit1") -fieldIntVectorOnCells.setComponentName(2,"Vy") -fieldIntVectorOnCells.setComponentDescription(2,"comp2") -fieldIntVectorOnCells.setMEDComponentUnit(2,"unit2") -fieldIntVectorOnCells.setComponentName(3,"Vz") -fieldIntVectorOnCells.setComponentDescription(3,"comp3") -fieldIntVectorOnCells.setMEDComponentUnit(3,"unit3") - -for i in range(numberOfNodes): - valueInt1 = i+1 - valueInt2 = i+2 - valueInt3 = i+3 - valueDbl1 = valueInt1*0.1 - valueDbl2 = valueInt2*0.1 - valueDbl3 = valueInt3*0.1 - fieldDoubleScalarOnNodes.setValueIJ(i+1,1,valueDbl1) - - fieldIntScalarOnNodes.setValueIJ(i+1,1,valueInt1) - - fieldDoubleVectorOnNodes.setValueIJ(i+1,1,valueDbl1) - fieldDoubleVectorOnNodes.setValueIJ(i+1,2,valueDbl2) - fieldDoubleVectorOnNodes.setValueIJ(i+1,3,valueDbl3) - - fieldIntVectorOnNodes.setValueIJ(i+1,1,valueInt1) - fieldIntVectorOnNodes.setValueIJ(i+1,2,valueInt2) - fieldIntVectorOnNodes.setValueIJ(i+1,3,valueInt3) - -for i in range(numberOfCells): - valueInt1 = i+1 - valueInt2 = i+2 - valueInt3 = i+3 - valueDbl1 = valueInt1*0.1 - valueDbl2 = valueInt2*0.1 - valueDbl3 = valueInt3*0.1 - fieldDoubleScalarOnCells.setValueIJ(i+1,1,valueDbl1) - - fieldIntScalarOnCells.setValueIJ(i+1,1,valueInt1) - - fieldDoubleVectorOnCells.setValueIJ(i+1,1,valueDbl1) - fieldDoubleVectorOnCells.setValueIJ(i+1,2,valueDbl2) - fieldDoubleVectorOnCells.setValueIJ(i+1,3,valueDbl3) - - fieldIntVectorOnCells.setValueIJ(i+1,1,valueInt1) - fieldIntVectorOnCells.setValueIJ(i+1,2,valueInt2) - fieldIntVectorOnCells.setValueIJ(i+1,3,valueInt3) - -driver = MED_FIELDDOUBLE_WRONLY_DRIVER(med22FileName,fieldDoubleScalarOnNodes) -driver.open() -driver.write() -driver.close() - -driver = MED_FIELDINT_WRONLY_DRIVER(med22FileName,fieldIntScalarOnNodes) -fieldIntScalarOnNodes.write(driver) - -idMedV22 = fieldDoubleScalarOnCells.addDriver(MED_DRIVER,med22FileName) -fieldDoubleScalarOnCells.write(idMedV22) - -fieldDoubleVectorOnNodes.write(MED_DRIVER,med22FileName) -fieldIntVectorOnNodes.write (MED_DRIVER,med22FileName) -fieldIntScalarOnCells.write (MED_DRIVER,med22FileName) -fieldDoubleVectorOnCells.write(MED_DRIVER,med22FileName) -fieldIntVectorOnCells.write (MED_DRIVER,med22FileName) - - -idVtk = fieldDoubleScalarOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleScalarOnNodes.getName()) -fieldDoubleScalarOnNodes.writeAppend(idVtk) - -idVtk = fieldIntScalarOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldIntScalarOnNodes.getName()) -fieldIntScalarOnNodes.writeAppend(idVtk) - -idVtk = fieldDoubleVectorOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleVectorOnNodes.getName()) -fieldDoubleVectorOnNodes.writeAppend(idVtk) - -idVtk = fieldIntVectorOnNodes.addDriver(VTK_DRIVER,vtkFileName,fieldIntVectorOnNodes.getName()) -fieldIntVectorOnNodes.writeAppend(idVtk) - -idVtk = fieldDoubleScalarOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleScalarOnCells.getName()) -fieldDoubleScalarOnCells.writeAppend(idVtk) - -idVtk = fieldIntScalarOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldIntScalarOnCells.getName()) -fieldIntScalarOnCells.writeAppend(idVtk) - -idVtk = fieldDoubleVectorOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldDoubleVectorOnCells.getName()) -fieldDoubleVectorOnCells.writeAppend(idVtk) - -idVtk = fieldIntVectorOnCells.addDriver(VTK_DRIVER,vtkFileName,fieldIntVectorOnCells.getName()) -fieldIntVectorOnCells.writeAppend(idVtk) diff --git a/src/MEDMEM_SWIG/medNumPy_test.py b/src/MEDMEM_SWIG/medNumPy_test.py deleted file mode 100644 index c4364fc38..000000000 --- a/src/MEDMEM_SWIG/medNumPy_test.py +++ /dev/null @@ -1,186 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Check that numpy arrays can be used to define coordinates, connectivities and field values - -import unittest -from libMEDMEM_Swig import * - -class medNumPyTest(unittest.TestCase): - def test0(self): - - try: - from numpy import array, arange, ndarray - except: - # numpy is not available, it is not an error - print "numpy unavailable" - return - - myMeshing = MESHING() - myMeshing.setName("meshing") - - spaceDimension = 3 - numberOfNodes = 19 - coordinates = [0.0, 0.0, 0.0 , - 0.0, 0.0, 1.0 , - 2.0, 0.0, 1.0 , - 0.0, 2.0, 1.0 , - -2.0, 0.0, 1.0 , - 0.0, -2.0, 1.0 , - 1.0, 1.0, 2.0 , - -1.0, 1.0, 2.0 , - -1.0, -1.0, 2.0, - 1.0, -1.0, 2.0 , - 1.0, 1.0, 3.0 , - -1.0, 1.0, 3.0 , - -1.0, -1.0, 3.0, - 1.0, -1.0, 3.0 , - 1.0, 1.0, 4.0 , - -1.0, 1.0, 4.0 , - -1.0, -1.0, 4.0, - 1.0, -1.0, 4.0 , - 0.0, 0.0, 5.0 ] - - myMeshing.setCoordinates(spaceDimension,numberOfNodes, array( coordinates ), - "CARTESIAN",MED_FULL_INTERLACE) - coord = myMeshing.getCoordinates(MED_FULL_INTERLACE) - self.assertTrue( isinstance( coord, ndarray )) - - units = ["cm ", "cm ", "cm "] - names = ["X ", "Y ", "Z "] - myMeshing.setCoordinatesNames(names) - myMeshing.setCoordinatesUnits(units) - - # definition of connectivities - - numberOfTypes = 1 - entity = MED_CELL - - types = [MED_TETRA4] - numberOfElements = [12] - - myMeshing.setNumberOfTypes(numberOfTypes,entity) - myMeshing.setTypes(types,entity) - myMeshing.setNumberOfElements(numberOfElements,entity) - - connectivityTetra = [1,2,3,6, - 1,2,4,3 , - 1,2,5,4 , - 1,2,6,5 , - 2,7,4,3 , - 2,8,5,4 , - 2,9,6,5 , - 2,10,3,6, - 2,7,3,10, - 2,8,4,7 , - 2,9,5,8 , - 2,10,6,9] - - myMeshing.setConnectivity(entity,types[0], array( connectivityTetra )) - conn = myMeshing.getConnectivity(MED_NODAL,entity,MED_ALL_ELEMENTS) - self.assertTrue( isinstance( conn, ndarray )) - - myGroup = GROUP() - myGroup.setName("SomeCells") - myGroup.setMesh(myMeshing) - myGroup.setEntity(MED_CELL) - myGroup.setNumberOfGeometricType(1) - - myGroup.setGeometricType(types) - myNumberOfElements = [4,1,2] - myGroup.setNumberOfElements(myNumberOfElements) - - index = [1,5,6,8] - values = [2,7,8,12,13,15,16] - myGroup.setNumber( array( index ), array( values )) - - myMeshing.addGroup(myGroup) - - # saving the generated mesh in MED - - import os - tmpDir = os.getenv("TMP") - if not tmpDir: - tmpDir = os.getenv("TMPDIR", "/tmp") - - filename = os.path.join(tmpDir,"medNumPy_test.med") - myMeshing.write(MED_DRIVER,filename) - - # we build now 2 fields - - supportOnNodes = SUPPORT(myMeshing,"On_All_Nodes",MED_NODE) - numberOfNodes = supportOnNodes.getNumberOfElements(MED_ALL_ELEMENTS) - - fieldDoubleScalarOnNodes = FIELDDOUBLE(supportOnNodes,1) - fieldDoubleScalarOnNodes.setName("fieldScalarDoubleNode") - fieldDoubleScalarOnNodes.setIterationNumber(-1) - fieldDoubleScalarOnNodes.setOrderNumber(-1) - fieldDoubleScalarOnNodes.setTime(0.0) - - fieldDoubleScalarOnNodes.setComponentName(1,"Vx") - fieldDoubleScalarOnNodes.setComponentDescription(1,"comp1") - fieldDoubleScalarOnNodes.setMEDComponentUnit(1,"unit1") - - nodeValues = arange( numberOfNodes, dtype=float ) - fieldDoubleScalarOnNodes.setValue( nodeValues ) - - resValue = fieldDoubleScalarOnNodes.getValue() - self.assertTrue( isinstance( resValue, ndarray )) - - intArray = arange( numberOfNodes, dtype=int ) - self.assertRaises( TypeError, fieldDoubleScalarOnNodes.setValue, intArray ) - - fieldDoubleScalarOnNodes.write(MED_DRIVER,filename) - - - supportOnCells = SUPPORT(myMeshing,"On_All_Cells",MED_CELL) - numberOfCells = supportOnCells.getNumberOfElements(MED_ALL_ELEMENTS) - - fieldIntScalarOnCells = FIELDINT(supportOnCells,1) - fieldIntScalarOnCells.setName("fieldScalarIntCell") - fieldIntScalarOnCells.setIterationNumber(-1) - fieldIntScalarOnCells.setOrderNumber(-1) - fieldIntScalarOnCells.setTime(0.0) - - fieldIntScalarOnCells.setComponentName(1,"Vx") - fieldIntScalarOnCells.setComponentDescription(1,"comp1") - fieldIntScalarOnCells.setMEDComponentUnit(1,"unit1") - - cellValues = arange(numberOfCells) - fieldIntScalarOnCells.setValue( cellValues ) - - resValue = fieldIntScalarOnCells.getValue() - self.assertTrue( isinstance( resValue, ndarray )) - self.assertTrue( len(resValue) == numberOfCells) - - dblArray = arange( numberOfNodes, dtype=float ) - self.assertRaises( TypeError, fieldIntScalarOnCells.setValue, dblArray ) - - fieldIntScalarOnCells.write(MED_DRIVER,filename) - - os.remove( filename ) - - def setUp(self): - pass - -unittest.main() diff --git a/src/MEDMEM_SWIG/med_field_anal.py b/src/MEDMEM_SWIG/med_field_anal.py deleted file mode 100755 index 252e030cd..000000000 --- a/src/MEDMEM_SWIG/med_field_anal.py +++ /dev/null @@ -1,583 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -############################################################################ -# This Python script is testing the generation of MED field using a -# user-callable function with different number of components and -# different SUPPORTs. -############################################################################ -# -from math import * - -def f_scal_dbl_2d(x, y): - ret = [] - ret.append(x + y) - return ret - -def f_scal_dbl_3d(x, y, z): - ret = [] - ret.append(x + y + z) - return ret - -def f_vect_dbl_2d(x, y): - ret = [] - ret.append(x + y) - ret.append(2.*(x + y)) - return ret - -def f_vect_dbl_3d(x, y, z): - ret = [] - ret.append(x + y + z) - ret.append(2.*(x + y + z)) - ret.append(3.*(x + y + z)) - return ret - -def f_scal_int_2d(x, y): - ret = [] - ret_tmp = x + y - ret_tmp = int(ret_tmp) - ret.append(ret_tmp) - return ret - -def f_scal_int_3d(x, y, z): - ret = [] - ret_tmp = x + y + z - ret_tmp = int(ret_tmp) - ret.append(ret_tmp) - return ret - -def f_vect_int_2d(x, y): - ret = [] - ret.append(int(x + y)) - ret.append(int(2.*(x + y))) - return ret - -def f_vect_int_3d(x, y, z): - ret = [] - ret.append(int(x + y + z)) - ret.append(int(2.*(x + y + z))) - ret.append(int(3.*(x + y + z))) - return ret - -from libMEDMEM_Swig import * -from random import * -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, "carre_en_quad4_seg2.med") -medFile = os.path.join(filePath, "cube_hexa8_quad4.med") - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `i`+'th' - -md = MEDFILEBROWSER(medFile) -nbMeshes = md.getNumberOfMeshes() - -print "The med file", medFile, "contains", nbMeshes, "mesh(es)" - -mesh_name = md.getMeshName(0) -mesh = MESH(MED_DRIVER,medFile,mesh_name) -spaceDim = mesh.getSpaceDimension() -meshDim = mesh.getMeshDimension() -nbNodes = mesh.getNumberOfNodes() - -print "" -print "The mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes" - -supportOnCell = mesh.getSupportOnAll(MED_CELL) - -supportOnNode = mesh.getSupportOnAll(MED_NODE) - -if (spaceDim == 3) : - supportOnConst = mesh.getSupportOnAll(MED_FACE) -elif (spaceDim == 2) : - supportOnConst = mesh.getSupportOnAll(MED_EDGE) - -##print "" -##print supportOnCell - -if (spaceDim == 2) : - fieldDoubleScalOnCell = createFieldDoubleFromAnalytic(supportOnCell,1, - f_scal_dbl_2d) - fieldDoubleVectOnCell = createFieldDoubleFromAnalytic(supportOnCell, - spaceDim, - f_vect_dbl_2d) - fieldIntScalOnCell = createFieldIntFromAnalytic(supportOnCell,1, - f_scal_int_2d) - fieldIntVectOnCell = createFieldIntFromAnalytic(supportOnCell,spaceDim, - f_vect_int_2d) -elif (spaceDim == 3) : - fieldDoubleScalOnCell = createFieldDoubleFromAnalytic(supportOnCell,1, - f_scal_dbl_3d) - fieldDoubleVectOnCell = createFieldDoubleFromAnalytic(supportOnCell, - spaceDim, - f_vect_dbl_3d) - fieldIntScalOnCell = createFieldIntFromAnalytic(supportOnCell,1, - f_scal_int_3d) - fieldIntVectOnCell = createFieldIntFromAnalytic(supportOnCell,spaceDim, - f_vect_int_3d) - -fieldDoubleScalOnCell.setName("Scalar Double Field on all Cells") -fieldDoubleScalOnCell.setDescription("Generated via a Python function") - -fieldDoubleVectOnCell.setName("Vector Double Field on all Cells") -fieldDoubleVectOnCell.setDescription("Generated via a Python function") - -fieldIntScalOnCell.setName("Scalar Integer Field on all Cells") -fieldIntScalOnCell.setDescription("Generated via a Python function") - -fieldIntVectOnCell.setName("Vector Integer Field on all Cells") -fieldIntVectOnCell.setDescription("Generated via a Python function") - -name = fieldDoubleScalOnCell.getName() -desc = fieldDoubleScalOnCell.getDescription() -nbOfComp = fieldDoubleScalOnCell.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldDoubleScalOnCell.getIterationNumber() -orderNb = fieldDoubleScalOnCell.getOrderNumber() -time = fieldDoubleScalOnCell.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldDoubleScalOnCell.getComponentName(kp1) - compDesc = fieldDoubleScalOnCell.getComponentDescription(kp1) - compUnit = fieldDoubleScalOnCell.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldDoubleScalOnCell.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldDoubleScalOnCell.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldDoubleVectOnCell.getName() -desc = fieldDoubleVectOnCell.getDescription() -nbOfComp = fieldDoubleVectOnCell.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldDoubleVectOnCell.getIterationNumber() -orderNb = fieldDoubleVectOnCell.getOrderNumber() -time = fieldDoubleVectOnCell.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldDoubleVectOnCell.getComponentName(kp1) - compDesc = fieldDoubleVectOnCell.getComponentDescription(kp1) - compUnit = fieldDoubleVectOnCell.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldDoubleVectOnCell.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldDoubleVectOnCell.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldIntScalOnCell.getName() -desc = fieldIntScalOnCell.getDescription() -nbOfComp = fieldIntScalOnCell.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldIntScalOnCell.getIterationNumber() -orderNb = fieldIntScalOnCell.getOrderNumber() -time = fieldIntScalOnCell.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldIntScalOnCell.getComponentName(kp1) - compDesc = fieldIntScalOnCell.getComponentDescription(kp1) - compUnit = fieldIntScalOnCell.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldIntScalOnCell.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldIntScalOnCell.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldIntVectOnCell.getName() -desc = fieldIntVectOnCell.getDescription() -nbOfComp = fieldIntVectOnCell.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldIntVectOnCell.getIterationNumber() -orderNb = fieldIntVectOnCell.getOrderNumber() -time = fieldIntVectOnCell.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldIntVectOnCell.getComponentName(kp1) - compDesc = fieldIntVectOnCell.getComponentDescription(kp1) - compUnit = fieldIntVectOnCell.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldIntVectOnCell.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldIntVectOnCell.getRow(k+1) - print " *",valueI[:nbOfComp] - -##print "" -##print supportOnNode - -if (spaceDim == 2) : - fieldDoubleScalOnNode = createFieldDoubleFromAnalytic(supportOnNode,1, - f_scal_dbl_2d) - fieldDoubleVectOnNode = createFieldDoubleFromAnalytic(supportOnNode, - spaceDim, - f_vect_dbl_2d) - fieldIntScalOnNode = createFieldIntFromAnalytic(supportOnNode,1, - f_scal_int_2d) - fieldIntVectOnNode = createFieldIntFromAnalytic(supportOnNode, spaceDim, - f_vect_int_2d) -elif (spaceDim == 3) : - fieldDoubleScalOnNode = createFieldDoubleFromAnalytic(supportOnNode,1, - f_scal_dbl_3d) - fieldDoubleVectOnNode = createFieldDoubleFromAnalytic(supportOnNode, - spaceDim, - f_vect_dbl_3d) - fieldIntScalOnNode = createFieldIntFromAnalytic(supportOnNode,1, - f_scal_int_3d) - fieldIntVectOnNode = createFieldIntFromAnalytic(supportOnNode, spaceDim, - f_vect_int_3d) - -fieldDoubleScalOnNode.setName("Scalar Double Field on all Nodes") -fieldDoubleScalOnNode.setDescription("Generated via a Python function") - -fieldDoubleVectOnNode.setName("Vector Double Field on all Nodes") -fieldDoubleVectOnNode.setDescription("Generated via a Python function") - -fieldIntScalOnNode.setName("Scalar Integer Field on all Nodes") -fieldIntScalOnNode.setDescription("Generated via a Python function") - -fieldIntVectOnNode.setName("Vector Integer Field on all Nodes") -fieldIntVectOnNode.setDescription("Generated via a Python function") - -print "" -name = fieldDoubleScalOnNode.getName() -desc = fieldDoubleScalOnNode.getDescription() -nbOfComp = fieldDoubleScalOnNode.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldDoubleScalOnNode.getIterationNumber() -orderNb = fieldDoubleScalOnNode.getOrderNumber() -time = fieldDoubleScalOnNode.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldDoubleScalOnNode.getComponentName(kp1) - compDesc = fieldDoubleScalOnNode.getComponentDescription(kp1) - compUnit = fieldDoubleScalOnNode.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldDoubleScalOnNode.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldDoubleScalOnNode.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldDoubleVectOnNode.getName() -desc = fieldDoubleVectOnNode.getDescription() -nbOfComp = fieldDoubleVectOnNode.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldDoubleVectOnNode.getIterationNumber() -orderNb = fieldDoubleVectOnNode.getOrderNumber() -time = fieldDoubleVectOnNode.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldDoubleVectOnNode.getComponentName(kp1) - compDesc = fieldDoubleVectOnNode.getComponentDescription(kp1) - compUnit = fieldDoubleVectOnNode.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldDoubleVectOnNode.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldDoubleVectOnNode.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldIntScalOnNode.getName() -desc = fieldIntScalOnNode.getDescription() -nbOfComp = fieldIntScalOnNode.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldIntScalOnNode.getIterationNumber() -orderNb = fieldIntScalOnNode.getOrderNumber() -time = fieldIntScalOnNode.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldIntScalOnNode.getComponentName(kp1) - compDesc = fieldIntScalOnNode.getComponentDescription(kp1) - compUnit = fieldIntScalOnNode.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldIntScalOnNode.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldIntScalOnNode.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldIntVectOnNode.getName() -desc = fieldIntVectOnNode.getDescription() -nbOfComp = fieldIntVectOnNode.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldIntVectOnNode.getIterationNumber() -orderNb = fieldIntVectOnNode.getOrderNumber() -time = fieldIntVectOnNode.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldIntVectOnNode.getComponentName(kp1) - compDesc = fieldIntVectOnNode.getComponentDescription(kp1) - compUnit = fieldIntVectOnNode.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldIntVectOnNode.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldIntVectOnNode.getRow(k+1) - print " *",valueI[:nbOfComp] - -##print "" -##print supportOnConst - -if (spaceDim == 2) : - fieldDoubleScalOnConst = createFieldDoubleFromAnalytic(supportOnConst,1, - f_scal_dbl_2d) - fieldDoubleVectOnConst = createFieldDoubleFromAnalytic(supportOnConst, - spaceDim, - f_vect_dbl_2d) - fieldIntScalOnConst = createFieldIntFromAnalytic(supportOnConst,1, - f_scal_int_2d) - fieldIntVectOnConst = createFieldIntFromAnalytic(supportOnConst, spaceDim, - f_vect_int_2d) -elif (spaceDim == 3) : - fieldDoubleScalOnConst = createFieldDoubleFromAnalytic(supportOnConst,1, - f_scal_dbl_3d) - fieldDoubleVectOnConst = createFieldDoubleFromAnalytic(supportOnConst, - spaceDim, - f_vect_dbl_3d) - fieldIntScalOnConst = createFieldIntFromAnalytic(supportOnConst,1, - f_scal_int_3d) - fieldIntVectOnConst = createFieldIntFromAnalytic(supportOnConst, spaceDim, - f_vect_int_3d) - -fieldDoubleScalOnConst.setName("Scalar Double Field on all Faces/Edges") -fieldDoubleScalOnConst.setDescription("Generated via a Python function") - -fieldDoubleVectOnConst.setName("Vector Double Field on all Faces/Edges") -fieldDoubleVectOnConst.setDescription("Generated via a Python function") - -fieldIntScalOnConst.setName("Scalar Integer Field on all Faces/Edges") -fieldIntScalOnConst.setDescription("Generated via a Python function") - -fieldIntVectOnConst.setName("Vector Integer Field on all Faces/Edges") -fieldIntVectOnConst.setDescription("Generated via a Python function") - -print "" -name = fieldDoubleScalOnConst.getName() -desc = fieldDoubleScalOnConst.getDescription() -nbOfComp = fieldDoubleScalOnConst.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldDoubleScalOnConst.getIterationNumber() -orderNb = fieldDoubleScalOnConst.getOrderNumber() -time = fieldDoubleScalOnConst.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldDoubleScalOnConst.getComponentName(kp1) - compDesc = fieldDoubleScalOnConst.getComponentDescription(kp1) - compUnit = fieldDoubleScalOnConst.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldDoubleScalOnConst.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldDoubleScalOnConst.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldDoubleVectOnConst.getName() -desc = fieldDoubleVectOnConst.getDescription() -nbOfComp = fieldDoubleVectOnConst.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldDoubleVectOnConst.getIterationNumber() -orderNb = fieldDoubleVectOnConst.getOrderNumber() -time = fieldDoubleVectOnConst.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldDoubleVectOnConst.getComponentName(kp1) - compDesc = fieldDoubleVectOnConst.getComponentDescription(kp1) - compUnit = fieldDoubleVectOnConst.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldDoubleVectOnConst.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldDoubleVectOnConst.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldIntScalOnConst.getName() -desc = fieldIntScalOnConst.getDescription() -nbOfComp = fieldIntScalOnConst.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldIntScalOnConst.getIterationNumber() -orderNb = fieldIntScalOnConst.getOrderNumber() -time = fieldIntScalOnConst.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldIntScalOnConst.getComponentName(kp1) - compDesc = fieldIntScalOnConst.getComponentDescription(kp1) - compUnit = fieldIntScalOnConst.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldIntScalOnConst.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldIntScalOnConst.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -name = fieldIntVectOnConst.getName() -desc = fieldIntVectOnConst.getDescription() -nbOfComp = fieldIntVectOnConst.getNumberOfComponents() -print " Field",name," : ",desc -print " Number Of Components:",nbOfComp -iterationNb = fieldIntVectOnConst.getIterationNumber() -orderNb = fieldIntVectOnConst.getOrderNumber() -time = fieldIntVectOnConst.getTime() -print " Iteration Number",iterationNb -print " Order Number",orderNb -print " Time",time -for k in range(nbOfComp): - kp1 = k+1 - compName = fieldIntVectOnConst.getComponentName(kp1) - compDesc = fieldIntVectOnConst.getComponentDescription(kp1) - compUnit = fieldIntVectOnConst.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - -support = fieldIntVectOnConst.getSupport() -nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) -print " Values:",nbOf -for k in range(nbOf): - valueI = fieldIntVectOnConst.getRow(k+1) - print " *",valueI[:nbOfComp] - -print "" -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_opfield_test.py b/src/MEDMEM_SWIG/med_opfield_test.py deleted file mode 100755 index a31b7254b..000000000 --- a/src/MEDMEM_SWIG/med_opfield_test.py +++ /dev/null @@ -1,532 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -############################################################################ -# this Python script is testing all operations between FIELD(DOUBLE,INT) -############################################################################ -# -from libMEDMEM_Swig import * -from random import * -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join( filePath, "pointe.med" ) - -def add_one(i): - return i+1 - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `i`+'th' - -md = MEDFILEBROWSER(medFile) -nbMeshes = md.getNumberOfMeshes() -nbFields = md.getNumberOfFields() - -print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)" - -if (nbMeshes>0): - print "Mesh(es) Name(s) is(are) " - - for i in range(nbMeshes): - mesh_name = md.getMeshName(i) - print " - ",mesh_name - -if (nbFields>0): - print "Field(s) Name(s) is(are) " - - for i in range(nbFields): - field_name = md.getFieldName(i) - print " - ",field_name - -print "" - -mesh_name = md.getMeshName(0) -mesh = MESH(MED_DRIVER,md.getFileName(),mesh_name) -spaceDim = mesh.getSpaceDimension() -meshDim = mesh.getMeshDimension() -nbNodes = mesh.getNumberOfNodes() -print "The mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes" - -if (nbFields>0): - print "" - print "Field(s) Analysis " - for i in range(nbFields): - print "" - field_name = md.getFieldName(i) - dtits = md.getFieldIteration(field_name) - nbOfIt = len(dtits) - print "The",print_ord(i),"field is",field_name,"with",nbOfIt,"iteration(s)" - for dtitfield in dtits: - print "" - dt = dtitfield.getdt() - it = dtitfield.getit() - type = md.getFieldType(field_name) - print " * Iteration:",dt,"Order number:",it,"Type:",type - if type == MED_INT32: - fieldint = FIELDINT(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh) - name = fieldint.getName() - desc = fieldint.getDescription() - nbOfComp = fieldint.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldint.getIterationNumber() - orderNb = fieldint.getOrderNumber() - time = fieldint.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - print "Norme 2 : ", fieldint.norm2() - print "Norme Max : ", fieldint.normMax() - - if fielddouble.getSupport().getEntity()!=MED_NODE: - fieldint_vol=fieldint.getSupport().getMesh().getVolume(fieldint.getSupport()) - print "Norme L1 : ", fieldint.normL1() - print "Norme L2 : ", fieldint.normL2() - print "Norme L2(vol) : ", fieldint.normL2(fieldint_vol) - - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldint.getComponentName(kp1) - compDesc = fieldint.getComponentDescription(kp1) - compUnit = fieldint.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - if fielddouble.getSupport().getEntity()!=MED_NODE: - print " Norme L1 : ", fieldint.normL1(kp1) - print " Norme L2 : ", fieldint.normL2(kp1) - print " Norme L2(vol) : ", fieldint.normL2(kp1,fieldint_vol) - - support = fieldint.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldint.getRow(k+1) - print " *",valueI[:nbOfComp] - fieldint2 = FIELDINT(fieldint) - print "" - fieldintadd = fieldint + fieldint2 - print "Test of the addition of two integer fields with creation a new one" - print "" - name = fieldintadd.getName() - desc = fieldintadd.getDescription() - nbOfComp = fieldintadd.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintadd.getIterationNumber() - orderNb = fieldintadd.getOrderNumber() - time = fieldintadd.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintadd.getComponentName(kp1) - compDesc = fieldintadd.getComponentDescription(kp1) - compUnit = fieldintadd.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintadd.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintadd.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fieldintsub = fieldint - fieldint2 - print "Test of the substraction of two integer fields with creation a new one" - print "" - name = fieldintsub.getName() - desc = fieldintsub.getDescription() - nbOfComp = fieldintsub.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintsub.getIterationNumber() - orderNb = fieldintsub.getOrderNumber() - time = fieldintsub.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintsub.getComponentName(kp1) - compDesc = fieldintsub.getComponentDescription(kp1) - compUnit = fieldintsub.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintsub.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintsub.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fieldintmul = fieldint * fieldint2 - print "Test of the multiplication of two integer fields with creation a new one" - print "" - name = fieldintmul.getName() - desc = fieldintmul.getDescription() - nbOfComp = fieldintmul.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintmul.getIterationNumber() - orderNb = fieldintmul.getOrderNumber() - time = fieldintmul.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintmul.getComponentName(kp1) - compDesc = fieldintmul.getComponentDescription(kp1) - compUnit = fieldintmul.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintmul.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintmul.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - try: - fieldintdiv = fieldint / fieldint2 - print "Test of the division of two integer fields with creation a new one" - print "" - name = fieldintdiv.getName() - desc = fieldintdiv.getDescription() - nbOfComp = fieldintdiv.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintdiv.getIterationNumber() - orderNb = fieldintdiv.getOrderNumber() - time = fieldintdiv.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintdiv.getComponentName(kp1) - compDesc = fieldintdiv.getComponentDescription(kp1) - compUnit = fieldintdiv.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintdiv.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintdiv.getRow(k+1) - print " *",valueI[:nbOfComp] - - except: - print "fieldintdiv = fieldint / fieldint2 catch/except error" - elif type == MED_REEL64: - fielddouble = FIELDDOUBLE(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh) - name = fielddouble.getName() - desc = fielddouble.getDescription() - nbOfComp = fielddouble.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddouble.getIterationNumber() - orderNb = fielddouble.getOrderNumber() - time = fielddouble.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - print "Norme 2 : ", fielddouble.norm2() - print "Norme Max : ", fielddouble.normMax() - print "try sobolev",fielddouble.getSupport().getEntity() - if fielddouble.getSupport().getEntity()!=MED_NODE: - if (spaceDim == 3) : - fielddouble_vol=fielddouble.getSupport().getMesh().getVolume(fielddouble.getSupport()) - elif (spaceDim == 2): - fielddouble_vol=fielddouble.getSupport().getMesh().getArea(fielddouble.getSupport()) - print "Norme L1 : ", fielddouble.normL1() - print "Norme L2 : ", fielddouble.normL2() - print "Norme L2(vol) : ", fielddouble.normL2(fielddouble_vol) - - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddouble.getComponentName(kp1) - compDesc = fielddouble.getComponentDescription(kp1) - compUnit = fielddouble.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - if fielddouble.getSupport().getEntity()!=MED_NODE: - print " Norme L1 : ", fielddouble.normL1(kp1) - print " Norme L2 : ", fielddouble.normL2(kp1) - print " Norme L2(vol) : ", fielddouble.normL2(kp1, fielddouble_vol) - - support = fielddouble.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddouble.getRow(k+1) - print " *",valueI[:nbOfComp] - fielddouble2 = FIELDDOUBLE(fielddouble) - print "" - fielddoubleadd = fielddouble + fielddouble2 - print "Test of the addition of two double fields with creation a new one" - print "" - name = fielddoubleadd.getName() - desc = fielddoubleadd.getDescription() - nbOfComp = fielddoubleadd.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoubleadd.getIterationNumber() - orderNb = fielddoubleadd.getOrderNumber() - time = fielddoubleadd.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoubleadd.getComponentName(kp1) - compDesc = fielddoubleadd.getComponentDescription(kp1) - compUnit = fielddoubleadd.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoubleadd.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoubleadd.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fielddoublesub = fielddouble - fielddouble2 - print "Test of the substraction of two double fields with creation a new one" - print "" - name = fielddoublesub.getName() - desc = fielddoublesub.getDescription() - nbOfComp = fielddoublesub.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoublesub.getIterationNumber() - orderNb = fielddoublesub.getOrderNumber() - time = fielddoublesub.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoublesub.getComponentName(kp1) - compDesc = fielddoublesub.getComponentDescription(kp1) - compUnit = fielddoublesub.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoublesub.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoublesub.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fielddoublemul = fielddouble * fielddouble2 - print "Test of the multiplication of two double fields with creation a new one" - print "" - name = fielddoublemul.getName() - desc = fielddoublemul.getDescription() - nbOfComp = fielddoublemul.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoublemul.getIterationNumber() - orderNb = fielddoublemul.getOrderNumber() - time = fielddoublemul.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoublemul.getComponentName(kp1) - compDesc = fielddoublemul.getComponentDescription(kp1) - compUnit = fielddoublemul.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoublemul.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoublemul.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - try: - fielddoublediv = fielddouble / fielddouble2 - print "Test of the division of two double fields with creation a new one" - print "" - name = fielddoublediv.getName() - desc = fielddoublediv.getDescription() - nbOfComp = fielddoublediv.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoublediv.getIterationNumber() - orderNb = fielddoublediv.getOrderNumber() - time = fielddoublediv.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoublediv.getComponentName(kp1) - compDesc = fielddoublediv.getComponentDescription(kp1) - compUnit = fielddoublediv.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoublediv.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoublediv.getRow(k+1) - print " *",valueI[:nbOfComp] - except: - print "fielddoublediv = fielddouble / fielddouble2 catch/except error" - else: - print " !!!! Bad type of Field !!!!" - -print "" -print "TESTS OPERATIONS SUR FIELDDOUBLE : " - - -fielddoublesub = fielddouble-fielddouble2 -fielddoublemul = fielddouble*fielddouble2 - -try: - fielddoublediv = fielddouble/fielddouble2 -except: - pass - -fielddoubleasso = fielddouble+fielddouble2*fielddouble2 -fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2) - - -print " f1 : ",fielddouble.getValue() -print " f2 : ",fielddouble2.getValue() -print "--------------------------------------------------------------------------------------------------------------" -print " + : ",fielddoubleadd.getValue() -print " - : ",fielddoublesub.getValue() -print " * : ",fielddoublemul.getValue() - -try: - print " / : ",fielddoublediv.getValue() -except: - pass - -fielddouble+=fielddouble2; -print " += : ",fielddouble.getValue() -fielddouble-=fielddouble2; -print " -= : ",fielddouble.getValue() -fielddouble*=fielddouble2; -print " *= : ",fielddouble.getValue() -fielddouble/=fielddouble2; -print " /= : ",fielddouble.getValue() -print "f1+f2*f2: ",fielddoubleasso.getValue() -fielddouble.applyLin(4,1); -print " 4f1+1 : ",fielddouble.getValue() -print " f1.f2 : ",fielddoubleSP.getValue() -fielddouble2.applyPyFunc(add_one) -print " CB:f2+1: ",fielddouble2.getValue() - -print "" -print "TESTS OPERATIONS SUR FIELDINT : " - - -fieldintadd = fieldint+fieldint2 -fieldintsub = fieldint-fieldint2 -fieldintmul = fieldint*fieldint2 - -try: - fieldintdiv = fieldint/fieldint2 -except: - pass - -fieldintasso = fieldint+fieldint*fieldint -fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2) - -print " f1 : ",fieldint.getValue() -print " f2 : ",fieldint2.getValue() -print "--------------------------------------------------------------------------------------------------------------" -print " + : ",fieldintadd.getValue() -print " - : ",fieldintsub.getValue() -print " * : ",fieldintmul.getValue() - -try: - print " / : ",fieldintdiv.getValue() -except: - pass - -fieldint+=fieldint2; -print " += : ",fieldint.getValue() -fieldint-=fieldint2; -print " -= : ",fieldint.getValue() -fieldint*=fieldint2; -print " *= : ",fieldint.getValue() -fieldint/=fieldint2; -print " /= : ",fieldint.getValue() -print "f1+f2*f2: ",fieldintasso.getValue() -fieldint.applyLin(4,1); -print " 4f1+1 : ",fieldint.getValue() -print " f1.f2 : ",fieldintSP.getValue() -fieldint2.applyPyFunc(add_one) -print " CB:f2+1: ",fieldint2.getValue() -myname="toto" -fieldint.setName(myname) -name = fieldint.getName() -print "test de setName : ",name -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_opsupp_test.py b/src/MEDMEM_SWIG/med_opsupp_test.py deleted file mode 100755 index b2bc44948..000000000 --- a/src/MEDMEM_SWIG/med_opsupp_test.py +++ /dev/null @@ -1,426 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -############################################################################ -# This Python script is testing the merge and the intersection of -# several SUPPORTs -############################################################################ -# -from libMEDMEM_Swig import * -from random import * -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join( filePath, "pointe.med" ) - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `i`+'th' - -md = MEDFILEBROWSER(medFile) -nbMeshes = md.getNumberOfMeshes() - -print "The med file", medFile, "contains", nbMeshes, "mesh(es)" - -mesh_name = md.getMeshName(0) -mesh = MESH(MED_DRIVER,medFile,mesh_name) -spaceDim = mesh.getSpaceDimension() -meshDim = mesh.getMeshDimension() -nbNodes = mesh.getNumberOfNodes() -print "The mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes" - -print "" -print "Mesh Families analysis:" -print "" - -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - if (entity == MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - elif (entity == MED_NODE) & (nbFam == 0): - print "This mesh has no Node Family(ies)" - elif (entity == MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - elif (entity == MED_CELL) & (nbFam == 0): - print "This mesh has no Cell Family(ies)" - elif (entity == MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - elif (entity == MED_FACE) & (nbFam == 0): - print "This mesh has no Face Family(ies)" - elif (entity == MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - elif (entity == MED_EDGE) & (nbFam == 0): - print "This mesh has no Edge Family(ies)" - print "" - - if nbFam > 0: - for j in range(nbFam): - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -print "we are going to do some operation on Node families" -print "by definition families have no intersection" -print "" -entity = MED_NODE -familyNode1 = mesh.getFamily(entity,1) -familyNode2 = mesh.getFamily(entity,2) -familyNode3 = mesh.getFamily(entity,3) -familyNode4 = mesh.getFamily(entity,4) - -listOfSupports = [] -listOfSupports.append(familyNode1) -listOfSupports.append(familyNode2) - -support = mesh.mergeSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -support = mesh.intersectSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -listOfSupports.append(familyNode3) - -support = mesh.mergeSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -print "we are going to do some operation on Cell families" -print "by definition families have no intersection" -print "" -entity = MED_CELL -familyCell1 = mesh.getFamily(entity,1) -familyCell2 = mesh.getFamily(entity,2) -familyCell3 = mesh.getFamily(entity,3) - -listOfSupports = [] -listOfSupports.append(familyCell1) -listOfSupports.append(familyCell2) - -support = mesh.mergeSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -support = mesh.intersectSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -listOfSupports.append(familyCell3) - -support = mesh.mergeSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -print "Let's now do an example of union and intersection of two supports with a non empty intersection" -print "" -support1 = SUPPORT() -support1.setMesh(mesh) -support1.setName("Partial_Support_1") -support1Description = "Partial Support 1" -support1NbOfTypes = 3 -support1TotNbElm = 8 -support1GeoType = [MED_TETRA4,MED_HEXA8,MED_PYRA5] -support1NbOfElm = [4,2,2] -support1NbValue = [1,2,3,4,15,16,13,14] - -support1.setpartial(support1Description,support1NbOfTypes,support1TotNbElm, - support1GeoType,support1NbOfElm,support1NbValue) - -supportName = support1.getName() -supportDescription = support1.getDescription() -supportMeshname = support1.getMesh().getName() -supportEntity = support1.getEntity() -supportBool = support1.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support1.getNumberOfTypes() - types = support1.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support1.getNumberOfElements(type) - number = support1.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -support2 = SUPPORT() -support2.setMesh(mesh) -support2.setName("Partial_Support_2") -support2Description = "Partial Support 2" -support2NbOfTypes = 3 -support2TotNbElm = 8 -support2GeoType = [MED_TETRA4,MED_HEXA8,MED_PYRA5] -support2NbOfElm = [6,1,1] -support2NbValue = [3,4,9,10,11,12,16,14] - -support2.setpartial(support2Description,support2NbOfTypes,support2TotNbElm, - support2GeoType,support2NbOfElm,support2NbValue) - -supportName = support2.getName() -supportDescription = support2.getDescription() -supportMeshname = support2.getMesh().getName() -supportEntity = support2.getEntity() -supportBool = support2.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support2.getNumberOfTypes() - types = support2.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support2.getNumberOfElements(type) - number = support2.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -listOfSupports = [] -listOfSupports.append(support1) -listOfSupports.append(support2) - -print "The union" -print "" - -support = mesh.mergeSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -print "The intersection" -print "" - -support = mesh.intersectSupports(listOfSupports) - -supportName = support.getName() -supportDescription = support.getDescription() -supportMeshname = support.getMesh().getName() -supportEntity = support.getEntity() -supportBool = support.isOnAllElements() -print " -Name:",supportName -print " -Description:",supportDescription -print " -Entity:",supportEntity -if (supportBool): - print " -Is on all entities" -else: - nbOfTypes = support.getNumberOfTypes() - types = support.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = support.getNumberOfElements(type) - number = support.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_test1.py b/src/MEDMEM_SWIG/med_test1.py deleted file mode 100644 index f51412454..000000000 --- a/src/MEDMEM_SWIG/med_test1.py +++ /dev/null @@ -1,542 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -# This Python script is parsing a MED file using MED Memory from SALOME platform: -# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as -# well as (d-1)-cells, families). It analyses fields stored in the MED file (d is -# the space dimension). You can assume that it is a kind of MED file parser. -################################################################################### -# -from libMEDMEM_Swig import * -from random import * -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, "carre_en_quad4_seg2.med") -#medFile = os.path.join(filePath, "cube_hexa8_quad4.med") - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `i`+'th' - -md = MEDFILEBROWSER(medFile) - -nbMeshes = md.getNumberOfMeshes() - -nbFields = md.getNumberOfFields() - -print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)" - -if (nbMeshes>0): - print "Mesh(es) Name(s) is(are) " - - for i in range(nbMeshes): - mesh_name = md.getMeshName(i) - print " - ",mesh_name - -if (nbFields>0): - print "Field(s) Name(s) is(are) " - - for i in range(nbFields): - field_name = md.getFieldName(i) - print " - ",field_name - -print "" - -if (nbMeshes>0): - print "Mesh(es) Analysis " - for i in range(nbMeshes): - mesh_name = md.getMeshName(i) - mesh = MESH(MED_DRIVER,md.getFileName(),mesh_name) - spaceDim = mesh.getSpaceDimension() - meshDim = mesh.getMeshDimension() - print "The",print_ord(i), "mesh, '",mesh_name,"', is a",spaceDim,"D mesh on a",meshDim,"D geometry" - nbNodes = mesh.getNumberOfNodes() - print "The mesh has",nbNodes,"Nodes" - coordSyst = mesh.getCoordinatesSystem() - print "The coordinates system is",coordSyst - print "The Coordinates :" - coordNames = [] - coordUnits = [] - for isd in range(spaceDim): - coordNames.append(mesh.getCoordinateName(isd)) - coordUnits.append(mesh.getCoordinateUnit(isd)) - - print "names:", coordNames - print "units", coordUnits - print "values:" - coordinates = mesh.getCoordinates(MED_FULL_INTERLACE) - for k in range(nbNodes): - kp1 = k+1 - coords = [] - for isd in range(spaceDim): - isdp1 = isd+1 - coords.append(mesh.getCoordinate(kp1,isdp1)) - - print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)] - - print "" - print "Show the Nodal Connectivity of Cells:" - nbTypesCell = mesh.getNumberOfTypes(MED_CELL) - print "" - if (nbTypesCell>0): - print "The Mesh has",nbTypesCell,"Type(s) of Cell" - types = mesh.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = mesh.getNumberOfElements(MED_CELL,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - - print "" - print "Show the Nodal Connectivity of constituents (Faces in 3D or Edges in 2D):" - - if (spaceDim == 3) : constituent = MED_FACE - elif (spaceDim == 2) : constituent = MED_EDGE - else : print "proble with the sapce dimension : ",spaceDim - - nbTypesConst = mesh.getNumberOfTypes(constituent) - print "" - if (nbTypesConst>0): - print "The Mesh has",nbTypesConst,"Type(s) of Constituent" - types = mesh.getTypes(constituent) - for k in range(nbTypesConst): - type = types[k] - nbElemType = mesh.getNumberOfElements(constituent,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh.getConnectivity(MED_NODAL,constituent,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - - print "" - print "Show the Reverse Nodal Connectivity:" - ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL) - ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL) - print "" - for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - - print "" - print "Show the Descending Connectivity:" - mesh.calculateConnectivity(MED_DESCENDING,MED_CELL) - nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) - Connectivity = mesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) - ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL) - print "" - for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] - - print "" - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - if (entity == MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - elif (entity == MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - elif (entity == MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - elif (entity == MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - numberFamily = family.getNumber(MED_ALL_ELEMENTS) - print " * Getting an Integer Field on the family ",familyName - fieldFamilyIntg = FIELDINT(family,spaceDim) - fieldFamilyIntg.setIterationNumber(0) - fieldFamilyIntg.setOrderNumber(0) - fieldFamilyIntg.setTime(0.0) - for kcomp in range(spaceDim): - kcomp1 = kcomp+1 - if kcomp == 0: - fieldCompName = "comp1" - fieldCompDesc = "desc1" - fieldCompUnit = "unit1" - if kcomp == 1: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - if kcomp == 2: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - - fieldFamilyIntg.setComponentName(kcomp1,fieldCompName) - fieldFamilyIntg.setComponentDescription(kcomp1,fieldCompDesc) - fieldFamilyIntg.setMEDComponentUnit(kcomp1,fieldCompUnit) - fieldFamilyName = "Integer Field on "+familyName - fieldFamilyIntg.setName(fieldFamilyName) - field_name = fieldFamilyIntg.getName() - type_field = fieldFamilyIntg.getValueType() - nbOfComp = fieldFamilyIntg.getNumberOfComponents() - print " The field",field_name,"is with the type",type_field - print " It has",nbOfComp,"Component(s)" - for kcomp in range(nbOfComp): - kcomp1 = kcomp+1 - compName = fieldFamilyIntg.getComponentName(kcomp1) - compDesc = fieldFamilyIntg.getComponentDescription(kcomp1) - compUnit = fieldFamilyIntg.getMEDComponentUnit(kcomp1) - print " * Component:",kcomp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - print " Randomly set and get to check ..!" - for k in range(nbOf): - valueI = [] - for kcomp in range(nbOfComp): - valueI.append(randint(0,100)) - -# print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - valInd = numberFamily[k] - fieldFamilyIntg.setRow(valInd,valueI) - valueIverif = fieldFamilyIntg.getRow(valInd) - print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] - print " * Getting a Real Field" - fieldFamilyDble = FIELDDOUBLE(family,spaceDim) - fieldFamilyDble.setIterationNumber(0) - fieldFamilyDble.setOrderNumber(0) - fieldFamilyDble.setTime(0.0) - for kcomp in range(spaceDim): - kcomp1 = kcomp+1 - if kcomp == 0: - fieldCompName = "comp1" - fieldCompDesc = "desc1" - fieldCompUnit = "unit1" - if kcomp == 1: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - if kcomp == 2: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - - fieldFamilyDble.setComponentName(kcomp1,fieldCompName) - fieldFamilyDble.setComponentDescription(kcomp1,fieldCompDesc) - fieldFamilyDble.setMEDComponentUnit(kcomp1,fieldCompUnit) - - fieldFamilyName = "Real Field on "+familyName - fieldFamilyDble.setName(fieldFamilyName) - field_name = fieldFamilyDble.getName() - type_field = fieldFamilyDble.getValueType() - nbOfComp = fieldFamilyDble.getNumberOfComponents() - print " The field",field_name,"is with the type",type_field - print " It has",nbOfComp,"Component(s)" - for kcomp in range(nbOfComp): - kcomp1 = kcomp+1 - compName = fieldFamilyDble.getComponentName(kcomp1) - compDesc = fieldFamilyDble.getComponentDescription(kcomp1) - compUnit = fieldFamilyDble.getMEDComponentUnit(kcomp1) - print " * Component:",kcomp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - nbOf = fieldFamilyDble.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - print " Randomly set and get to check ..!" - for k in range(nbOf): - valueI = [] - for kcomp in range(nbOfComp): - valueI.append(random()) - -# print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - valInd = numberFamily[k] - fieldFamilyDble.setRow(valInd,valueI) - valueIverif = fieldFamilyDble.getRow(valInd) - print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] - print "" - print "" - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbGrp = mesh.getNumberOfGroups(entity) - if (entity == MED_NODE) & (nbGrp > 0): - print "This mesh has",nbGrp,"Node Group(s)" - elif (entity == MED_CELL) & (nbGrp > 0): - print "This mesh has",nbGrp,"Cell Group(s)" - elif (entity == MED_FACE) & (nbGrp > 0): - print "This mesh has",nbGrp,"Face Group(s)" - elif (entity == MED_EDGE) & (nbGrp > 0): - print "This mesh has",nbGrp,"Edge Group(s)" - - if nbGrp > 0: - for j in range(nbGrp): - print "" - group = mesh.getGroup(entity,j+1) - groupName = group.getName() - groupDescription = group.getDescription() - groupEntity = group.getEntity() - groupBool = group.isOnAllElements() - print " -Name:",groupName - print " -Description:",groupDescription - print " -Entity:",groupEntity - nbOfFam = group.getNumberOfFamilies() - print " -Number Of Families:",nbOfFam - for k in range(nbOfFam): - print " * Family:",group.getFamily(k+1).getName() - print " -Entities list:" - if (groupBool): - print " -Is on all entities" - else: - nbOfTypes = group.getNumberOfTypes() - types = group.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = group.getNumberOfElements(type) - number = group.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - - print "Building of the support on all Cells of the mesh." - supportCell = mesh.getSupportOnAll( MED_CELL ) - print "" - barycenter = mesh.getBarycenter(supportCell) - print "Getting barycenter of all Cells of the mesh" - for j in range(nbElemts): - barycenterCell = barycenter.getRow(j+1) - print " * ",barycenterCell[:spaceDim] - print "" - if spaceDim == 3 : - print "Getting volume of all Cells of the mesh:" - volume = mesh.getVolume(supportCell) - voltot = 0. - for j in range(nbElemts): - volumeCell = volume.getValueIJ(j+1,1) - print " * ",volumeCell - voltot = voltot + volumeCell - print "Volume of the mesh:",voltot - print "" - print "Building of the support on all Faces of the mesh." - supportFace = SUPPORT(mesh,"Support on all faces of the mesh",MED_FACE) - nbFace = mesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS) - print "" - print "Getting normal of each face of this support",nbFace - nbTypeFace = mesh.getNumberOfTypes(MED_FACE) - TypeFace = mesh.getTypes(MED_FACE) - print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace] - normal = mesh.getNormal(supportFace) - area = mesh.getArea(supportFace) - for j in range(nbFace): - normalFace = normal.getRow(j+1) - areaFace = area.getRow(j+1) - value1 = normalFace[0] - value2 = normalFace[1] - value3 = normalFace[2] - norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) - print " * ",normalFace[:spaceDim],"norm:",norm," --> area ",areaFace[0] - elif spaceDim == 2: - print "Getting area on all Cells of the mesh:" - area = mesh.getArea(supportCell) - areatot = 0. - for j in range(nbElemts): - areaCell = area.getValueIJ(j+1,1) - print " * ",areaCell - areatot = areatot + areaCell - print "Area of the mesh:",areatot - print "" - print "Building of the support on all Edges of the mesh." - supportEdge = mesh.getSupportOnAll(MED_EDGE) - nbEdge = mesh.getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS) - print "" - print "Getting normal of each edge of this support",nbEdge - nbTypeEdge = mesh.getNumberOfTypes(MED_EDGE) - TypeEdge = mesh.getTypes(MED_EDGE) - print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge] - normal = mesh.getNormal(supportEdge) - length = mesh.getLength(supportEdge) - for j in range(nbEdge): - normalEdge = normal.getRow(j+1) - lengthEdge = length.getRow(j+1) - value1 = normalEdge[0] - value2 = normalEdge[1] - norm = (value1*value1 + value2*value2)**(0.5) - print " * ",normalEdge[:spaceDim],"norm:",norm," --> length ",lengthEdge[0] - print "" - print "Building support on Elements of the boundary" - if spaceDim == 3 : - suppBound = mesh.getBoundaryElements(MED_FACE) - nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) - print "Getting normal field on the boundary",nbElmBound - normalBound = mesh.getNormal(suppBound) - if suppBound.isOnAllElements(): - numberSuppBound = range(1,nbElmBound+1) - else: - numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) - for j in range(nbElmBound): - valInd = numberSuppBound[j] - normalBoundJ = normalBound.getRow(valInd) - value1 = normalBoundJ[0] - value2 = normalBoundJ[1] - value3 = normalBoundJ[2] - norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) - print " * ",normalBoundJ[:spaceDim],"norm:",norm - elif spaceDim == 2: - suppBound = mesh.getBoundaryElements(MED_EDGE) - nbElmBound = suppBound.getNumberOfElements(MED_ALL_ELEMENTS) - print "Getting normal field on the boundary",nbElmBound - normalBound = mesh.getNormal(suppBound) - if suppBound.isOnAllElements(): - numberSuppBound = range(1,nbElmBound+1) - else: - numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) - for j in range(nbElmBound): - valInd = numberSuppBound[j] - normalBoundJ = normalBound.getRow(valInd) - value1 = normalBoundJ[0] - value2 = normalBoundJ[1] - norm = (value1*value1 + value2*value2)**(0.5) - print " * ",normalBoundJ[:spaceDim],"norm:",norm - print "" -if (nbFields>0): - print "Field(s) Analysis " - for i in range(nbFields): - field_name = md.getFieldName(i) - dtits = md.getFieldIteration(field_name) - nbOfIt = len(dtits) - print "The",print_ord(i),"field is",field_name,"with",nbOfIt,"iteration(s)" - for dtitfield in dtits: - dt = dtitfield.getdt() - it = dtitfield.getit() - type = md.getFieldType(field_name) - print " * Iteration:",dt,"Order number:",it,"Type:",type - if type == MED_INT32: - fieldint = FIELDINT(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh) - name = fieldint.getName() - desc = fieldint.getDescription() - nbOfComp = fieldint.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldint.getIterationNumber() - orderNb = fieldint.getOrderNumber() - time = fieldint.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldint.getComponentName(kp1) - compDesc = fieldint.getComponentDescription(kp1) - compUnit = fieldint.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldint.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldint.getRow(k+1) - print " *",valueI[:nbOfComp] - elif type == MED_REEL64: - fielddouble = FIELDDOUBLE(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh) - name = fielddouble.getName() - desc = fielddouble.getDescription() - nbOfComp = fielddouble.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddouble.getIterationNumber() - orderNb = fielddouble.getOrderNumber() - time = fielddouble.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddouble.getComponentName(kp1) - compDesc = fielddouble.getComponentDescription(kp1) - compUnit = fielddouble.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddouble.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddouble.getRow(k+1) - print " *",valueI[:nbOfComp] - else: - print " !!!! Bad type of Field !!!!" - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_test2.py b/src/MEDMEM_SWIG/med_test2.py deleted file mode 100644 index 4259eeeb0..000000000 --- a/src/MEDMEM_SWIG/med_test2.py +++ /dev/null @@ -1,489 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -# This Python script is parsing a MED file using MED Memory from SALOME platform: -# It analyses all meshes in the MED file (coordinates, connectivity of d-cells as -# well as (d-1)-cells, families), it tests all fields generated in the MESH class -# and write them in a 2 new med files (V2.1 and V2.2), it gives only the number of -# fields stored in the MED file (d is the mesh/space dimension). -################################################################################### -# -from libMEDMEM_Swig import * -from random import * - -#============================================================================== - -def AnalyzeField(field): - name = field.getName() - desc = field.getDescription() - nbComp = field.getNumberOfComponents() - itNum = field.getIterationNumber() - ordNum = field.getOrderNumber() - type = field.getValueType() - - print "Analysis of the field ",name," with the description ",desc - print "iteration number ",itNum," order Number ",ordNum - print "It has ",nbComp," component(s) with the type ",type - - fieldValue = field.getValue() - fieldSupport = field.getSupport() - fieldMesh = fieldSupport.getMesh() - fieldEntity = fieldSupport.getEntity() - bool = fieldSupport.isOnAllElements() - - if bool: - print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName() - if fieldEntity == MED_NODE: - nbValByComp = fieldMesh.getNumberOfNodes() - else: - nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - else: - print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName() - nbValByComp = fieldSupport.getNumberOfElements(MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - - for i in range(nbComp): - ip1 = i + 1 - compName = field.getComponentName(ip1) - compDesc = field.getComponentDescription(ip1) - compUnit = field.getMEDComponentUnit(ip1) - print "The ",(i+1),"-th component ",compName," with the dexription ",compDesc," and the unit ",compUnit - - for i in range(nbValByComp): - print " * ",fieldValue[i*nbComp:(i+1)*nbComp] - -#============================================================================== -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, "carre_en_quad4_seg2.med") -#medFile = os.path.join(filePath, "cube_hexa8_quad4.med") - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `i`+'th' - -md = MEDFILEBROWSER(medFile) - -nbMeshes = md.getNumberOfMeshes() - -nbFields = md.getNumberOfFields() - -print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)" - -if (nbMeshes>0): - print "Mesh(es) Name(s) is(are) " - - for i in range(nbMeshes): - mesh_name = md.getMeshName(i) - print " - ",mesh_name - -if (nbFields>0): - print "Field(s) Name(s) is(are) " - - for i in range(nbFields): - field_name = md.getFieldName(i) - print " - ",field_name - -print "" - -if (nbMeshes>0): - print "Mesh(es) Analysis " - for i in range(nbMeshes): - mesh_name = md.getMeshName(i) - mesh = MESH(MED_DRIVER,md.getFileName(),mesh_name) - spaceDim = mesh.getSpaceDimension() - meshDim = mesh.getMeshDimension() - print "The",print_ord(i), "mesh, '",mesh_name,"', is a",spaceDim,"D mesh on a",meshDim,"D geometry" - nbNodes = mesh.getNumberOfNodes() - print "The mesh has",nbNodes,"Nodes" - coordSyst = mesh.getCoordinatesSystem() - print "The coordinates system is",coordSyst - print "The Coordinates :" - coordNames = [] - coordUnits = [] - for isd in range(spaceDim): - coordNames.append(mesh.getCoordinateName(isd)) - coordUnits.append(mesh.getCoordinateUnit(isd)) - - print "names:", coordNames - print "units", coordUnits - print "values:" - coordinates = mesh.getCoordinates(MED_FULL_INTERLACE) - for k in range(nbNodes): - kp1 = k+1 - coords = [] - for isd in range(spaceDim): - isdp1 = isd+1 - coords.append(mesh.getCoordinate(kp1,isdp1)) - - print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)] - - print "" - print "Show the Nodal Connectivity:" - nbTypesCell = mesh.getNumberOfTypes(MED_CELL) - print "" - if (nbTypesCell>0): - print "The Mesh has",nbTypesCell,"Type(s) of Cell" - types = mesh.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = mesh.getNumberOfElements(MED_CELL,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - - print "" - print "Show the Reverse Nodal Connectivity:" - ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL) - ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL) - print "" - for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - - print "" - print "Show the Descending Connectivity:" - mesh.calculateConnectivity(MED_DESCENDING,MED_CELL) - nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) - Connectivity = mesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) - ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL) - print "" - for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] - - print "" - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - if (entity == MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - elif (entity == MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - elif (entity == MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - elif (entity == MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - numberFamily = family.getNumber(MED_ALL_ELEMENTS) - print " * Getting an Integer Field on the family ",familyName - fieldFamilyIntg = FIELDINT(family,spaceDim) - fieldFamilyIntg.setIterationNumber(0) - fieldFamilyIntg.setOrderNumber(0) - fieldFamilyIntg.setTime(0.0) - for kcomp in range(spaceDim): - kcomp1 = kcomp+1 - if kcomp == 0: - fieldCompName = "comp1" - fieldCompDesc = "desc1" - fieldCompUnit = "unit1" - if kcomp == 1: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - if kcomp == 2: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - - fieldFamilyIntg.setComponentName(kcomp1,fieldCompName) - fieldFamilyIntg.setComponentDescription(kcomp1,fieldCompDesc) - fieldFamilyIntg.setMEDComponentUnit(kcomp1,fieldCompUnit) - fieldFamilyName = "Integer Field on "+familyName - fieldFamilyIntg.setName(fieldFamilyName) - field_name = fieldFamilyIntg.getName() - type_field = fieldFamilyIntg.getValueType() - nbOfComp = fieldFamilyIntg.getNumberOfComponents() - print " The field",field_name,"is with the type",type_field - print " It has",nbOfComp,"Component(s)" - for kcomp in range(nbOfComp): - kcomp1 = kcomp+1 - compName = fieldFamilyIntg.getComponentName(kcomp1) - compDesc = fieldFamilyIntg.getComponentDescription(kcomp1) - compUnit = fieldFamilyIntg.getMEDComponentUnit(kcomp1) - print " * Component:",kcomp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - print " Randomly set and get to check ..!" - for k in range(nbOf): - valueI = [] - for kcomp in range(nbOfComp): - valueI.append(randint(0,100)) - -# print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - valInd = numberFamily[k] - fieldFamilyIntg.setRow(valInd,valueI) - valueIverif = fieldFamilyIntg.getRow(valInd) - print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] - print " * Getting a Real Field" - fieldFamilyDble = FIELDDOUBLE(family,spaceDim) - fieldFamilyDble.setIterationNumber(0) - fieldFamilyDble.setOrderNumber(0) - fieldFamilyDble.setTime(0.0) - for kcomp in range(spaceDim): - kcomp1 = kcomp+1 - if kcomp == 0: - fieldCompName = "comp1" - fieldCompDesc = "desc1" - fieldCompUnit = "unit1" - if kcomp == 1: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - if kcomp == 2: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - - fieldFamilyDble.setComponentName(kcomp1,fieldCompName) - fieldFamilyDble.setComponentDescription(kcomp1,fieldCompDesc) - fieldFamilyDble.setMEDComponentUnit(kcomp1,fieldCompUnit) - - fieldFamilyName = "Real Field on "+familyName - fieldFamilyDble.setName(fieldFamilyName) - field_name = fieldFamilyDble.getName() - type_field = fieldFamilyDble.getValueType() - nbOfComp = fieldFamilyDble.getNumberOfComponents() - print " The field",field_name,"is with the type",type_field - print " It has",nbOfComp,"Component(s)" - for kcomp in range(nbOfComp): - kcomp1 = kcomp+1 - compName = fieldFamilyDble.getComponentName(kcomp1) - compDesc = fieldFamilyDble.getComponentDescription(kcomp1) - compUnit = fieldFamilyDble.getMEDComponentUnit(kcomp1) - print " * Component:",kcomp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - nbOf = fieldFamilyDble.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - print " Randomly set and get to check ..!" - for k in range(nbOf): - valueI = [] - for kcomp in range(nbOfComp): - valueI.append(random()) - -# print " Set Entry *",(k+1)," ",valueI[:nbOfComp] - valInd = numberFamily[k] - fieldFamilyDble.setRow(valInd,valueI) - valueIverif = fieldFamilyDble.getRow(valInd) - print " Set/Get Entry *",(k+1)," ",valueI[:nbOfComp]," / ",valueIverif[:nbOfComp] - if (entity != MED_NODE): - print "" - print "Getting barycenter on this family" - barycenterfamily = mesh.getBarycenter(family) - if (not familyBool): numberFamily = family.getNumber(MED_ALL_ELEMENTS) - nbVal = barycenterfamily.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) - nbComp = barycenterfamily.getNumberOfComponents() - for j in range(nbVal): - valInd = j+1 - if (not familyBool): valInd = numberFamily[j] - barycenterfamilyentity = barycenterfamily.getRow(valInd) - print " * ",barycenterfamilyentity[:nbComp] - print "" - - print "Building of the support on all Cells of the mesh." - supportCell = mesh.getSupportOnAll( MED_CELL ) - print "" - print "Getting barycenter of all Cells of the mesh" - barycenter = mesh.getBarycenter(supportCell) - for j in range(nbElemts): - barycenterCell = barycenter.getRow(j+1) - print " * ",barycenterCell[:spaceDim] - - print "Writing on file the mesh" - writeMed21File = medFile[0:(len(medFile)-4)]+"_V21_fields.med" - writeMed22File = medFile[0:(len(medFile)-4)]+"_V22_fields.med" - fieldsMesh = barycenter.getSupport().getMesh() - fieldsMeshName = "Fields Mesh" - fieldsMesh.setName(fieldsMeshName) - - index22Mesh = fieldsMesh.addDriver(MED_DRIVER,writeMed22File,fieldsMeshName) - fieldsMesh.write(index22Mesh) - - AnalyzeField(barycenter) - - print "Writing on file the cells barycenter field" - - barycenterName = barycenter.getName() - - index22FieldBarycenter = barycenter.addDriver(MED_DRIVER,writeMed22File,barycenterName) - barycenter.write(index22FieldBarycenter) - - print "" - if spaceDim == 3 : - print "Getting volume of all Cells of the mesh:" - volume = mesh.getVolume(supportCell) - voltot = 0. - for j in range(nbElemts): - volumeCell = volume.getValueIJ(j+1,1) - print " * ",volumeCell - voltot = voltot + volumeCell - print "Volume of the mesh:",voltot - print "" - - AnalyzeField(volume) - - print "Writing on file the cells volume field" - - volumeName = volume.getName() - - index22FieldVolume = volume.addDriver(MED_DRIVER,writeMed22File,volumeName) - volume.write(index22FieldVolume) - - print "" - print "Building of the support on all Faces of the mesh." - supportFace = SUPPORT(mesh,"Support on all faces of the mesh",MED_FACE) - supportFace.update() - nbFace = mesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS) - print "" - print "Getting normal of each face of this support",nbFace - nbTypeFace = mesh.getNumberOfTypes(MED_FACE) - TypeFace = mesh.getTypes(MED_FACE) - print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace] - normal = mesh.getNormal(supportFace) - for j in range(nbFace): - normalFace = normal.getRow(j+1) - value1 = normalFace[0] - value2 = normalFace[1] - value3 = normalFace[2] - norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) - print " * ",normalFace[:spaceDim],"norm:",norm - print "" - - AnalyzeField(normal) - - print "Writing on file the face normal field" - - normalName = normal.getName() - - index22FieldNormal = normal.addDriver(MED_DRIVER,writeMed22File,normalName) - normal.write(index22FieldNormal) - - elif spaceDim == 2: - print "Getting area on all Cells of the mesh:" - area = mesh.getArea(supportCell) - areatot = 0. - for j in range(nbElemts): - areaCell = area.getValueIJ(j+1,1) - print " * ",areaCell - areatot = areatot + areaCell - print "Area of the mesh:",areatot - print "" - - AnalyzeField(area) - - print "Writing on file the cells area field" - - areaName = area.getName() - - index22FieldArea = area.addDriver(MED_DRIVER,writeMed22File,areaName) - area.write(index22FieldArea) - - print "" - print "Getting the support on all Edges of the mesh." - supportEdge = mesh.getSupportOnAll(MED_EDGE) - nbEdge = mesh.getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS) - print "" - print "Getting normal of each edge of this support",nbEdge - nbTypeEdge = mesh.getNumberOfTypes(MED_EDGE) - TypeEdge = mesh.getTypes(MED_EDGE) - print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge] - normal = mesh.getNormal(supportEdge) - for j in range(nbEdge): - normalEdge = normal.getRow(j+1) - value1 = normalEdge[0] - value2 = normalEdge[1] - norm = (value1*value1 + value2*value2)**(0.5) - print " * ",normalEdge[:spaceDim],"norm:",norm - print "" - - AnalyzeField(normal) - - print "Writing on file the edge normal field" - - normalName = normal.getName() - - index22FieldNormal = normal.addDriver(MED_DRIVER,writeMed22File,normalName) - normal.write(index22FieldNormal) - print "" - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_test3.py b/src/MEDMEM_SWIG/med_test3.py deleted file mode 100644 index 2f70a5df2..000000000 --- a/src/MEDMEM_SWIG/med_test3.py +++ /dev/null @@ -1,247 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -# This Python script is parsing a MED file using MED Memory from SALOME platform: -# It tests the setValue, setRow and setColum functions on MED fields -################################################################################### -# -from libMEDMEM_Swig import * -from random import * -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, "carre_en_quad4_seg2.med") -#medFile = os.path.join(filePath, "cube_hexa8_quad4.med") - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `i`+'th' - -md = MEDFILEBROWSER(medFile) - -nbMeshes = md.getNumberOfMeshes() - -nbFields = md.getNumberOfFields() - -print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)" - -if (nbMeshes>0): - print "Mesh(es) Name(s) is(are) " - - for i in range(nbMeshes): - mesh_name = md.getMeshName(i) - print " - ",mesh_name - -if (nbFields>0): - print "Field(s) Name(s) is(are) " - - for i in range(nbFields): - field_name = md.getFieldName(i) - print " - ",field_name - -print "" - -if (nbMeshes>0): - print "Mesh(es) Analysis " - for i in range(nbMeshes): - mesh_name = md.getMeshName(i) - mesh = MESH(MED_DRIVER,md.getFileName(),mesh_name) - spaceDim = mesh.getSpaceDimension() - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - if (entity == MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - elif (entity == MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - elif (entity == MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - elif (entity == MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - numberFamily = family.getNumber(MED_ALL_ELEMENTS) - print " * Getting an Integer Field on the family ",familyName - fieldFamilyIntg = FIELDINT(family,spaceDim) - fieldFamilyIntg.setIterationNumber(0) - fieldFamilyIntg.setOrderNumber(0) - fieldFamilyIntg.setTime(0.0) - for kcomp in range(spaceDim): - if kcomp == 0: - fieldCompName = "comp1" - fieldCompDesc = "desc1" - fieldCompUnit = "unit1" - if kcomp == 1: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - if kcomp == 2: - fieldCompName = "comp2" - fieldCompDesc = "desc2" - fieldCompUnit = "unit2" - - kcomp1 = kcomp+1 - fieldFamilyIntg.setComponentName(kcomp1,fieldCompName) - fieldFamilyIntg.setComponentDescription(kcomp1,fieldCompDesc) - fieldFamilyIntg.setMEDComponentUnit(kcomp1,fieldCompUnit) - fieldFamilyName = "Integer Field on "+familyName - fieldFamilyIntg.setName(fieldFamilyName) - field_name = fieldFamilyIntg.getName() - type_field = fieldFamilyIntg.getValueType() - nbOfComp = fieldFamilyIntg.getNumberOfComponents() - print " The field",field_name,"is with the type",type_field - print " It has",nbOfComp,"Component(s)" - for kcomp in range(nbOfComp): - kcomp1 = kcomp+1 - compName = fieldFamilyIntg.getComponentName(kcomp1) - compDesc = fieldFamilyIntg.getComponentDescription(kcomp1) - compUnit = fieldFamilyIntg.getMEDComponentUnit(kcomp1) - print " * Component:",kcomp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - nbOf = fieldFamilyIntg.getSupport().getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - print " Randomly set (via setValue) and get (via getValue) to check with the same mode ..!" - value = [] - for k in range(nbOf*nbOfComp): - value.append(randint(0,100)) - print " the mode is full interlace" - mode = MED_FULL_INTERLACE - fieldFamilyIntg.setValue(value) - valueverif = fieldFamilyIntg.getValue() - for k in range(nbOf*nbOfComp): - print " Set/Get Entry * ",value[k]," / ",valueverif[k] - print "" - value = [] - for k in range(nbOf*nbOfComp): - value.append(randint(0,100)) - print " the mode is no interlace" - mode = MED_NO_INTERLACE - fieldFamilyIntg.setValue(value) - valueverif = fieldFamilyIntg.getValue() - for k in range(nbOf*nbOfComp): - print " Set/Get Entry * ",value[k]," / ",valueverif[k] - print "" - print " Randomly set (via setValue) and get (via getValue) to check with different mode ..!" - value = [] - for k in range(nbOf*nbOfComp): - value.append(randint(0,100)) - print " the mode for set is full interlace and no interlace for get" - mode_full = MED_FULL_INTERLACE - mode_no = MED_NO_INTERLACE - fieldFamilyIntg.setValue(value) - valueverif = fieldFamilyIntg.getValue() - for k in range(nbOf*nbOfComp): - print " Set/Get Entry * ",value[k]," / ",valueverif[k] - print "" - value = [] - for k in range(nbOf*nbOfComp): - value.append(randint(0,100)) - print " the mode for set is no interlace and full interlace for get" - fieldFamilyIntg.setValue(value) - valueverif = fieldFamilyIntg.getValue() - for k in range(nbOf*nbOfComp): - print " Set/Get Entry * ",value[k]," / ",valueverif[k] - print "" - print " Randomly set (via setRow/setColumn) and get (via getRow/getColumn) to check with the same mode ..!" - value = [] - for k in range(nbOf*nbOfComp): - value.append(randint(0,100)) - mode = MED_FULL_INTERLACE - print " the mode is full interlace ", mode - print " the field interlacing mode ",fieldFamilyIntg.getInterlacingType() - for k in range(nbOf): - valInd = numberFamily[k] - fieldFamilyIntg.setRow(valInd,value[k*nbOfComp:(k+1)*nbOfComp]) - valueverif = [] - for k in range(nbOf): - valInd = numberFamily[k] - valueverif.extend(fieldFamilyIntg.getRow(valInd)) - for k in range(nbOf*nbOfComp): - print " Set/Get Entry * ",value[k]," / ",valueverif[k] - print "" - value = [] - for k in range(nbOf*nbOfComp): - value.append(randint(0,100)) - mode = MED_NO_INTERLACE - print " the mode is no interlace ", mode - print " the field interlacing mode ",fieldFamilyIntg.getInterlacingType() - for k in range(nbOf): - valInd = numberFamily[k] - fieldFamilyIntg.setRow(valInd,value[k*nbOfComp:(k+1)*nbOfComp]) - fieldFamilyIntgOtherMode = createFieldIntConvertNoInterlace(fieldFamilyIntg) - valueverif = [] - for k in range(nbOfComp): - valueverif.extend(fieldFamilyIntgOtherMode.getColumn(k+1)) - for k in range(nbOf*nbOfComp): - print " Set/Get Entry * ",value[k]," / ",valueverif[k] - print "" -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_test_grid.py b/src/MEDMEM_SWIG/med_test_grid.py deleted file mode 100755 index 3d8e251e1..000000000 --- a/src/MEDMEM_SWIG/med_test_grid.py +++ /dev/null @@ -1,338 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# Python script for testing T5.10 task -# ########################################### -#% Test structured mesh (GRID) reading from file test19.med -#% test19.med can be obtained by running test19_c.out executable -# or locally in MEDMEM directory create_grid -# -from libMEDMEM_Swig import * - -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, "test19.med") -print "Read file", medFile - -md = MEDFILEBROWSER(medFile) - -nbMeshes = md.getNumberOfMeshes() -print "Nb meshes:", nbMeshes -if nbMeshes == 0: - raise RuntimeError, "Can't read med file" - -############################## -# test "CartGrid" -############################## - -mesh_name = md.getMeshName(0) -print "Read", mesh_name -grid = GRID(MED_DRIVER,medFile,mesh_name) - -if grid.getIsAGrid() == 0: - raise RuntimeError, "Mesh 0 is not a grid" - -I = grid.getArrayLength(1) -print "_iArrayLength", I -if I != 4: - raise RuntimeError, "Error in grid.getArrayLength(1)" - -J = grid.getArrayLength(2) -print "_jArrayLength", J -if J != 4: - raise RuntimeError, "Error in grid.getArrayLength(2)" - -K = grid.getArrayLength(3) -print "_kArrayLength", K -if K != 0: - raise RuntimeError, "Error in grid.getArrayLength(3)" - -grid_type = grid.getGridType() -print "grid_type =", grid_type -if grid_type != MED_CARTESIAN: - raise RuntimeError, "Wrong grid type" - -spaceDim = grid.getSpaceDimension() -print "spaceDim =", spaceDim -if spaceDim != 2: - raise RuntimeError, "Wrong space dimention" - -meshDim = grid.getMeshDimension() -print "meshDim =", meshDim -if spaceDim != meshDim: - raise RuntimeError, "Wrong mesh dimention" - -nbNodes = grid.getNumberOfNodes() -print "nbNodes =", nbNodes -if nbNodes != 16: - raise RuntimeError, "Wrong nb of nodes" - -coordSyst = grid.getCoordinatesSystem() -print "coordSyst =", coordSyst -if coordSyst != "CARTESIAN": - raise RuntimeError, "Wrong coordinates system" - -mesh = grid.convertInMESH() -coordinates = mesh.getCoordinates(MED_FULL_INTERLACE) -print "coordinates =", coordinates -xy = [ grid.getArrayValue(1, I-1 ) , grid.getArrayValue(2, J-1 ) ] -xy2 = coordinates[(nbNodes-1)*spaceDim:(nbNodes*spaceDim)] -print list(xy) -print xy2 -if not list(xy) == list(xy2): - raise RuntimeError, "Error in grid.getCoordinates(MED_FULL_INTERLACE)" - -nbTypesCell = grid.getNumberOfTypes(MED_CELL) -print "nbTypesCell =", nbTypesCell -if nbTypesCell != 1: - raise RuntimeError, "Wrong nbTypesCell" - -types = grid.getTypes(MED_CELL) -print "Cell types =", types -if types != [204]: - raise RuntimeError, "Wrong Cell types" - -nbElemType = grid.getNumberOfElements(MED_CELL,types[0]) -print "Nb cells =", nbElemType -if nbElemType != 9: - raise RuntimeError, "Wrong Nb cells" - -print "getEntityPosition : convert node number to i,j,k" - -n1 = grid.getEntityPosition(MED_NODE,10) -n2 = grid.getEntityPosition(MED_NODE,16) - -if n1 == [1,2]: o1 = "Ok" -else: o1 = "KO" -if n2 == [3,3]: o2 = "Ok" -else: o2 = "KO" - -print "Node 10 -> i,j = ", n1, " : ", o1 -print "Node 16 -> i,j = ", n2, " : ", o2 - -print "getEntityPosition : convert cell number to i,j,k" - -n1 = grid.getEntityPosition(MED_CELL,3) -n2 = grid.getEntityPosition(MED_CELL,4) - -if n1 == [2,0]: o1 = "Ok" -else: o1 = "KO" -if n2 == [0,1]: o2 = "Ok" -else: o2 = "KO" - -print "Cell 3 -> i,j = ", n1, " : ", o1 -print "Cell 4 -> i,j = ", n2, " : ", o2 - -print "getEntityPosition : convert face number to i,j,k" - -n1 = grid.getEntityPosition(MED_FACE,6) -n2 = grid.getEntityPosition(MED_FACE,8) - -if n1 == [1,2,1]: o1 = "Ok" -else: o1 = "KO" -if n2 == [1,1,2]: o2 = "Ok" -else: o2 = "KO" - -print "Face 6 -> i,j = ", n1, " : ", o1 -print "Face 8 -> i,j = ", n2, " : ", o2 - -print "getNodeNumber : convert i,j,k to node number" - -n1 = grid.getNodeNumber(2,1,0) -n2 = grid.getNodeNumber(1,2,0) - -if n1 == 7: o1 = "Ok" -else: o1 = "KO" -if n2 == 10: o2 = "Ok" -else: o2 = "KO" - -print "getNodeNumber 2,1,0 = ", n1, " : ", o1 -print "getNodeNumber 1,2,0 = ", n2, " : ", o2 - -print "getCellNumber : convert i,j,k to cell number" - -n1 = grid.getCellNumber(1,0,0) -n2 = grid.getCellNumber(2,1,0) - -if n1 == 2: o1 = "Ok" -else: o1 = "KO" -if n2 == 6: o2 = "Ok" -else: o2 = "KO" - -print "getCellNumber 1,0,0 = ", n1, " : ", o1 -print "getCellNumber 2,1,0 = ", n2, " : ", o2 - -print "getFaceNumber : convert i,j,k to face number" - -n1 = grid.getFaceNumber(0,0,2,0) -n2 = grid.getFaceNumber(0,1,1,0) - -if n1 == 7: o1 = "Ok" -else: o1 = "KO" -if n2 == 5: o2 = "Ok" -else: o2 = "KO" - -print "getFaceNumber 1,0,2,0 = ", n1, " : ", o1 -print "getFaceNumber 1,1,1,0 = ", n2, " : ", o2 - -print "Connectivity" -n1 = grid.getNodeNumber(0,0,0) -n2 = grid.getNodeNumber(0,1,0) -n3 = grid.getNodeNumber(1,1,0) -n4 = grid.getNodeNumber(1,0,0) - -conn1 = [n1,n2,n3,n4] - -Connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,types[0]) -print "connectivity =", Connectivity - -print "Cell 1 nodes:", conn1, Connectivity[0:4] -if list(conn1) != list(Connectivity[0:4]): - raise RuntimeError, "Wrong nodal connectivity" - - -ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL) -ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL) -n = 6 -beg = ReverseConnectivityIndex[n-1]-1 -end = ReverseConnectivityIndex[n]-1 -print "Node",n,"rev connectivity =",ReverseConnectivity[beg:end] -if end-beg != 4: - raise RuntimeError, "Wrong reverse connectivity" -if ReverseConnectivity[beg] != 1: - raise RuntimeError, "Wrong reverse connectivity" - -edgfecon = mesh.getConnectivity(MED_NODAL,MED_EDGE,MED_ALL_ELEMENTS) -print edgfecon -print len(edgfecon) - -mesh.calculateConnectivity(MED_DESCENDING,MED_CELL) -Connectivity = mesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) -ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL) -n = 1 -beg = ConnectivityIndex[n-1]-1 -end = ConnectivityIndex[n]-1 -print "Element",n,"descending connectivity -->",Connectivity[beg:end] -if list(Connectivity[beg:end]) != [13, 4, 14, 1]: - raise RuntimeError, "Wrong descending connectivity" - -print "getReverseConnectivity(MED_DESCENDING)", mesh.getReverseConnectivity(MED_DESCENDING) -print "grid.getReverseConnectivityIndex(MED_DESCENDING)",mesh.getReverseConnectivityIndex(MED_DESCENDING) - -############################## -# test "bodyfitted" -############################## - -mesh_name = md.getMeshName(1) -print "Read", mesh_name -grid = GRID(MED_DRIVER,medFile,mesh_name) - -if grid.getIsAGrid() == 0: - raise RuntimeError, "Mesh 1 is not a grid" - -mesh = grid.convertInMESH() - -I = grid.getArrayLength(1) -print "_iArrayLength", I -if I != 2: - raise RuntimeError, "Error in grid.getArrayLength(1)" - -J = grid.getArrayLength(2) -print "_jArrayLength", J -if J != 2: - raise RuntimeError, "Error in grid.getArrayLength(2)" - -K = grid.getArrayLength(3) -print "_kArrayLength", K -if K != 0: - raise RuntimeError, "Error in grid.getArrayLength(3)" - -grid_type = grid.getGridType() -print "grid_type =", grid_type -if grid_type != MED_BODY_FITTED: - raise RuntimeError, "Wrong grid type" - -spaceDim = grid.getSpaceDimension() -print "spaceDim =", spaceDim -if spaceDim != 2: - raise RuntimeError, "Wrong space dimention" - -meshDim = grid.getMeshDimension() -print "meshDim =", meshDim -if spaceDim != meshDim: - raise RuntimeError, "Wrong mesh dimention" - -nbNodes = grid.getNumberOfNodes() -print "nbNodes =", nbNodes -if nbNodes != 4: - raise RuntimeError, "Wrong nb of nodes" - -coordSyst = grid.getCoordinatesSystem() -print "coordSyst =", coordSyst -if coordSyst != "CARTESIAN": - raise RuntimeError, "Wrong coordinates system" - -nbTypesCell = grid.getNumberOfTypes(MED_CELL) -print "nbTypesCell =", nbTypesCell -if nbTypesCell != 1: - raise RuntimeError, "Wrong nbTypesCell" - -types = grid.getTypes(MED_CELL) -print "Cell types =", types -if types != [204]: - raise RuntimeError, "Wrong Cell types" - -nbElemType = grid.getNumberOfElements(MED_CELL,types[0]) -print "Nb cells =", nbElemType -if nbElemType != 1: - raise RuntimeError, "Wrong Nb cells" - -Connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,types[0]) -print "connectivity =", Connectivity -n1 = grid.getNodeNumber(0,0,0) -n2 = grid.getNodeNumber(0,1,0) -n3 = grid.getNodeNumber(1,1,0) -n4 = grid.getNodeNumber(1,0,0) -conn1 = [n1,n2,n3,n4] -print "Cell 1 nodes:", conn1, Connectivity[0:4] -if conn1 != list(Connectivity[0:4]): - raise RuntimeError, "Wrong nodal connectivity" - -############################################## -# test "maa1" which in fact is not a pure GRID -############################################## - -mesh_name = md.getMeshName(2) - -print "Read", mesh_name -mesh = MESH(MED_DRIVER,md.getFileName(),mesh_name) - -if mesh.getIsAGrid() == 0: - print "Mesh ",mesh_name," is not a grid" - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/med_test_skin.py b/src/MEDMEM_SWIG/med_test_skin.py deleted file mode 100644 index d886715fd..000000000 --- a/src/MEDMEM_SWIG/med_test_skin.py +++ /dev/null @@ -1,88 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#% Test function MESH::getSkin() on mesh from file cube_hexa8_quad4.med -#% The med file can be obtained by running create_mesh_c3h8q4 executable -# -from libMEDMEM_Swig import * -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, "cube_hexa8_quad4.med") - -print "" -print "Read file", medFile -print "" - -md = MEDFILEBROWSER(medFile) - -mesh_name = md.getMeshName(0) -mesh = MESH(MED_DRIVER,medFile,mesh_name) - -print "Building the support on all (8) Cells of the mesh." -supportCell = mesh.getSupportOnAll(MED_CELL) - -print "Getting skin of an all cell support" - -supportSkin = mesh.getSkin(supportCell) -faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] ) -print "--------", faceNumbers -if faceNumbers != [2, 3, 6, 8, 10, 11, 12, 13, 16, 17, 19, 20, 22, 23, 24, 27, 28, 29, 30, 31, 32, 34, 35, 36]: - raise RuntimeError, "Wrong skin of an all cell support" - -print "Build the support on 1 Cell (#8) of the mesh." -supportCell = SUPPORT( supportCell ) -supportCell.setAll( 0 ) -nbGeomTypes = 1 -nbTotalEntity = 1 -GeometricType = mesh.getTypes(MED_CELL) -nbEntityList = [1, 2] -EntityNbs = [8] -supportCell.setpartial("1 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs) - -print "Getting skin of 1 cell support" -supportSkin = mesh.getSkin(supportCell) -faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] ) -print "Skin Support FACE numbers:" -print "--------", faceNumbers -if faceNumbers != [18, 26, 33, 34, 35, 36]: - raise RuntimeError, "Wrong skin of 1 cell support" - - - -print "Building the support on 2 Cells (#1 #2) of the mesh." -nbTotalEntity = 2 -nbEntityList = [1, 3] -EntityNbs = [1, 2] -supportCell.setpartial("2 Cell support",nbGeomTypes,nbTotalEntity,GeometricType,nbEntityList,EntityNbs) - -print "Getting skin of 2 cell support" -supportSkin = mesh.getSkin(supportCell) -faceNumbers = supportSkin.getNumber( supportSkin.getTypes()[0] ) -print "Skin Support FACE numbers:", faceNumbers -if faceNumbers != [1, 2, 3, 4, 6, 7, 8, 9, 10, 11]: - raise RuntimeError, "Wrong skin of 2 cells support" diff --git a/src/MEDMEM_SWIG/medmem.py b/src/MEDMEM_SWIG/medmem.py deleted file mode 100644 index cb7d80703..000000000 --- a/src/MEDMEM_SWIG/medmem.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -from libMEDMEM_Swig import * diff --git a/src/MEDMEM_SWIG/medutilities.py b/src/MEDMEM_SWIG/medutilities.py deleted file mode 100644 index b24f81117..000000000 --- a/src/MEDMEM_SWIG/medutilities.py +++ /dev/null @@ -1,468 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# -- -# Copyright (C) 2009-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Erwan ADAM (CEA) -# -- - -from libMEDMEM_Swig import * - -def my_remove(f): - from os import remove - try: - remove(f) - except OSError: - pass - return - -def sauv2med(*argv): - argv = list(argv) - # argv = argv[1:] - for arg in argv: - convert(arg, "GIBI", "MED") - pass - return - -def med2sauv(*argv): - argv = list(argv) - # argv = argv[1:] - format = 1 - for arg in argv[:]: - if arg.find('--format') == 0: - argv.remove(arg) - try: - value = arg.split("=")[1] - except IndexError: - usage(1) - pass - try: - value = int(value) - except ValueError: - usage(1) - pass - format = value - pass - pass - for arg in argv: - convert(arg, "MED", "GIBI", format) - pass - return - -def convert(file_in, driver_in, driver_out, format=1, file_out=None): - # - print file_in - # - if file_out is None: - file_out = file_in -## if file_out.find('.') != -1: -## suffix = file_in.split('.')[-1] -## if driver_in == "GIBI": -## test = "sauv" -## else: -## test = "med" -## pass -## if len(suffix) >= len(test): -## suffix = suffix[:len(test)] -## suffix = suffix.lower() -## if suffix == test: -## file_out = '.'.join(file_in.split('.')[:-1]) -## pass -## pass -## pass - if driver_out == "GIBI": - file_out += ".sauv" - elif driver_out == "MED": - file_out += ".med" - else: - msg = "Driver out %s is unknown"%(driver_out) - raise NotImplementedError(msg) - pass - print file_out - # - meshes = [] - fields = [] - if driver_in == "GIBI": - driver = GIBI_MED_RDONLY_DRIVER(file_in) - fields = driver.read() - mesh = driver.getMesh() - if mesh: - meshes.append( mesh ) - elif driver_in == "MED": - med = MEDFILEBROWSER(file_in) - for mesh_name in med.getMeshNames(): - if med.isStructuredMesh( mesh_name ): - mesh = GRID( MED_DRIVER, file_in, mesh_name ) - else: - mesh = MESH( MED_DRIVER, file_in, mesh_name ) - meshes.append( mesh ) - for field_name in med.getFieldNames(): - mesh_name = med.getMeshName( field_name ) - mesh = 0 - for m in meshes: - if m.getName() == mesh_name: - mesh = m; break - for dtit in med.getFieldIteration( field_name ): - if med.getFieldType( field_name ) == MED_REEL64: - field = FIELDDOUBLE(MED_DRIVER, file_in, field_name, dtit.dt, dtit.it, mesh ) - else: - field = FIELDINT(MED_DRIVER, file_in, field_name, dtit.dt, dtit.it, mesh ) - fields.append( field ) - else: - msg = "Driver in %s is unknown"%(driver_in) - raise NotImplementedError(msg) - # - my_remove(file_out) - # - if driver_out == "GIBI": - mesh = meshes[0] - mesh_dim = mesh.getSpaceDimension() - if format == 0: - file_out = file_out+'__format__' - my_remove(file_out) - pass - if fields: - driver = GIBI_MED_WRONLY_DRIVER(file_out, fields, mesh) - else: - driver = GIBI_MESH_WRONLY_DRIVER(file_out, mesh) - driver.open() - driver.write() - driver.close() - # - if mesh_dim >= 3: - from sys import platform - if platform in ["win32"]: - f = open(file_out) - content = f.read() - f.close() - content = content.replace("IFOUR -1", "IFOUR 2") - content = content.replace("IFOMOD -1", "IFOMOD 2") - f = open(file_out, "w") - f.write(content) - f.close() - else: - cmd = "sed" - cmd += ' -e "s/IFOUR -1/IFOUR 2/g"' - cmd += ' -e "s/IFOMOD -1/IFOMOD 2/g"' - # cmd += ' -e "s/IECHO 1/IECHO 0/g"' - cmd += ' %s > .dummy'%(file_out) - cmd += ' && ' - cmd += ' mv -f .dummy %s'%(file_out) - from os import system - system(cmd) - pass - pass - # - if format == 0: - from castemlauncher import CastemLauncher - dgibi_stream = "\n" - dgibi_stream += "OPTI REST FORMAT '%s' ;\n"%(file_out) - dgibi_stream += "REST FORMAT;\n" - file_out = file_out.replace('__format__', '') - dgibi_stream += "OPTI SAUV '%s' ;\n"%(file_out) - dgibi_stream += "SAUV ;\n" - cl = CastemLauncher(dgibi_stream) - cl.addTmpFiles(file_out+'__format__', "UTILNOTI", "UTILPROC") - cl.run() - pass - return - # - for mesh in meshes: - mesh.write(MED_DRIVER, file_out) - for field in fields: - typedField = field.castToTypedField(); - typedField.write(MED_DRIVER, file_out) - # - return - -def avs2med_one_file(file_in, file_out, mesh_name, field_name): - """ - Convert an ucd avs inp file into a med file - inp Specifications can be found at : - http://people.scs.fsu.edu/~burkardt/data/ucd/ucd.html - http://help.avs.com/Express/doc/help/reference/dvmac/UCD_Form.htm - - """ - my_remove(file_out) - # - meshing = MESHING() - meshing.setName(mesh_name) - # - f = open(file_in) - lines = f.readlines() - f.close() - nb_lines = len(lines) - # ---- - # Skip the comments - # ---- - while 1: - l = lines[0] - if l[0] != "#": - break - lines = lines[1:] - pass - # ---- - headers = [ int(i) for i in lines[0].split() ] - lines = lines[1:] - number_of_nodes = headers[0] - number_of_cells = headers[1] - number_of_nodes_data = headers[2] - number_of_cells_data = headers[3] - number_of_whole_data = headers[3] - # ---------- - # Nodes - # ---------- - nodes = lines[:number_of_nodes] - lines = lines[number_of_nodes:] - nodes = [ " ".join(l.split()[1:]) for l in nodes ] - nodes = " ".join(nodes) - nodes = [ float(v) for v in nodes.split() ] - # -------- - # Space dimension - # -------- - nodes_min = min(nodes) - nodes_max = max(nodes) - epsilon = 1.0e-5 * (nodes_max - nodes_min) - nodes_z = [ nodes[i] for i in range(2, 3 * number_of_nodes, 3) ] - nodes_z_min = min(nodes_z) - nodes_z_max = max(nodes_z) - space_dimension = 2 - if abs(nodes_z_max) > epsilon: - space_dimension = 3 - pass - if abs(nodes_z_min) > epsilon: - space_dimension = 3 - pass - # - if space_dimension == 2: - l = range(0, 3 * number_of_nodes, 3) + range(1, 3 * number_of_nodes, 3) - l.sort() - nodes = [ nodes[i] for i in l ] - pass - # - meshing.setCoordinates(space_dimension, number_of_nodes, nodes, "CARTESIAN", MED_FULL_INTERLACE) - # ---------- - # Cells - # ---------- - cells = lines[:number_of_cells] - lines = lines[number_of_cells:] - cells = [ c.split() for c in cells ] - # - type2connectivity = {} - for c in cells: - cell_id = int(c[0]) - cell_mat = int(c[1]) - cell_type = c[2] - cell_connectivity = c[3:] - # - avs_type = cell_type - if 0: - pass - elif avs_type == 'tri': - entity = MED_CELL - nb2medtype = { - 3: MED_TRIA3, - } - elif avs_type == 'quad': - entity = MED_CELL - nb2medtype = { - 4: MED_QUAD4, - 8: MED_QUAD8, - } - elif avs_type == 'tet': - entity = MED_CELL - nb2medtype = { - 4: MED_TETRA4, - } - elif avs_type == 'hex': - entity = MED_CELL - nb2medtype = { - 8: MED_HEXA8, - } - elif avs_type == 'pyr': - entity = MED_CELL - nb2medtype = { - 5: MED_PYRA5, - } - elif avs_type == 'prism': - entity = MED_CELL - nb2medtype = { - 6: MED_PENTA6, - } - else: - raise Exception("unknown avs_type : %s"%(avs_type)) - # - med_type = nb2medtype[len(cell_connectivity)] - # - try: - d = type2connectivity[entity] - except: - type2connectivity[entity] = {} - d = type2connectivity[entity] - pass - # - try: - l = d[med_type] - except: - d[med_type] = [] - l = d[med_type] - pass - # - cell_connectivity = ' '.join(cell_connectivity) - l.append(cell_connectivity) - # - pass - # - mesh_dimension = space_dimension - # - for entity, d in type2connectivity.items(): - meshing.setNumberOfTypes(len(d.keys()), entity) - meshing.setTypes(d.keys(), entity) - meshing.setNumberOfElements([len(v) for v in d.values()], entity) - for key, value in d.items(): - connectivity = value - connectivity = " ".join(connectivity) - connectivity = [ int(v) for v in connectivity.split() ] - meshing.setConnectivity(connectivity, entity, key) - pass - pass - # ----------- - meshing.write(meshing.addDriver(MED_DRIVER,file_out,meshing.getName())) - # ----------- - flag = -1 - for n in [number_of_nodes_data, number_of_cells_data]: - flag += 1 - if n == 0: - continue - # ----------- - header = [ int(v) for v in lines[0].split() ] - lines = lines[1:] - nb_of_components = header[0] - nb_of_values_by_component = header[1:] - if len(nb_of_values_by_component) != nb_of_components: - msg = "Error at line %d"%(nb_lines - len(lines)) - raise Exception(msg) - # - titles_by_component = [] - for i in range(nb_of_components): - l = lines[0] - lines = lines[1:] - label = l.split(',')[0] - unit = l[len(label)+1:] # The +1 is for the comma - label = label.strip() - unit = unit.strip() - labels_by_value = nb_of_values_by_component[i]*[''] - l = [label, unit, labels_by_value] - titles_by_component.append(l) - pass - if nb_of_components > 1: - if nb_of_values_by_component == nb_of_components * [1]: - nb_of_values_by_component = [ nb_of_components ] - nb_of_components = 1 - if flag == 0: - if number_of_cells_data: - name = field_name + "_on_nodes" - pass - pass - else: - if number_of_nodes_data: - name = field_name + "_on_cells" - pass - pass - titles_by_component = [ [name, "", [t[0] for t in titles_by_component]] ] - pass - pass - if flag == 0: - nb = number_of_nodes - else: - nb = number_of_cells - pass - values = lines[:nb] - lines = lines[nb:] - vals = [] - imin = 1 - for i in range(nb_of_components): - imax = imin + nb_of_values_by_component[i] - vals.append([ l.split()[imin:imax] for l in values ]) - imin = imax - pass - values = vals - # ---------- - if flag == 0: - support = SUPPORT(meshing, "support_on_nodes", MED_NODE) - else: - support = SUPPORT(meshing, "support_on_cells", MED_CELL) - pass - for i in range(nb_of_components): - nb = nb_of_values_by_component[i] - field = FIELDDOUBLE(support, nb) - field.setName(titles_by_component[i][0]) - # field.setIterationNumber(-1) - # field.setOrderNumber(-1) - # field.setTime(0.0) - for n in range(nb): - name = titles_by_component[i][2][n] - if name: - field.setComponentName(n+1,name) - pass - pass - # --------------- - value = values[i] - value = [ " ".join(l) for l in value ] - value = " ".join(value) - value = [ float(v) for v in value.split() ] - field.setValue(value) - # ----- - field.write(field.addDriver(MED_DRIVER,file_out,field.getName())) - # ------- - pass - # - pass - return - -def avs2med(*argv): - argv = list(argv) - # - mesh_name = "mesh" - field_name = "field" - # - for arg in argv[:]: - if ( arg.find('--mesh_name') == 0 ) or ( arg.find('--mesh-name') == 0 ) : - argv.remove(arg) - try: - mesh_name = arg.split("=")[1] - except IndexError: - usage(1) - pass - pass - if ( arg.find('--field_name') == 0 ) or ( arg.find('--field-name') == 0 ) : - argv.remove(arg) - try: - field_name = arg.split("=")[1] - except IndexError: - usage(1) - pass - pass - pass - # - for arg in argv: - avs2med_one_file(arg, arg + ".med", mesh_name, field_name) - pass - # - return - diff --git a/src/MEDMEM_SWIG/my_typemap.i b/src/MEDMEM_SWIG/my_typemap.i deleted file mode 100644 index 0837216d8..000000000 --- a/src/MEDMEM_SWIG/my_typemap.i +++ /dev/null @@ -1,264 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifdef WITH_NUMPY -%init %{ - import_array(); -%} -#endif - -%{ -#include - -#ifdef WITH_NUMPY -#include -#endif -%} - -#if defined(SWIGPYTHON) -%typemap(in) std::string * , const std::string * , const std::string * const { - /* typemap in for string * , const string * , const string * const */ - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $1 = new string[size]; - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyString_Check(o)) - $1[i] = string(PyString_AsString(PyList_GetItem($input,i))); - else { - PyErr_SetString(PyExc_TypeError,"list must contain strings"); - delete [] ($1); - return NULL; - } - } - } - else - { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} -%typemap(freearg) string * , const string * , const string * const { - delete [] ($1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) double * , const double * , const double * const -{ - /* typemap in for double * , const double * , const double * const */ - /* Check if $input is a list */ - bool ok = false; - if (!ok && PyList_Check($input)) - { - int size = PyList_Size($input); - int i = 0; - $1 = (double *) malloc(size*sizeof(double)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyFloat_Check(o)) - $1[i] = PyFloat_AsDouble(PyList_GetItem($input,i)); - else { - PyErr_SetString(PyExc_TypeError,"list must contain floats"); - free($1); - return NULL; - } - } - ok = true; - } -#ifdef WITH_NUMPY - /* Check if $input is a ndarray */ - if ( !ok && PyArray_Check($input)) - { - if ( !PyArray_ISFLOAT ($input)) - { - PyErr_SetString(PyExc_TypeError,"ndarray must contain floats"); - return NULL; - } - - npy_intp size = PyArray_SIZE($input); - double* workPtr = $1 = (double *) malloc(size*sizeof(double)); - - if ( PyArray_ISCONTIGUOUS( $input )) // the data is in a single C-style contiguous segment - { - const char * dataPtr = PyArray_BYTES( $input ); - int step = PyArray_ITEMSIZE( $input ); - while(size--) - { - *workPtr++ = *((const double*) dataPtr); - dataPtr += step; - } - } - else - { - PyArrayIterObject *iter = (PyArrayIterObject *)PyArray_IterNew($input); - if ( !iter ) - { - PyErr_SetString(PyExc_RuntimeError,"can't iterate over a ndarray"); - free($1); - return NULL; - } - while (iter->index < iter->size) - { - *workPtr++ = *((const double*) iter->dataptr); - PyArray_ITER_NEXT(iter); - } - } - ok = true; - } -#endif - if ( !ok ) - { - PyErr_SetString(PyExc_TypeError,"not a list nor a ndarray"); - return NULL; - } -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) int * , const int * , const int * const -{ - /* typemap in for int * , const int * , const int * const */ - /* Check if is a list */ - bool ok = false; - if (PyList_Check($input)) - { - int size = PyList_Size($input); - int i = 0; - $1 = (int *) malloc(size*sizeof(int)); - for (i = 0; i < size; i++) - { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) - $1[i] = PyInt_AsLong(PyList_GetItem($input,i)); - else { - PyErr_SetString(PyExc_TypeError,"list must contain integers"); - free($1); - return NULL; - } - } - ok = true; - } -#ifdef WITH_NUMPY - /* Check if $input is a ndarray */ - if ( !ok && PyArray_Check($input)) - { - if ( !PyArray_ISINTEGER ($input)) - { - PyErr_SetString(PyExc_TypeError,"ndarray must contain integers"); - return NULL; - } - - npy_intp size = PyArray_SIZE($input); - int* workPtr = $1 = (int *) malloc(size*sizeof(int)); - - if ( PyArray_ISCONTIGUOUS( $input )) // the data is in a single C-style contiguous segment - { - const char * dataPtr = PyArray_BYTES( $input ); - int step = PyArray_ITEMSIZE( $input ); - while(size--) - { - *workPtr++ = *((const int*) dataPtr); - dataPtr += step; - } - } - else - { - PyArrayIterObject *iter = (PyArrayIterObject *)PyArray_IterNew($input); - if ( !iter ) - { - PyErr_SetString(PyExc_RuntimeError,"can't iterate over a ndarray"); - free($1); - return NULL; - } - while (iter->index < iter->size) - { - *workPtr++ = *((const int*) iter->dataptr); - PyArray_ITER_NEXT(iter); - } - } - ok = true; - } -#endif - if ( !ok ) - { - PyErr_SetString(PyExc_TypeError,"not a list nor a ndarray"); - return NULL; - } -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) medGeometryElement * , const medGeometryElement * , const medGeometryElement * const -{ - /* typemap in for medGeometryElement * , const medGeometryElement * , const medGeometryElement * const */ - /* Check if is a list */ - if (PyList_Check($input)) { - int size = PyList_Size($input); - int i = 0; - $1 = (medGeometryElement *) malloc(size*sizeof(medGeometryElement)); - for (i = 0; i < size; i++) { - PyObject *o = PyList_GetItem($input,i); - if (PyInt_Check(o)) - $1[i] = (medGeometryElement) PyInt_AsLong(PyList_GetItem($input,i)); - else { - PyErr_SetString(PyExc_TypeError,"list must contain integers"); - free($1); - return NULL; - } - } - } - else - { - PyErr_SetString(PyExc_TypeError,"not a list"); - return NULL; - } -} -#endif - -#if defined(SWIGPYTHON) -%typemap(out) list { - int i; - list::iterator iL; - - $result = PyList_New($1->size()); - for (i=0, iL=$1->begin(); iL!=$1->end(); i++, iL++) - PyList_SetItem($result,i,PyString_FromString((*iL).c_str())); -} -#endif - -%typemap(freearg) int * , const int * , const int * const { - /* free the memory allocated in the typemap in for int * , const int * , const int * const */ - free($1); -} - -%typemap(freearg) double * , const double * , const double * const { - /* free the memory allocated in the typemap in for double * , const double * , const double * const */ - free($1); -} - -%typemap(freearg) medGeometryElement * , const medGeometryElement * , const medGeometryElement * const { - /* free the memory allocated in the typemap in for medGeometryElement * , const medGeometryElement * , const medGeometryElement * const */ - free($1); -} diff --git a/src/MEDMEM_SWIG/sauv2med b/src/MEDMEM_SWIG/sauv2med deleted file mode 100755 index 3cf468ac5..000000000 --- a/src/MEDMEM_SWIG/sauv2med +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# -- -# Copyright (C) 2009-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -# Author : Erwan ADAM (CEA) -# -- - -from sys import argv -d = argv[0] -from os.path import dirname -d = dirname(d) -from os.path import abspath -d = abspath(d+'/../lib') -from sys import path -if d not in path: - path.insert(0, d) - pass - -from medutilities import sauv2med -from sys import argv -sauv2med(*argv[1:]) diff --git a/src/MEDMEM_SWIG/testDriverAscii.py b/src/MEDMEM_SWIG/testDriverAscii.py deleted file mode 100644 index 1bb08a2ff..000000000 --- a/src/MEDMEM_SWIG/testDriverAscii.py +++ /dev/null @@ -1,54 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -from libMEDMEM_Swig import * - -import os - -# -#before running this script, please be sure about the path the file fileName -# - -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, "test_2D.med") - -asciiFile = "tyst.txt" - -md=MEDFILEBROWSER(medFile) - -nbMeshes = md.getNumberOfMeshes() - -nbFields = md.getNumberOfFields() - -print "The med file", medFile, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)" -f1Name=md.getFieldName(0) -mesh_name=md.getMeshName(f1Name) -mesh=MESH(MED_DRIVER,medFile,mesh_name) -it=md.getFieldIteration(f1Name)[0] -f1=FIELDDOUBLE(MED_DRIVER,medFile,f1Name,it.dt,it.it,mesh) -id2=f1.addDriver(ASCII_DRIVER,asciiFile,"Default Field Name",MED_ECRI) -f1.write(id2) - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/testGaussLocalization.py b/src/MEDMEM_SWIG/testGaussLocalization.py deleted file mode 100644 index ed6979fae..000000000 --- a/src/MEDMEM_SWIG/testGaussLocalization.py +++ /dev/null @@ -1,137 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -# This Python script is to test the API of the C++ GAUSS_LOCALIZATION class -# defined in MEDMEM_GaussLocalization.hxx. This test is the Python equivalent -# of the test_GaussLocalization.cxx program. -################################################################################### -# -from libMEDMEM_Swig import * - -a = 0.446948490915965 -b = 0.091576213509771 -p1 = 0.11169079483905 -p2 = 0.0549758718227661 - -typeGeo = MED_TRIA6 - -ngauss = 6 - -gaussLocName = "Model n1" - -refCoo = [-1.0,1.0, - -1.0,-1.0, - 1.0,-1.0, - -1.0,0.0, - 0.0,-1.0, - 0.0,0.0] - -gsCoo = [2*b-1, 1-4*b, - 2*b-1, 2*b-1, - 1-4*b, 2*b-1, - 1-4*a, 2*a-1, - 2*a-1, 1-4*a, - 2*a-1, 2*a-1] - -weight = [4*p2, 4*p2, 4*p2, 4*p1, 4*p1, 4*p1] - -interlacingType = MED_FULL_INTERLACE - -gaussLoc = GAUSS_LOCALIZATION_FULL(gaussLocName, typeGeo, ngauss, refCoo, - gsCoo, weight) - -print "Gauss Localization via the str operator: ", gaussLoc - -print "Gauss Localization via the get methods from the class API" - -typeGeoVerif = gaussLoc.getType() - -ngaussVerif = gaussLoc.getNbGauss() - -gaussLocNameVerif = gaussLoc.getName() - -refCooVerif = gaussLoc.getRefCoo() - -gsCooVerif = gaussLoc.getGsCoo() - -weightVerif = gaussLoc.getWeight() - -interlacingTypeVerif = gaussLoc.getInterlacingType() - -lenrefCoo = len(refCoo) -lenrefCooVerif = len(refCooVerif) - -lengsCoo = len(gsCoo) -lengsCooVerif = len(gsCooVerif) - -lenweight = len(weight) -lenweightVerif = len(weightVerif) - -if (typeGeo != typeGeoVerif): - print "the geometric type does not match" - print typeGeo, " verif ", typeGeo - pass - -if (ngauss != ngaussVerif): - print "the number of Gauss points does not match" - print ngauss, " verif ", ngaussVerif - pass - -if (interlacingType != interlacingTypeVerif): - print "the interlacing type does not match" - print interlacingType, " verif ", interlacingTypeVerif - pass - -if (gaussLocName != gaussLocNameVerif): - print "the Gauss Location name does not match" - print gaussLocName, " verif ", gaussLocNameVerif - pass - -if (lenrefCoo == lenrefCooVerif): - print "refCoo verification -- length ",lenrefCoo - for i in range(lenrefCoo): - if (refCoo[i] != refCooVerif[i]): - print " * ",i," ",refCoo[i], " --- ",refCooVerif[i] -else: - print "the array of referrence element coordinates does not match" - -if (lengsCoo == lengsCooVerif): - print "gsCoo verification -- length ",lengsCoo - for i in range(lengsCoo): - if (gsCoo[i] != gsCooVerif[i]): - print " * ",i," ",gsCoo[i], " --- ",gsCooVerif[i] -else: - print "the array of gauss points coordinates does not match" - -if (lenweight == lenweightVerif): - print "weight verification -- length ",lenweight - for i in range(lenweight): - if (weight[i] != weightVerif[i]): - print " * ",i," ",weight[i], " --- ",weightVerif[i] -else: - print "the array of gauss points weight does not match" - -print "seems to be OK" -print "" -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/testMedMemCxxTests.py b/src/MEDMEM_SWIG/testMedMemCxxTests.py deleted file mode 100644 index 988e80b6f..000000000 --- a/src/MEDMEM_SWIG/testMedMemCxxTests.py +++ /dev/null @@ -1,623 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -from libMEDMEM_Swig import * - -import os,string - -filesPath=os.environ["MED_ROOT_DIR"] -filesPath=os.path.join(filesPath, "share", "salome", "resources", "med") - -testExecfiles = [] -argListTest = [] -rootFileTest = [] -meshTest = [] -fieldTest = [] - -# executables list to test functionalities - -testExecfiles.append("testUArray") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUCellModel") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUCoordinate") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUGeoNameMeshEntities") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUMedException") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUModulusArray") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUPointerOf") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUSkyLineArray") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("testUUnit") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_affect_medarray") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_copie_coordinate") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_copie_medarray") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_MEDMEM_Array") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_MEDMEM_CellModel") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_MEDMEM_ModulusArray") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_MEDMEM_SkyLineArray") -argListTest.append("") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_MEDMEM_Meshing") -argListTest.append("toto") -rootFileTest.append("") -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("Darcy3_3D_H_10x10x10") -argListTest.append(os.path.join(filesPath,"Darcy3_3D_H_10x10x10.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("dx200_dy1_avec_2couches") -argListTest.append(os.path.join(filesPath,"dx200_dy1_avec_2couches.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("elle_2D_QT_10x10") -argListTest.append(os.path.join(filesPath,"elle_2D_QT_10x10.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("elle_2D_QT_2x2") -argListTest.append(os.path.join(filesPath,"elle_2D_QT_2x2.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("elle_2D_QT_40x40") -argListTest.append(os.path.join(filesPath,"elle_2D_QT_40x40.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("elle_2D_QT_4x4") -argListTest.append(os.path.join(filesPath,"elle_2D_QT_4x4.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("elle_3D_HPr_10x10x10") -argListTest.append(os.path.join(filesPath,"elle_3D_HPr_10x10x10.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("elle_3D_HPr_2x2x2") -argListTest.append(os.path.join(filesPath,"elle_3D_HPr_2x2x2.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("elle_3D_HPr_4x4x4") -argListTest.append(os.path.join(filesPath,"elle_3D_HPr_4x4x4.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("inclusion_2d_raf") -argListTest.append(os.path.join(filesPath,"inclusion_2d_raf.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("inclusion_2d") -argListTest.append(os.path.join(filesPath,"inclusion_2d.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_ktest1-3-hexa") -argListTest.append(os.path.join(filesPath,"mail_ktest1-3-hexa.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_ktest1-3-tetra") -argListTest.append(os.path.join(filesPath,"mail_ktest1-3-tetra.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_ktest3-1") -argListTest.append(os.path.join(filesPath,"mail_ktest3-1.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_ktest3-2") -argListTest.append(os.path.join(filesPath,"mail_ktest3-2.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("maillage_andra2_100elts") -argListTest.append(os.path.join(filesPath,"maillage_andra2_100elts.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("maillage_cas2_2d") -argListTest.append(os.path.join(filesPath,"maillage_cas2_2d.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("maillage_cas4_234elts") -argListTest.append(os.path.join(filesPath,"maillage_cas4_234elts.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("maillage_CHEMVAL_100elts") -argListTest.append(os.path.join(filesPath,"maillage_CHEMVAL_100elts.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("maillage_CHEMVAL_40elts") -argListTest.append(os.path.join(filesPath,"maillage_CHEMVAL_40elts.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("maillage_chemvalIV_cas1_100elts") -argListTest.append(os.path.join(filesPath,"maillage_chemvalIV_cas1_100elts.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("maillage_chemvalIV_cas1_40elts") -argListTest.append(os.path.join(filesPath,"maillage_chemvalIV_cas1_40elts.sauve")) -meshTest.append("") -fieldTest.append("") - -# no resource file named maill_mistra_elim.sauve -# testExecfiles.append("test_gibi_driver") -# rootFileTest.append("maill_mistra_elim") -# argListTest.append(os.path.join(filesPath,"maill_mistra_elim.sauve")) -# meshTest.append("") -# fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_test1-1-qua") -argListTest.append(os.path.join(filesPath,"mail_test1-1-qua.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_test1-1-tri") -argListTest.append(os.path.join(filesPath,"mail_test1-1-tri.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_test1-2-qua") -argListTest.append(os.path.join(filesPath,"mail_test1-2-qua.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail_test1-2-tri") -argListTest.append(os.path.join(filesPath,"mail_test1-2-tri.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail-test1-4-1") -argListTest.append(os.path.join(filesPath,"mail-test1-4-1.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_gibi_driver") -rootFileTest.append("mail-test1-4-2") -argListTest.append(os.path.join(filesPath,"mail-test1-4-2.sauve")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_porflow_driver") -rootFileTest.append("boitenew") -argListTest.append(os.path.join(filesPath,"boitenew.inp")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_porflow_driver") -rootFileTest.append("Case1") -argListTest.append(os.path.join(filesPath,"Case1.inp")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_porflow_driver") -rootFileTest.append("cube") -argListTest.append(os.path.join(filesPath,"cube.inp")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_porflow_driver") -rootFileTest.append("test3") -argListTest.append(os.path.join(filesPath,"test3.inp")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_porflow_driver") -rootFileTest.append("titi") -argListTest.append(os.path.join(filesPath,"titi.inp")) -meshTest.append("") -fieldTest.append("") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("mesh") -meshTest.append("Mesh 1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"mesh.med") + " " + "'Mesh 1'") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("maillage_UniSegFam") -meshTest.append("maillage_CHEMVAL_100elts") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"maillage_UniSegFam.med") + " " + "maillage_CHEMVAL_100elts") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("carre_en_quad4") -meshTest.append("carre_en_quad4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"carre_en_quad4.med") + " " + "carre_en_quad4") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("cube_hexa8") -meshTest.append("CUBE_EN_HEXA8") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8.med") + " " + "CUBE_EN_HEXA8") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("test19") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"test19.med") + " " + "maa1") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("carre_en_quad4_seg2") -meshTest.append("carre_en_quad4_seg2") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"carre_en_quad4_seg2.med") + " " + "carre_en_quad4_seg2") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("cube_hexa8_quad4") -meshTest.append("CUBE_EN_HEXA8_QUAD4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8_quad4.med") + " " + "CUBE_EN_HEXA8_QUAD4") - -testExecfiles.append("test_copie_connectivity") -rootFileTest.append("pointe") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"pointe.med") + " " + "maa1") - -testExecfiles.append("test_copie_family") -rootFileTest.append("mesh") -meshTest.append("Mesh 1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"mesh.med") + " " + "'Mesh 1'") - -testExecfiles.append("test_copie_family") -rootFileTest.append("pointe") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"pointe.med") + " " + "maa1") - -# no nodal families in carre_en_quad4.med -# testExecfiles.append("test_copie_family") -# rootFileTest.append("carre_en_quad4") -# meshTest.append("carre_en_quad4") -# fieldTest.append("") -# argListTest.append(os.path.join(filesPath,"carre_en_quad4.med") + " " + "carre_en_quad4") - -testExecfiles.append("test_copie_family") -rootFileTest.append("cube_hexa8") -meshTest.append("CUBE_EN_HEXA8") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8.med") + " " + "CUBE_EN_HEXA8") - -testExecfiles.append("test_copie_family") -rootFileTest.append("test19") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"test19.med") + " " + "maa1") - -# no nodal families in carre_en_quad4_seg2.med -# testExecfiles.append("test_copie_family") -# rootFileTest.append("carre_en_quad4_seg2") -# meshTest.append("carre_en_quad4_seg2") -# fieldTest.append("") -# argListTest.append(os.path.join(filesPath,"carre_en_quad4_seg2.med") + " " + "carre_en_quad4_seg2") - -testExecfiles.append("test_copie_family") -rootFileTest.append("cube_hexa8_quad4") -meshTest.append("CUBE_EN_HEXA8_QUAD4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8_quad4.med") + " " + "CUBE_EN_HEXA8_QUAD4") - -testExecfiles.append("test_copie_family") -rootFileTest.append("pointe") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"pointe.med") + " " + "maa1") - -# no nodal grous in mesh.med -# testExecfiles.append("test_copie_group") -# rootFileTest.append("mesh") -# meshTest.append("Mesh 1") -# fieldTest.append("") -# argListTest.append(os.path.join(filesPath,"mesh.med") + " " + "'Mesh 1'") - -# no nodal grous in maillage_UniSegFam.med -# testExecfiles.append("test_copie_group") -# rootFileTest.append("maillage_UniSegFam") -# meshTest.append("maillage_CHEMVAL_100elts") -# fieldTest.append("") -# argListTest.append(os.path.join(filesPath,"maillage_UniSegFam.med") + " " + "maillage_CHEMVAL_100elts") - -# no nodal grous in maillage_UniSegFam.med -# testExecfiles.append("test_copie_group") -# rootFileTest.append("carre_en_quad4") -# meshTest.append("carre_en_quad4") -# fieldTest.append("") -# argListTest.append(os.path.join(filesPath,"carre_en_quad4.med") + " " + "carre_en_quad4") - -testExecfiles.append("test_copie_group") -rootFileTest.append("cube_hexa8") -meshTest.append("CUBE_EN_HEXA8") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8.med") + " " + "CUBE_EN_HEXA8") - -testExecfiles.append("test_copie_group") -rootFileTest.append("test19") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"test19.med") + " " + "maa1") - -# no nodal grous in carre_en_quad4_seg2.med -# testExecfiles.append("test_copie_group") -# rootFileTest.append("carre_en_quad4_seg2") -# meshTest.append("carre_en_quad4_seg2") -# fieldTest.append("") -# argListTest.append(os.path.join(filesPath,"carre_en_quad4_seg2.med") + " " + "carre_en_quad4_seg2") - -testExecfiles.append("test_copie_group") -rootFileTest.append("cube_hexa8_quad4") -meshTest.append("CUBE_EN_HEXA8_QUAD4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8_quad4.med") + " " + "CUBE_EN_HEXA8_QUAD4") - -testExecfiles.append("test_copie_group") -rootFileTest.append("pointe") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"pointe.med") + " " + "maa1") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("mesh") -meshTest.append("Mesh 1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"mesh.med") + " " + "'Mesh 1'") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("maillage_UniSegFam") -meshTest.append("maillage_CHEMVAL_100elts") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"maillage_UniSegFam.med") + " " + "maillage_CHEMVAL_100elts") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("carre_en_quad4") -meshTest.append("carre_en_quad4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"carre_en_quad4.med") + " " + "carre_en_quad4") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("cube_hexa8") -meshTest.append("CUBE_EN_HEXA8") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8.med") + " " + "CUBE_EN_HEXA8") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("test19") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"test19.med") + " " + "maa1") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("carre_en_quad4_seg2") -meshTest.append("carre_en_quad4_seg2") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"carre_en_quad4_seg2.med") + " " + "carre_en_quad4_seg2") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("cube_hexa8_quad4") -meshTest.append("CUBE_EN_HEXA8_QUAD4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8_quad4.med") + " " + "CUBE_EN_HEXA8_QUAD4") - -testExecfiles.append("test_copie_mesh") -rootFileTest.append("pointe") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"pointe.med") + " " + "maa1") - -testExecfiles.append("test_copie_support") -rootFileTest.append("mesh") -meshTest.append("Mesh 1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"mesh.med") + " " + "'Mesh 1'") - -testExecfiles.append("test_copie_support") -rootFileTest.append("maillage_UniSegFam") -meshTest.append("maillage_CHEMVAL_100elts") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"maillage_UniSegFam.med") + " " + "maillage_CHEMVAL_100elts") - -testExecfiles.append("test_copie_support") -rootFileTest.append("carre_en_quad4") -meshTest.append("carre_en_quad4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"carre_en_quad4.med") + " " + "carre_en_quad4") - -testExecfiles.append("test_copie_support") -rootFileTest.append("cube_hexa8") -meshTest.append("CUBE_EN_HEXA8") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8.med") + " " + "CUBE_EN_HEXA8") - -testExecfiles.append("test_copie_support") -rootFileTest.append("test19") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"test19.med") + " " + "maa1") - -testExecfiles.append("test_copie_support") -rootFileTest.append("carre_en_quad4_seg2") -meshTest.append("carre_en_quad4_seg2") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"carre_en_quad4_seg2.med") + " " + "carre_en_quad4_seg2") - -testExecfiles.append("test_copie_support") -rootFileTest.append("cube_hexa8_quad4") -meshTest.append("CUBE_EN_HEXA8_QUAD4") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"cube_hexa8_quad4.med") + " " + "CUBE_EN_HEXA8_QUAD4") - -testExecfiles.append("test_copie_support") -rootFileTest.append("pointe") -meshTest.append("maa1") -fieldTest.append("") -argListTest.append(os.path.join(filesPath,"pointe.med") + " " + "maa1") - -############################################################################### - -nbOfTests = len(testExecfiles) - -print "Running all test programs with several arguments ... total = ",nbOfTests - -testOutfiles = [] -testErrfiles = [] - -for i in range(nbOfTests): - if (rootFileTest[i] == ""): - testOutfiles.append(testExecfiles[i] + ".out") - else: - if (meshTest[i] == ""): - testOutfiles.append(testExecfiles[i]+ "_" + rootFileTest[i] + ".out") - else: - if (fieldTest[i] == ""): - meshName = string.replace(meshTest[i]," ","_") - testOutfiles.append(testExecfiles[i]+ "_" + rootFileTest[i] + "_" + meshName + ".out") - else: - meshName = string.replace(meshTest[i]," ","_") - fieldName = string.replace(fieldTest[i]," ","_") - testOutfiles.append(testExecfiles[i]+ "_" + rootFileTest[i] + "_" + meshName + "_" + fieldName + ".out") - testErrfiles.append(testExecfiles[i] + ".err") - -for i in range(nbOfTests): - aCommand = testExecfiles[i] + " " + argListTest[i] + " > " + testOutfiles[i] + " 2> " + testErrfiles[i] - status = os.system(aCommand) - if (status != 0): - print "problem with the command ", aCommand - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/testMedMemGeneral.py b/src/MEDMEM_SWIG/testMedMemGeneral.py deleted file mode 100755 index 14802260f..000000000 --- a/src/MEDMEM_SWIG/testMedMemGeneral.py +++ /dev/null @@ -1,1294 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -# This Python script is testing all functionalities of the Med Memory through its -# Python API; for this purpose a battery of med file as well as gibi files are -# scanned using the parser written in the Python script med_test1.py with some -# addings to test other functionality written in othe Python scripts in the bin -# directory of the installation of MED -################################################################################### -# -from libMEDMEM_Swig import * -from random import * - -import sys,os,string - -filesPath = os.environ["MED_ROOT_DIR"] -filesPath = os.path.join(filesPath, "share", "salome", "resources", "med") - -tmpDir = os.getenv("TEMP") -if tmpDir == None: - tmpDir = "/tmp" - -tmpMask = os.path.join(tmpDir, "*_test.*") -os.system("rm -rf " + tmpMask) - -fileNames = [] -meshNames = [] - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `i`+'th' - -def add_one(i): - return i+1 - -################################################################################### -# -# Here is the part you should change to add another file to the test files battery -# -################################################################################### -# -# med file list -# -# from CODE_ASTER -# - -##fileNames.append("maill.0.med") -##meshNames.append("MAILTRQU") - -##fileNames.append("zzzz121b.med") -##meshNames.append("MUN") - -# -# from the SMESH Salome Module -# - -fileNames.append("mesh.med") -meshNames.append("Mesh 1") - -# -# from other source including LGLS ones -# - -fileNames.append("maillage_UniSegFam.med") -meshNames.append("maillage_CHEMVAL_100elts") - -fileNames.append("carre_en_quad4.med") -meshNames.append("carre_en_quad4") - -fileNames.append("cube_hexa8.med") -meshNames.append("CUBE_EN_HEXA8") - -##fileNames.append("test19.med") -##meshNames.append("CartGrid") - -##fileNames.append("test19.med") -##meshNames.append("bodyfitted") - -##fileNames.append("test19.med") -##meshNames.append("maa1") - -fileNames.append("carre_en_quad4_seg2.med") -meshNames.append("carre_en_quad4_seg2") - -fileNames.append("cube_hexa8_quad4.med") -meshNames.append("CUBE_EN_HEXA8_QUAD4") - -fileNames.append("pointe.med") -meshNames.append("maa1") - -fileNames.append("Mistrat.med") -meshNames.append("Mistrat_Hexa") - -##fileNames.append("TimeStamps.med") -##meshNames.append("dom") - -fileNames.append("Darcy3_3D_H_10x10x10_2.med") -meshNames.append("Darcy3_3D_H_10x10x10") - -fileNames.append("elle_3D_HPr_10x10x10_2.med") -meshNames.append("elle_3D_HPr_10x10x10") - -fileNames.append("elle_3D_HPr_2x2x2_2.med") -meshNames.append("elle_3D_HPr_2x2x2") - -fileNames.append("elle_3D_HPr_4x4x4_2.med") -meshNames.append("elle_3D_HPr_4x4x4") - - - -fileNames.append("ChampsDarcy.med") -meshNames.append("2D_I129") - -fileNames.append("darcy_1.1_res.med") -meshNames.append("mail_test1-1-tri") - -fileNames.append("darcy_1.3_resCASTEM.med") -meshNames.append("mail_ktest1-3-tetra") - -fileNames.append("darcy_1.3_resPORFLOW.med") -meshNames.append("mail_ktest1-3-hexa") - -fileNames.append("darcy_1.3_resTRACES.med") -meshNames.append("mail_ktest1-3-tetra") - -fileNames.append("darcy2_Castem_EFMH.med") -meshNames.append("mail_test1-2-tri") - -fileNames.append("darcy2_Castem_qua_EFMH.med") -meshNames.append("mail_test1-2-qua") - -fileNames.append("darcy2_Castem_qua_VF.med") -meshNames.append("mail_test1-2-qua") - -# there is a field with too long name (38 > MED_TAILLE_NOM==32): -# "analytical_field - CONCENTRATION of A1" -# so that invalid writing is sometimes fatal -# fileNames.append("Deff_fdt_5.8_castem_efmh_diff_conc_dom.med") -# meshNames.append("maillage_deffec_fdt") - -# there is a field with too long name (38 > MED_TAILLE_NOM==32): -# "analytical_field - CONCENTRATION of A1" -# so that invalid writing is sometimes fatal -# fileNames.append("Deff_fdt_5.8_castem_vf_diff_conc_dom.med") -# meshNames.append("maillage_deffec_fdt") - -fileNames.append("extendedtransport53_triangles.med") -meshNames.append("TestA3_2094_0.1_rsurf_tri") - -fileNames.append("H_CastCast_EFMH_I129_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_CastCast_VF_I129_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_CastCast_VF_Se79_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_CastPorf_I129_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_CastPorf_Se79_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_PorfCast_EFMH_I129_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_PorfCast_EFMH_Se79_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_PorfPorf_I129_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_Traces_I129_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("H_Traces_Se79_COUPLEX1.med") -meshNames.append("COUPLEX1") - -fileNames.append("maillage_5_5_5.med") -meshNames.append("maillage_5_5_5") - -fileNames.append("maillage_chemvalIV_cas1_40elts.med") -meshNames.append("maillage_chemvalIV_cas1_40elts") - - - - -# -# Castem or Gibi file list -# - -fileNames.append("Darcy3_3D_H_10x10x10.sauve") -meshNames.append("") - -fileNames.append("dx200_dy1_avec_2couches.sauve") -meshNames.append("") - -fileNames.append("elle_2D_QT_10x10.sauve") -meshNames.append("") - -fileNames.append("elle_2D_QT_2x2.sauve") -meshNames.append("") - -fileNames.append("elle_2D_QT_40x40.sauve") -meshNames.append("") - -fileNames.append("elle_2D_QT_4x4.sauve") -meshNames.append("") - -fileNames.append("elle_3D_HPr_10x10x10.sauve") -meshNames.append("") - -fileNames.append("elle_3D_HPr_2x2x2.sauve") -meshNames.append("") - -fileNames.append("elle_3D_HPr_4x4x4.sauve") -meshNames.append("") - -fileNames.append("inclusion_2d_raf.sauve") -meshNames.append("") - -fileNames.append("inclusion_2d.sauve") -meshNames.append("") - -fileNames.append("mail_ktest1-3-hexa.sauve") -meshNames.append("") - -fileNames.append("mail_ktest1-3-tetra.sauve") -meshNames.append("") - -fileNames.append("mail_ktest3-1.sauve") -meshNames.append("") - -fileNames.append("mail_ktest3-2.sauve") -meshNames.append("") - -fileNames.append("maillage_andra2_100elts.sauve") -meshNames.append("") - -fileNames.append("maillage_cas2_2d.sauve") -meshNames.append("") - -fileNames.append("maillage_cas4_234elts.sauve") -meshNames.append("") - -fileNames.append("maillage_CHEMVAL_100elts.sauve") -meshNames.append("") - -fileNames.append("maillage_CHEMVAL_40elts.sauve") -meshNames.append("") - -fileNames.append("maillage_chemvalIV_cas1_100elts.sauve") -meshNames.append("") - -fileNames.append("maillage_chemvalIV_cas1_40elts.sauve") -meshNames.append("") - -fileNames.append("mail_test1-1-qua.sauve") -meshNames.append("") - -fileNames.append("mail_test1-1-tri.sauve") -meshNames.append("") - -fileNames.append("mail_test1-2-qua.sauve") -meshNames.append("") - -fileNames.append("mail_test1-2-tri.sauve") -meshNames.append("") - -fileNames.append("mail-test1-4-1.sauve") -meshNames.append("") - -fileNames.append("mail-test1-4-2.sauve") -meshNames.append("") - -# -# Porflow file list -# - -fileNames.append("boitenew.inp") -meshNames.append("") - -fileNames.append("Case1.inp") -meshNames.append("") - -fileNames.append("cube.inp") -meshNames.append("") - -fileNames.append("test3.inp") -meshNames.append("") - -fileNames.append("titi.inp") -meshNames.append("") - -################################################################################### - -nbOfFiles = len(fileNames) -filesFull = [] - -for i in range(nbOfFiles): - filesFull.append(os.path.join(filesPath, fileNames[i])) - -################################################################################### -# -# Loop on all files -# -################################################################################### - -print " This test is running on ",nbOfFiles," files" -print "" - -for i in range(nbOfFiles): - fileName = fileNames[i] - fileFull = filesFull[i] - decompFile = string.split(fileName,".") - lenDecompFileM1 = len(decompFile)-1 - - if (lenDecompFileM1 == 0) : - print "The file ",fileName," should have at least a . in its name " - sys.exit(1) - - extensionFile = decompFile[lenDecompFileM1] - - rootFile = decompFile[0] - for k in range(1,lenDecompFileM1): - rootFile = rootFile + "." + decompFile[k] - - rootFileFull = os.path.join(tmpDir, rootFile) - - medV22FileName = rootFileFull + "V22_test.med" - vtkFileName = rootFileFull + "_test.vtk" - - try: - mesh = MESH() - if (extensionFile == "med"): - print "The file ",fileName," is a MED file and the name of the mesh is ", meshNames[i] - meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh) - meshDriver.setMeshName(meshNames[i]) - elif (extensionFile == "sauve"): - print "The file ",fileName," is a GIBI file" - meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh) - elif (extensionFile == "inp"): - print "The file ",fileName," is a PORFLOW file" - meshDriver = PORFLOW_MESH_RDONLY_DRIVER(fileFull,mesh) - else : - print "the file ",fileName,"has an unknow extension" - sys.exit(1) - - mesh.read(meshDriver) - except: - print "The mesh stored in the file ",fileName," is perhaps a GRID." - try: - print "... of MED_CARTESIAN type ?" - type = MED_CARTESIAN - mesh = GRID() - mesh.setGridType(type) - if (extensionFile == "med"): - meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh) - meshDriver.setMeshName(meshNames[i]) - elif (extensionFile == "sauve"): - meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh) - elif (extensionFile == "inp"): - print "The file ",fileName," is a PORFLOW file" - meshDriver = PORFLOW_MESH_RDONLY_DRIVER(fileFull,mesh) - else : - print "the file ",fileName,"has an unknow extension" - sys.exit(1) - - meshDriver.open() - meshDriver.read() - except: - meshDriver.close() - try: - print "... of MED_POLAR type ?" - mesh = GRID() - type = MED_POLAR - mesh.setGridType(type) - if (extensionFile == "med"): - meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh) - meshDriver.setMeshName(meshNames[i]) - elif (extensionFile == "sauve"): - meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh) - else : - print "the file ",fileName,"has an unknow extension" - sys.exit(1) - - meshDriver.open() - meshDriver.read() - except: - meshDriver.close() - print "... of MED_BODY_FITTED type ?" - mesh = GRID() - type = MED_BODY_FITTED - mesh.setGridType(type) - if (extensionFile == "med"): - meshDriver = MED_MESH_RDONLY_DRIVER(fileFull,mesh) - meshDriver.setMeshName(meshNames[i]) - elif (extensionFile == "sauve"): - meshDriver = GIBI_MESH_RDONLY_DRIVER(fileFull,mesh) - else : - print "the file ",fileName,"has an unknow extension" - sys.exit(1) - - meshDriver.open() - meshDriver.read() - - meshDriver.close() - - meshName = mesh.getName() - spaceDim = mesh.getSpaceDimension() - meshDim = mesh.getMeshDimension() - print "The mesh ",meshName," is a ",spaceDim,"D mesh on a ",meshDim,"D geometry" - - if (extensionFile == "med"): - print "and is mounted via the MED driver" - elif (extensionFile == "sauve"): - print "and is mounted via the GIBI driver" - elif (extensionFile == "inp"): - print "and is mounted via the PORFLOW driver" - - nbNodes = mesh.getNumberOfNodes() - print "The mesh ",meshName," has",nbNodes,"Nodes" - coordSyst = mesh.getCoordinatesSystem() - print "The coordinates system is",coordSyst - print "The Coordinates :" - coordNames = [] - coordUnits = [] - for isd in range(spaceDim): - coordNames.append(mesh.getCoordinateName(isd)) - coordUnits.append(mesh.getCoordinateUnit(isd)) - - print "names:", coordNames - print "units", coordUnits - print "values:" - coordinates = mesh.getCoordinates(MED_FULL_INTERLACE) - for k in range(nbNodes): - kp1 = k+1 - coords = [] - for isd in range(spaceDim): - isdp1 = isd+1 - coords.append(mesh.getCoordinate(kp1,isdp1)) - - print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)] - - print "" - print "Show the Cell Nodal Connectivity of the Cells:" - nbTypesCell = mesh.getNumberOfTypes(MED_CELL) - print "" - if (nbTypesCell>0): - print "The Mesh has",nbTypesCell,"Type(s) of Cell" - types = mesh.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = mesh.getNumberOfElements(MED_CELL,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - - print "" - print "Show the Cell Reverse Nodal Connectivity:" - ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL) - ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL) - print "" - for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - - print "" - print "Show the Cell Descending Connectivity:" - mesh.calculateConnectivity(MED_DESCENDING,MED_CELL) - nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) - Connectivity = mesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) - ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL) - print "" - for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] - - print "" - - if (spaceDim == 3): - constituent = MED_FACE - elif (spaceDim == 2): - constituent = MED_EDGE - - print "Show the Face/Edge Nodal Connectivity:" - nbTypesConst = mesh.getNumberOfTypes(constituent) - print "" - if (nbTypesConst>0): - print "The Mesh has",nbTypesConst,"Type(s) of Constituent" - types = mesh.getTypes(constituent) - for k in range(nbTypesConst): - type = types[k] - nbElemType = mesh.getNumberOfElements(constituent,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh.getConnectivity(MED_NODAL,constituent,type) - nbNodesPerConst = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerConst:(j+1)*nbNodesPerConst] - - if (meshDim == 3): - 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_DESCENDING,constituent) - nbElemts = mesh.getNumberOfElements(constituent,MED_ALL_ELEMENTS) - Connectivity = mesh.getConnectivity(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) - nbGrp = mesh.getNumberOfGroups(entity) - if (entity == MED_NODE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)" - elif (entity == MED_CELL) : - if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)" - elif (entity == MED_FACE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)" - elif (entity == MED_EDGE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)" - - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - nbGrp = mesh.getNumberOfGroups(entity) - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - - if nbGrp > 0: - for j in range(nbGrp): - print "" - group = mesh.getGroup(entity,j+1) - groupName = group.getName() - groupDescription = group.getDescription() - groupEntity = group.getEntity() - groupBool = group.isOnAllElements() - print " -Name:",groupName - print " -Description:",groupDescription - print " -Entity:",groupEntity - nbOfFam = group.getNumberOfFamilies() - print " -Number Of Families:",nbOfFam - for k in range(nbOfFam): - print " * Family:",group.getFamily(k+1).getName() - print " -Entities list:" - if (groupBool): - print " -Is on all entities" - else: - nbOfTypes = group.getNumberOfTypes() - types = group.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = group.getNumberOfElements(type) - number = group.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - - - print "Saving in file the mesh under the med and vtk format" - print "Med V22 file = ",medV22FileName - print "vtk file = ",vtkFileName - - idMedV22 = mesh.addDriver(MED_DRIVER,medV22FileName,mesh.getName(),RDWR) - mesh.write(idMedV22) - - idVtk = mesh.addDriver(VTK_DRIVER,vtkFileName,mesh.getName()) - mesh.write(idVtk) - print "" - - print "Building of the support on all Cells of the mesh." - supportCell = mesh.getSupportOnAll( MED_CELL ) - print "" - barycenter = mesh.getBarycenter(supportCell) - print "Getting barycenter of all Cells of the mesh" - for j in range(nbElemts): - barycenterCell = barycenter.getRow(j+1) - print " * ",barycenterCell[:spaceDim] - print "" - - print "Saving in file the cell barycenter field under the med and vtk format" - print "Med V22 file = ",medV22FileName - print "vtk file = ",vtkFileName - - idMedV22 = barycenter.addDriver(MED_DRIVER,medV22FileName,barycenter.getName()) - barycenter.write(idMedV22) - - idVtk = barycenter.addDriver(VTK_DRIVER,vtkFileName,barycenter.getName()) - barycenter.write(idVtk) - print "" - - if (spaceDim == 3) and (meshDim == spaceDim) : - print "Getting volume of all Cells of the mesh:" - volume = mesh.getVolume(supportCell) - voltot = 0. - for j in range(nbElemts): - volumeCell = volume.getValueIJ(j+1,1) - print " * ",volumeCell - voltot = voltot + volumeCell - print "Volume of the mesh:",voltot - print "" - - print "Saving in file the cell volume field under the med and vtk format" - print "Med V22 file = ",medV22FileName - print "vtk file = ",vtkFileName - - idMedV22 = volume.addDriver(MED_DRIVER,medV22FileName,volume.getName()) - volume.write(idMedV22) - - idVtk = volume.addDriver(VTK_DRIVER,vtkFileName,volume.getName()) - volume.write(idVtk) - print "" - - print "Building of the support on all Faces of the mesh." - supportFace = mesh.getSupportOnAll(MED_FACE) - nbFace = mesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENTS) - print "" - print "Getting normal of each face of this support",nbFace - nbTypeFace = mesh.getNumberOfTypes(MED_FACE) - TypeFace = mesh.getTypes(MED_FACE) - print "nbTypeFace:",nbTypeFace,"----",TypeFace[:nbTypeFace] - normal = mesh.getNormal(supportFace) - area = mesh.getArea(supportFace) - for j in range(nbFace): - normalFace = normal.getRow(j+1) - areaFace = area.getRow(j+1) - value1 = normalFace[0] - value2 = normalFace[1] - value3 = normalFace[2] - norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) - print " * ",normalFace[:spaceDim],"norm:",norm," --> area ",areaFace[0] - print "" - - print "Saving in file the face normal field under the med format" - print "Med V22 file = ",medV22FileName - - idMedV22 = normal.addDriver(MED_DRIVER,medV22FileName,normal.getName()) - normal.write(idMedV22) - - 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) and (meshDim == spaceDim): - print "Getting area on all Cells of the mesh:" - area = mesh.getArea(supportCell) - areatot = 0. - for j in range(nbElemts): - areaCell = area.getValueIJ(j+1,1) - print " * ",areaCell - areatot = areatot + areaCell - print "Area of the mesh:",areatot - print "" - - print "Saving in file the cell area field under the med and vtk format" - print "Med V22 file = ",medV22FileName - print "vtk file = ",vtkFileName - - - idMedV22 = area.addDriver(MED_DRIVER,medV22FileName,area.getName()) - area.write(idMedV22) - - idVtk = area.addDriver(VTK_DRIVER,vtkFileName,area.getName()) - area.write(idVtk) - print "" - - print "Building of the support on all Edges of the mesh." - supportEdge = mesh.getSupportOnAll(MED_EDGE) - nbEdge = mesh.getNumberOfElements(MED_EDGE,MED_ALL_ELEMENTS) - print "" - print "Getting normal of each edge of this support",nbEdge - nbTypeEdge = mesh.getNumberOfTypes(MED_EDGE) - TypeEdge = mesh.getTypes(MED_EDGE) - print "nbTypeEdge:",nbTypeEdge,"----",TypeEdge[:nbTypeEdge] - normal = mesh.getNormal(supportEdge) - length = mesh.getLength(supportEdge) - for j in range(nbEdge): - normalEdge = normal.getRow(j+1) - lengthEdge = length.getRow(j+1) - value1 = normalEdge[0] - value2 = normalEdge[1] - norm = (value1*value1 + value2*value2)**(0.5) - print " * ",normalEdge[:spaceDim],"norm:",norm," --> length ",lengthEdge[0] - print "" - - print "Saving in file the face normal field under the med format" - print "Med V22 file = ",medV22FileName - - idMedV22 = normal.addDriver(MED_DRIVER,medV22FileName,normal.getName()) - normal.write(idMedV22) - - print "but no in vtk format because vtk does not offer the possibility to view a field on edges or faces" - - print "" - print "Building support on Elements of the boundary" - 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 - normalBound = mesh.getNormal(suppBound) - numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) - for j in range(nbElmBound): - valInd = numberSuppBound[j] - normalBoundJ = normalBound.getRow(valInd) - value1 = normalBoundJ[0] - value2 = normalBoundJ[1] - value3 = normalBoundJ[2] - norm = (value1*value1 + value2*value2 + value3*value3)**(0.5) - print " * ",normalBoundJ[:spaceDim],"norm:",norm - 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 - normalBound = mesh.getNormal(suppBound) - numberSuppBound = suppBound.getNumber(MED_ALL_ELEMENTS) - for j in range(nbElmBound): - valInd = numberSuppBound[j] - normalBoundJ = normalBound.getRow(valInd) - value1 = normalBoundJ[0] - value2 = normalBoundJ[1] - norm = (value1*value1 + value2*value2)**(0.5) - print " * ",normalBoundJ[:spaceDim],"norm:",norm - print "" - - if (extensionFile == "med"): - md = MEDFILEBROWSER(fileFull) - - nbMeshes = md.getNumberOfMeshes() - nbFields = md.getNumberOfFields() - - print "The med file", fileName, "contains", nbMeshes, "mesh(es) and", nbFields, "field(s)" - - if (nbMeshes>0): - print "Mesh(es) Name(s) is(are) " - - for imsh in range(nbMeshes): - mesh_name = md.getMeshName(imsh) - print " - ",mesh_name - print "" - if (nbFields>0): - print "Field(s) Name(s) is(are) " - - for ifld in range(nbFields): - field_name = md.getFieldName(ifld) - print " - ",field_name - - print "" - -# mesh_name = md.getMeshName(0) - mesh_name = meshNames[i] - if md.isStructuredMesh( mesh_name ): - mesh = GRID(MED_DRIVER,md.getFileName(),mesh_name) - else: - mesh = MESH(MED_DRIVER,md.getFileName(),mesh_name) - spaceDim = mesh.getSpaceDimension() - meshDim = mesh.getMeshDimension() - nbNodes = mesh.getNumberOfNodes() - print "The first mesh",mesh_name,"is a",spaceDim,"D mesh on a",meshDim,"D geometry and has",nbNodes,"Nodes" - - if (nbFields>0): - print "Field(s) Analysis " - for ifld in range(nbFields): - field_name = md.getFieldName(ifld) - dtits = md.getFieldIteration(field_name) - print "The",print_ord(ifld),"field is",field_name,"with",len(dtits),"iteration(s)" - for dtitfield in dtits: - dt = dtitfield.getdt() - it = dtitfield.getit() - type = md.getFieldType(field_name) - print " * Iteration:",dt,"Order number:",it,"Type:",type - if type == MED_INT32: - fieldint = FIELDINT(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh) - name = fieldint.getName() - desc = fieldint.getDescription() - nbOfComp = fieldint.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldint.getIterationNumber() - orderNb = fieldint.getOrderNumber() - time = fieldint.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - print " Norme 2 : ", fieldint.norm2() - print " Norme Max : ", fieldint.normMax() - - if fieldint.getSupport().getEntity()!=MED_NODE: - fieldint_vol=fieldint.getSupport().getMesh().getVolume(fieldint.getSupport()) - print " Norme L1 : ", fieldint.normL1() - print " Norme L2 : ", fieldint.normL2() - print " Norme L2(vol) : ", fieldint.normL2(fieldint_vol) - - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldint.getComponentName(kp1) - compDesc = fieldint.getComponentDescription(kp1) - compUnit = fieldint.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - if fieldint.getSupport().getEntity()!=MED_NODE: - print " Norme L1 : ", fieldint.normL1(kp1) - print " Norme L2 : ", fieldint.normL2(kp1) - print " Norme L2(vol) : ", fieldint.normL2(kp1,fieldint_vol) - - support = fieldint.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldint.getRow(k+1) - print " *",valueI[:nbOfComp] - fieldint2 = FIELDINT(fieldint) - print "" - fieldintadd = fieldint + fieldint2 - print "Test of the addition of two integer fields with creation a new one" - print "" - name = fieldintadd.getName() - desc = fieldintadd.getDescription() - nbOfComp = fieldintadd.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintadd.getIterationNumber() - orderNb = fieldintadd.getOrderNumber() - time = fieldintadd.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintadd.getComponentName(kp1) - compDesc = fieldintadd.getComponentDescription(kp1) - compUnit = fieldintadd.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintadd.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintadd.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fieldintsub = fieldint - fieldint2 - print "Test of the substraction of two integer fields with creation a new one" - print "" - name = fieldintsub.getName() - desc = fieldintsub.getDescription() - nbOfComp = fieldintsub.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintsub.getIterationNumber() - orderNb = fieldintsub.getOrderNumber() - time = fieldintsub.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintsub.getComponentName(kp1) - compDesc = fieldintsub.getComponentDescription(kp1) - compUnit = fieldintsub.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintsub.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintsub.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fieldintmul = fieldint * fieldint2 - print "Test of the multiplication of two integer fields with creation a new one" - print "" - name = fieldintmul.getName() - desc = fieldintmul.getDescription() - nbOfComp = fieldintmul.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintmul.getIterationNumber() - orderNb = fieldintmul.getOrderNumber() - time = fieldintmul.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintmul.getComponentName(kp1) - compDesc = fieldintmul.getComponentDescription(kp1) - compUnit = fieldintmul.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintmul.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintmul.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - try: - fieldintdiv = fieldint / fieldint2 - print "Test of the division of two integer fields with creation a new one" - print "" - name = fieldintdiv.getName() - desc = fieldintdiv.getDescription() - nbOfComp = fieldintdiv.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldintdiv.getIterationNumber() - orderNb = fieldintdiv.getOrderNumber() - time = fieldintdiv.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fieldintdiv.getComponentName(kp1) - compDesc = fieldintdiv.getComponentDescription(kp1) - compUnit = fieldintdiv.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fieldintdiv.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldintdiv.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - print "TESTS OPERATIONS SUR FIELDINT : " - except: - print "testMedMemGeneral fieldintdiv = fieldint / fieldint2 catch/except error" - fieldintadd = fieldint+fieldint2 - fieldintsub = fieldint-fieldint2 - fieldintmul = fieldint*fieldint2 - try: - fieldintdiv = fieldint/fieldint2 - except: - fieldintdiv = None - print "testMedMemGeneral fieldintdiv = fieldint/fieldint2 catch/except error" - fieldintasso = fieldint+fieldint*fieldint - fieldintSP=createFieldIntScalarProduct(fieldint, fieldint2) - - print " f1 : ",fieldint.getValue() - print " f2 : ",fieldint2.getValue() - print "--------------------------------------------------------------------------------------------------------------" - print " + : ",fieldintadd.getValue() - print " - : ",fieldintsub.getValue() - print " * : ",fieldintmul.getValue() - if fieldintdiv == None : - print "testMedMemGeneral / : None" - else: - print " / : ",fieldintdiv.getValue() - fieldint+=fieldint2; - print " += : ",fieldint.getValue() - fieldint-=fieldint2; - print " -= : ",fieldint.getValue() - fieldint*=fieldint2; - print " *= : ",fieldint.getValue() - try: - fieldint/=fieldint2; - print " /= : ",fieldint.getValue() - except : - fieldint = None - print " /= : Catch/Except : None" - print "f1+f2*f2: ",fieldintasso.getValue() - if fieldint != None : - fieldint.applyLin(4,1); - print " 4f1+1 : ",fieldint.getValue() - print " f1.f2 : ",fieldintSP.getValue() - fieldint2.applyPyFunc(add_one) - print " CB:f2+1: ",fieldint2.getValue() - elif type == MED_REEL64: - fielddouble = FIELDDOUBLE(MED_DRIVER,md.getFileName(),field_name,dt,it,mesh) - name = fielddouble.getName() - desc = fielddouble.getDescription() - nbOfComp = fielddouble.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddouble.getIterationNumber() - orderNb = fielddouble.getOrderNumber() - time = fielddouble.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - print " Norme 2 : ", fielddouble.norm2() - print " Norme Max : ", fielddouble.normMax() - fielddouble.getSupport().update() - fieldEntity = fielddouble.getSupport().getEntity() - print "try sobolev",fieldEntity - if fieldEntity !=MED_NODE: - if (fieldEntity == MED_CELL): - if (spaceDim == 3): - fielddouble_vol=fielddouble.getSupport().getMesh().getVolume(fielddouble.getSupport()) - elif (spaceDim == 2): - fielddouble_vol=fielddouble.getSupport().getMesh().getArea(fielddouble.getSupport()) - elif (fieldEntity == MED_FACE): - fielddouble_vol=fielddouble.getSupport().getMesh().getArea(fielddouble.getSupport()) - elif (fieldEntity == MED_EDGE): - fielddouble_vol=fielddouble.getSupport().getMesh().getLength(fielddouble.getSupport()) - print "Norme L1 : ", fielddouble.normL1() - print "Norme L2 : ", fielddouble.normL2() - print "Norme L2(vol) : ", fielddouble.normL2(fielddouble_vol) - - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddouble.getComponentName(kp1) - compDesc = fielddouble.getComponentDescription(kp1) - compUnit = fielddouble.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - if fielddouble.getSupport().getEntity()!=MED_NODE: - print " Norme L1 : ", fielddouble.normL1(kp1) - print " Norme L2 : ", fielddouble.normL2(kp1) - print " Norme L2(vol) : ", fielddouble.normL2(kp1, fielddouble_vol) - - support = fielddouble.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddouble.getRow(k+1) - print " *",valueI[:nbOfComp] - fielddouble2 = FIELDDOUBLE(fielddouble) - print "" - fielddoubleadd = fielddouble + fielddouble2 - print "Test of the addition of two double fields with creation a new one" - print "" - name = fielddoubleadd.getName() - desc = fielddoubleadd.getDescription() - nbOfComp = fielddoubleadd.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoubleadd.getIterationNumber() - orderNb = fielddoubleadd.getOrderNumber() - time = fielddoubleadd.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoubleadd.getComponentName(kp1) - compDesc = fielddoubleadd.getComponentDescription(kp1) - compUnit = fielddoubleadd.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoubleadd.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoubleadd.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fielddoublesub = fielddouble - fielddouble2 - print "Test of the substraction of two double fields with creation a new one" - print "" - name = fielddoublesub.getName() - desc = fielddoublesub.getDescription() - nbOfComp = fielddoublesub.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoublesub.getIterationNumber() - orderNb = fielddoublesub.getOrderNumber() - time = fielddoublesub.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoublesub.getComponentName(kp1) - compDesc = fielddoublesub.getComponentDescription(kp1) - compUnit = fielddoublesub.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoublesub.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoublesub.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - fielddoublemul = fielddouble * fielddouble2 - print "Test of the multiplication of two double fields with creation a new one" - print "" - name = fielddoublemul.getName() - desc = fielddoublemul.getDescription() - nbOfComp = fielddoublemul.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoublemul.getIterationNumber() - orderNb = fielddoublemul.getOrderNumber() - time = fielddoublemul.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoublemul.getComponentName(kp1) - compDesc = fielddoublemul.getComponentDescription(kp1) - compUnit = fielddoublemul.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoublemul.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoublemul.getRow(k+1) - print " *",valueI[:nbOfComp] - print "" - try: - fielddoublediv = fielddouble / fielddouble2 - print "Test of the division of two double fields with creation a new one" - print "" - name = fielddoublediv.getName() - desc = fielddoublediv.getDescription() - nbOfComp = fielddoublediv.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fielddoublediv.getIterationNumber() - orderNb = fielddoublediv.getOrderNumber() - time = fielddoublediv.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - for k in range(nbOfComp): - kp1 = k+1 - compName = fielddoublediv.getComponentName(kp1) - compDesc = fielddoublediv.getComponentDescription(kp1) - compUnit = fielddoublediv.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",compName - print " Description:",compDesc - print " Unit:",compUnit - - support = fielddoublediv.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fielddoublediv.getRow(k+1) - print " *",valueI[:nbOfComp] - except: - print "testMedMemGeneral fielddoublediv = fielddouble / fielddouble2 catch/except error" - - print "" - print "TESTS OPERATIONS SUR FIELDDOUBLE : " - fielddoublesub = fielddouble-fielddouble2 - fielddoublemul = fielddouble*fielddouble2 - try: - fielddoublediv = fielddouble/fielddouble2 - except: - print "testMedMemGeneral /= : catch/except error" - fielddoublediv = None - fielddoubleasso = fielddouble+fielddouble2*fielddouble2 - fielddoubleSP=createFieldDoubleScalarProduct(fielddouble, fielddouble2) - print " f1 : ",fielddouble.getValue() - print " f2 : ",fielddouble2.getValue() - print "--------------------------------------------------------------------------------------------------------------" - print " + : ",fielddoubleadd.getValue() - print " - : ",fielddoublesub.getValue() - print " * : ",fielddoublemul.getValue() - if fielddoublediv != None: - print " / : ",fielddoublediv.getValue() - pass - fielddouble+=fielddouble2; - print " += : ",fielddouble.getValue() - fielddouble-=fielddouble2; - print " -= : ",fielddouble.getValue() - fielddouble*=fielddouble2; - print " *= : ",fielddouble.getValue() - try: - fielddouble/=fielddouble2; - print " /= : ",fielddouble.getValue() - except: - print "testMedMemGeneral /= : " - print "f1+f2*f2: ",fielddoubleasso.getValue() - fielddouble.applyLin(4,1); - print " 4f1+1 : ",fielddouble.getValue() - print " f1.f2 : ",fielddoubleSP.getValue() - fielddouble2.applyPyFunc(add_one) - print " CB:f2+1: ",fielddouble2.getValue() - else: - print " !!!! Bad type of Field !!!!" - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/testWriteAndFam.py b/src/MEDMEM_SWIG/testWriteAndFam.py deleted file mode 100755 index b11f0e9a1..000000000 --- a/src/MEDMEM_SWIG/testWriteAndFam.py +++ /dev/null @@ -1,159 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -# This Python script is testing the writing in Med format V2.1 V2.2 -# You can check if the analysis of the families is OK. -################################################################################### -# -from libMEDMEM_Swig import * -import string -import os -# -#befor running this script, please be sure about the path the files -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFiles = [] -#medFiles.append("geomMesh21.med") -medFiles.append("geomMesh22.med") -nbOfFiles = len(medFiles) - -for i in range(nbOfFiles): - medFile = medFiles[i] - medFile = os.path.join( filePath, medFile ) - medFiles[i] = medFile - pass - -meshName = "GeomMesh" - -for i in range(nbOfFiles): - medFile = medFiles[i] - - rootFile = string.split(medFile,".")[0] - medFileOut21 = rootFile + "Out21.med" - medFileOut22 = rootFile + "Out22.med" - - print "Mounting in memory of the mesh ",meshName," from the file ",medFile - mesh = MESH(MED_DRIVER,medFile,meshName) - - print "" - print "Families analysis of the mesh ",meshName," from the file ",medFile - print "" - - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - if (entity == MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - pass - elif (entity == MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - pass - elif (entity == MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - pass - elif (entity == MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - pass - - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyBool = family.isOnAllElements() - if (familyBool): - print " -this famyly named ",familyName," is on all entities" - pass - else: - familyNumber = family.getNumber(MED_ALL_ELEMENTS) - print " -this famyly named ",familyName," has ",len(familyNumber)," entities" - pass - pass - pass - pass - - print "" - print " adding a Med file V2.2 format driver to the mesh with the file ",medFileOut22 - idMedV22 = mesh.addDriver(MED_DRIVER,medFileOut22,mesh.getName()) - - print "" - print " writing the mesh in Med file V2.2 format" - mesh.write(idMedV22) - print "" - pass - -medFiles2 = [] - -for i in range(nbOfFiles): - medFile = medFiles[i] - rootFile = string.split(medFile,".")[0] - medFileOut22 = rootFile + "Out22.med" - - medFiles2.append(medFileOut22) - pass - -nbOfFiles = len(medFiles2) - -for i in range(nbOfFiles): - medFile = medFiles2[i] - mesh = MESH(MED_DRIVER,medFile,meshName) - - print "Families analysis of the mesh ",meshName," from the file ",medFile - print "" - for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - if (entity == MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - pass - elif (entity == MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - pass - elif (entity == MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - pass - elif (entity == MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - pass - - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyBool = family.isOnAllElements() - if (familyBool): - print " -this famyly named ",familyName," is on all entities" - pass - else: - familyNumber = family.getNumber(MED_ALL_ELEMENTS) - print " -this famyly named ",familyName," has ",len(familyNumber)," entities" - pass - pass - pass - pass - pass - -print "" -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/test_gibi.py b/src/MEDMEM_SWIG/test_gibi.py deleted file mode 100644 index d22cbb217..000000000 --- a/src/MEDMEM_SWIG/test_gibi.py +++ /dev/null @@ -1,389 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -################################################################################### -# -from libMEDMEM_Swig import * -from random import * -import string -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") -gibiFile = "elle_2D_QT_2x2.sauve" -mesh1Name = string.split(gibiFile,".")[0]+"_fromGibiDriver" - -gibiFile = os.path.join(filePath, gibiFile) -medFile = string.split(gibiFile,".")[0]+"_fromGibiDriver.med" -vtkFile = string.split(gibiFile,".")[0]+"_fromGibiDriver.vtk" -mesh2Name = mesh1Name - -mesh = MESH() -meshDriver = GIBI_MESH_RDONLY_DRIVER(gibiFile,mesh) - -meshDriver.open() -meshDriver.read() -meshDriver.close() - -#print mesh - -meshName = mesh.getName() -spaceDim = mesh.getSpaceDimension() -meshDim = mesh.getMeshDimension() -print "The mesh ",meshName," is a ",spaceDim,"D mesh on a ",meshDim,"D geometry" -print "and is mounted via the GIBI driver" -nbNodes = mesh.getNumberOfNodes() -print "The mesh ",meshName," has",nbNodes,"Nodes" -coordSyst = mesh.getCoordinatesSystem() -print "The coordinates system is",coordSyst -print "The Coordinates :" -coordNames = [] -coordUnits = [] -for isd in range(spaceDim): - coordNames.append(mesh.getCoordinateName(isd)) - coordUnits.append(mesh.getCoordinateUnit(isd)) - -print "names:", coordNames -print "units", coordUnits -print "values:" -coordinates = mesh.getCoordinates(MED_FULL_INTERLACE) -for k in range(nbNodes): - kp1 = k+1 - coords = [] - for isd in range(spaceDim): - isdp1 = isd+1 - coords.append(mesh.getCoordinate(kp1,isdp1)) - - print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)] - -print "" -print "Show the Nodal Connectivity:" -nbTypesCell = mesh.getNumberOfTypes(MED_CELL) -print "" -if (nbTypesCell>0): - print "The Mesh has",nbTypesCell,"Type(s) of Cell" - types = mesh.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = mesh.getNumberOfElements(MED_CELL,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - -print "" -print "Show the Reverse Nodal Connectivity:" -ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL) -ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL) -print "" -for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - -print "" -print "Show the Descending Connectivity:" -mesh.calculateConnectivity(MED_DESCENDING,MED_CELL) -nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) -Connectivity = mesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) -ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL) -print "" -for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] - -print "" -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - nbGrp = mesh.getNumberOfGroups(entity) - if (entity == MED_NODE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)" - elif (entity == MED_CELL) : - if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)" - elif (entity == MED_FACE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)" - elif (entity == MED_EDGE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)" - -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - nbGrp = mesh.getNumberOfGroups(entity) - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - - if nbGrp > 0: - for j in range(nbGrp): - print "" - group = mesh.getGroup(entity,j+1) - groupName = group.getName() - groupDescription = group.getDescription() - groupEntity = group.getEntity() - groupBool = group.isOnAllElements() - print " -Name:",groupName - print " -Description:",groupDescription - print " -Entity:",groupEntity - nbOfFam = group.getNumberOfFamilies() - print " -Number Of Families:",nbOfFam - for k in range(nbOfFam): - print " * Family:",group.getFamily(k+1).getName() - print " -Entities list:" - if (groupBool): - print " -Is on all entities" - else: - nbOfTypes = group.getNumberOfTypes() - types = group.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = group.getNumberOfElements(type) - number = group.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - -print "Printing of this mesh in med and vtk format with the name ", mesh.getName() - -idMed = mesh.addDriver(MED_DRIVER,medFile,mesh1Name) -mesh.write(idMed) - -idVtk = mesh.addDriver(VTK_DRIVER,vtkFile,mesh2Name) -mesh.write(idVtk) -print "" -print "Mounting this mesh using the MED driver" -print "" - -mesh1 = MESH() -mesh1Driver = MED_MESH_RDONLY_DRIVER(medFile,mesh1) - -mesh1Driver.setMeshName(mesh1Name) - -mesh1Driver.open() -mesh1Driver.read() -mesh1Driver.close() - -#print mesh - -mesh_name = mesh1Driver.getMeshName() -meshName = mesh1.getName() -spaceDim = mesh1.getSpaceDimension() -meshDim = mesh1.getMeshDimension() -print "The mesh ",meshName," is a ",spaceDim,"D mesh on a ",meshDim,"D geometry" -nbNodes = mesh1.getNumberOfNodes() -print "The mesh has",nbNodes,"Nodes" -coordSyst = mesh1.getCoordinatesSystem() -print "The coordinates system is",coordSyst -print "The Coordinates :" -coordNames = [] -coordUnits = [] -for isd in range(spaceDim): - coordNames.append(mesh1.getCoordinateName(isd)) - coordUnits.append(mesh1.getCoordinateUnit(isd)) - -print "names:", coordNames -print "units", coordUnits -print "values:" -coordinates = mesh1.getCoordinates(MED_FULL_INTERLACE) -for k in range(nbNodes): - kp1 = k+1 - coords = [] - for isd in range(spaceDim): - isdp1 = isd+1 - coords.append(mesh1.getCoordinate(kp1,isdp1)) - - print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)] - -print "" -print "Show the Nodal Connectivity:" -nbTypesCell = mesh1.getNumberOfTypes(MED_CELL) -print "" -if (nbTypesCell>0): - print "The Mesh has",nbTypesCell,"Type(s) of Cell" - types = mesh1.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = mesh1.getNumberOfElements(MED_CELL,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh1.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - -print "" -print "Show the Reverse Nodal Connectivity:" -ReverseConnectivity = mesh1.getReverseConnectivity(MED_NODAL) -ReverseConnectivityIndex = mesh1.getReverseConnectivityIndex(MED_NODAL) -print "" -for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - -print "" -print "Show the Descending Connectivity:" -mesh1.calculateConnectivity(MED_DESCENDING,MED_CELL) -nbElemts = mesh1.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) -Connectivity = mesh1.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) -ConnectivityIndex = mesh1.getConnectivityIndex(MED_DESCENDING,MED_CELL) -print "" -for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] - -print "" -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh1.getNumberOfFamilies(entity) - nbGrp = mesh1.getNumberOfGroups(entity) - if (entity == MED_NODE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)" - elif (entity == MED_CELL) : - if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)" - elif (entity == MED_FACE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)" - elif (entity == MED_EDGE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)" - -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh1.getNumberOfFamilies(entity) - nbGrp = mesh1.getNumberOfGroups(entity) - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh1.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - - if nbGrp > 0: - for j in range(nbGrp): - print "" - group = mesh1.getGroup(entity,j+1) - groupName = group.getName() - groupDescription = group.getDescription() - groupEntity = group.getEntity() - groupBool = group.isOnAllElements() - print " -Name:",groupName - print " -Description:",groupDescription - print " -Entity:",groupEntity - nbOfFam = group.getNumberOfFamilies() - print " -Number Of Families:",nbOfFam - for k in range(nbOfFam): - print " * Family:",group.getFamily(k+1).getName() - print " -Entities list:" - if (groupBool): - print " -Is on all entities" - else: - nbOfTypes = group.getNumberOfTypes() - types = group.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = group.getNumberOfElements(type) - number = group.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/test_porflow.py b/src/MEDMEM_SWIG/test_porflow.py deleted file mode 100644 index b2828bf8f..000000000 --- a/src/MEDMEM_SWIG/test_porflow.py +++ /dev/null @@ -1,389 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -################################################################################### -################################################################################### -# -from libMEDMEM_Swig import * -from random import * -import string -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") -porflowFile = "boitenew.inp" -mesh1Name = string.split(porflowFile,".")[0]+"_fromPorflowDriver" - -porflowFile = os.path.join(filePath, porflowFile) -medFile = string.split(porflowFile,".")[0]+"_fromPorflowDriver.med" -vtkFile = string.split(porflowFile,".")[0]+"_fromPorflowDriver.vtk" -mesh2Name = mesh1Name - -mesh = MESH() -meshDriver = PORFLOW_MESH_RDONLY_DRIVER(porflowFile,mesh) - -meshDriver.open() -meshDriver.read() -meshDriver.close() - -#print mesh - -meshName = mesh.getName() -spaceDim = mesh.getSpaceDimension() -meshDim = mesh.getMeshDimension() -print "The mesh ",meshName," is a ",spaceDim,"D mesh on a ",meshDim,"D geometry" -print "and is mounted via the PORFLOW driver" -nbNodes = mesh.getNumberOfNodes() -print "The mesh ",meshName," has",nbNodes,"Nodes" -coordSyst = mesh.getCoordinatesSystem() -print "The coordinates system is",coordSyst -print "The Coordinates :" -coordNames = [] -coordUnits = [] -for isd in range(spaceDim): - coordNames.append(mesh.getCoordinateName(isd)) - coordUnits.append(mesh.getCoordinateUnit(isd)) - -print "names:", coordNames -print "units", coordUnits -print "values:" -coordinates = mesh.getCoordinates(MED_FULL_INTERLACE) -for k in range(nbNodes): - kp1 = k+1 - coords = [] - for isd in range(spaceDim): - isdp1 = isd+1 - coords.append(mesh.getCoordinate(kp1,isdp1)) - - print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)] - -print "" -print "Show the Nodal Connectivity:" -nbTypesCell = mesh.getNumberOfTypes(MED_CELL) -print "" -if (nbTypesCell>0): - print "The Mesh has",nbTypesCell,"Type(s) of Cell" - types = mesh.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = mesh.getNumberOfElements(MED_CELL,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - -print "" -print "Show the Reverse Nodal Connectivity:" -ReverseConnectivity = mesh.getReverseConnectivity(MED_NODAL) -ReverseConnectivityIndex = mesh.getReverseConnectivityIndex(MED_NODAL) -print "" -for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - -print "" -print "Show the Descending Connectivity:" -mesh.calculateConnectivity(MED_DESCENDING,MED_CELL) -nbElemts = mesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) -Connectivity = mesh.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) -ConnectivityIndex = mesh.getConnectivityIndex(MED_DESCENDING,MED_CELL) -print "" -for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] - -print "" -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - nbGrp = mesh.getNumberOfGroups(entity) - if (entity == MED_NODE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)" - elif (entity == MED_CELL) : - if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)" - elif (entity == MED_FACE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)" - elif (entity == MED_EDGE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)" - -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh.getNumberOfFamilies(entity) - nbGrp = mesh.getNumberOfGroups(entity) - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - - if nbGrp > 0: - for j in range(nbGrp): - print "" - group = mesh.getGroup(entity,j+1) - groupName = group.getName() - groupDescription = group.getDescription() - groupEntity = group.getEntity() - groupBool = group.isOnAllElements() - print " -Name:",groupName - print " -Description:",groupDescription - print " -Entity:",groupEntity - nbOfFam = group.getNumberOfFamilies() - print " -Number Of Families:",nbOfFam - for k in range(nbOfFam): - print " * Family:",group.getFamily(k+1).getName() - print " -Entities list:" - if (groupBool): - print " -Is on all entities" - else: - nbOfTypes = group.getNumberOfTypes() - types = group.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = group.getNumberOfElements(type) - number = group.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - -print "Printing of this mesh in med and vtk format with the name ", mesh.getName() - -idMed = mesh.addDriver(MED_DRIVER,medFile,mesh1Name) -mesh.write(idMed) - -idVtk = mesh.addDriver(VTK_DRIVER,vtkFile,mesh2Name) -mesh.write(idVtk) -print "" -print "Mounting this mesh using the MED driver" -print "" - -mesh1 = MESH() -mesh1Driver = MED_MESH_RDONLY_DRIVER(medFile,mesh1) - -mesh1Driver.setMeshName(mesh1Name) - -mesh1Driver.open() -mesh1Driver.read() -mesh1Driver.close() - -#print mesh - -mesh_name = mesh1Driver.getMeshName() -meshName = mesh1.getName() -spaceDim = mesh1.getSpaceDimension() -meshDim = mesh1.getMeshDimension() -print "The mesh ",meshName," is a ",spaceDim,"D mesh on a ",meshDim,"D geometry" -nbNodes = mesh1.getNumberOfNodes() -print "The mesh has",nbNodes,"Nodes" -coordSyst = mesh1.getCoordinatesSystem() -print "The coordinates system is",coordSyst -print "The Coordinates :" -coordNames = [] -coordUnits = [] -for isd in range(spaceDim): - coordNames.append(mesh1.getCoordinateName(isd)) - coordUnits.append(mesh1.getCoordinateUnit(isd)) - -print "names:", coordNames -print "units", coordUnits -print "values:" -coordinates = mesh1.getCoordinates(MED_FULL_INTERLACE) -for k in range(nbNodes): - kp1 = k+1 - coords = [] - for isd in range(spaceDim): - isdp1 = isd+1 - coords.append(mesh1.getCoordinate(kp1,isdp1)) - - print coords," ---- ", coordinates[k*spaceDim:((k+1)*spaceDim)] - -print "" -print "Show the Nodal Connectivity:" -nbTypesCell = mesh1.getNumberOfTypes(MED_CELL) -print "" -if (nbTypesCell>0): - print "The Mesh has",nbTypesCell,"Type(s) of Cell" - types = mesh1.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = mesh1.getNumberOfElements(MED_CELL,type) - print "For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = mesh1.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print "Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - -print "" -print "Show the Reverse Nodal Connectivity:" -ReverseConnectivity = mesh1.getReverseConnectivity(MED_NODAL) -ReverseConnectivityIndex = mesh1.getReverseConnectivityIndex(MED_NODAL) -print "" -for j in range(nbNodes): - begin = ReverseConnectivityIndex[j]-1 - end = ReverseConnectivityIndex[j+1]-1 - print "Node",(j+1),"-->",ReverseConnectivity[begin:end] - -print "" -print "Show the Descending Connectivity:" -mesh1.calculateConnectivity(MED_DESCENDING,MED_CELL) -nbElemts = mesh1.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS) -Connectivity = mesh1.getConnectivity(MED_DESCENDING,MED_CELL,MED_ALL_ELEMENTS) -ConnectivityIndex = mesh1.getConnectivityIndex(MED_DESCENDING,MED_CELL) -print "" -for j in range(nbElemts): - begin = ConnectivityIndex[j]-1 - end = ConnectivityIndex[j+1]-1 - print "Element",(j+1),"-->",Connectivity[begin:end] - -print "" -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh1.getNumberOfFamilies(entity) - nbGrp = mesh1.getNumberOfGroups(entity) - if (entity == MED_NODE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Node Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Node Group(s)" - elif (entity == MED_CELL) : - if (nbFam > 0) : print "This mesh has",nbFam,"Cell Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Cell Group(s)" - elif (entity == MED_FACE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Face Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Face Group(s)" - elif (entity == MED_EDGE) : - if (nbFam > 0) : print "This mesh has",nbFam,"Edge Family(ies)" - if (nbGrp > 0) : print "This mesh has",nbGrp,"Edge Group(s)" - -for entity in [MED_NODE,MED_CELL,MED_FACE,MED_EDGE]: - nbFam = mesh1.getNumberOfFamilies(entity) - nbGrp = mesh1.getNumberOfGroups(entity) - if nbFam > 0: - for j in range(nbFam): - print "" - family = mesh1.getFamily(entity,j+1) - familyName = family.getName() - familyDescription = family.getDescription() - familyEntity = family.getEntity() - familyBool = family.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = family.getIdentifier() - nbOfAtt = family.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = family.getAttributesIdentifiers() - attributesvals = family.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",family.getAttributeDescription(k+1) - nbOfGrp = family.getNumberOfGroups() - print " -Number Of Groups:",nbOfGrp - for k in range(nbOfGrp): - print " * Group:",family.getGroupName(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - nbOfTypes = family.getNumberOfTypes() - types = family.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = family.getNumberOfElements(type) - number = family.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - - if nbGrp > 0: - for j in range(nbGrp): - print "" - group = mesh1.getGroup(entity,j+1) - groupName = group.getName() - groupDescription = group.getDescription() - groupEntity = group.getEntity() - groupBool = group.isOnAllElements() - print " -Name:",groupName - print " -Description:",groupDescription - print " -Entity:",groupEntity - nbOfFam = group.getNumberOfFamilies() - print " -Number Of Families:",nbOfFam - for k in range(nbOfFam): - print " * Family:",group.getFamily(k+1).getName() - print " -Entities list:" - if (groupBool): - print " -Is on all entities" - else: - nbOfTypes = group.getNumberOfTypes() - types = group.getTypes() - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = group.getNumberOfElements(type) - number = group.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - print "" - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MEDMEM_SWIG/test_profil_MedFieldDriver.py b/src/MEDMEM_SWIG/test_profil_MedFieldDriver.py deleted file mode 100644 index 9b55aaa68..000000000 --- a/src/MEDMEM_SWIG/test_profil_MedFieldDriver.py +++ /dev/null @@ -1,114 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -############################################################################ -# this Python script is testing the profil functionality using the FIELD -# constructor via a MED driver. -############################################################################ -# -from libMEDMEM_Swig import * - -# users inputs -#test 1 --- zzzz121b_without_tr6.med RESUZERODEPL____________________ 1 1 -#test 2 --- zzzz121b_without_tr6.med RESUZEROERRE_ELGA_NORE__________ 1 1 -#test 3 --- maill.00.med Indicateur_d_erreur_00 2 2 - -medFile = "zzzz121b_without_tr6.med" -#medFile = "maill.00.med" - -fieldName = "RESUZERODEPL____________________" -#fieldName = "RESUZEROERRE_ELGA_NORE__________" -#fieldName = "Indicateur_d_erreur_00" - -# default value, may be changed according to what field is stored in medFile -##iterationNumber = -1 -##orderNumber = -1 -iterationNumber = 1 -orderNumber = 1 -#iterationNumber = 2 -#orderNumber = 2 - -import os -# -#befor running this script, please be sure about the path the file fileName -# -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -medFile = os.path.join(filePath, medFile) - -def analyseField(field): - fieldName = field.getName() - fieldType = field.getValueType() - fieldDesc = field.getDescription() - fieldIterationNumber = field.getIterationNumber() - fieldOrderNumber = field.getOrderNumber() - fieldTime = field.getTime() - fieldNbOfComp = field.getNumberOfComponents() - print "The field ",fieldName," with the description ",fieldDesc," typed ",fieldType - print "Iteration number ",fieldIterationNumber," OrderNumber ",fieldOrderNumber," Time ",fieldTime - print "It has ",fieldNbOfComp,"components" - for k in range(fieldNbOfComp): - kp1 = k+1 - fieldCompName = field.getComponentName(kp1) - fieldCompDesc = field.getComponentDescription(kp1) - fieldCompUnit = field.getMEDComponentUnit(kp1) - print " * Component:",kp1 - print " Name:",fieldCompName - print " Description:",fieldCompDesc - print " Unit:",fieldCompUnit - pass - fieldSupport = field.getSupport() - fieldMeshName = fieldSupport.getMeshName() - fieldSupportOnAll = fieldSupport.isOnAllElements() - fieldNbEntities = fieldSupport.getNumberOfElements(MED_ALL_ELEMENTS) - fieldEntityType = fieldSupport.getEntity() - fieldSupportNumber = range(1,fieldNbEntities+1) - if (not fieldSupportOnAll): - fieldSupportNumber = fieldSupport.getNumber(MED_ALL_ELEMENTS) - pass - print " fieldSupportNumber ", fieldSupportNumber - fieldInterlacingType = field.getInterlacingType() - print "It relies on the mesh named ",fieldMeshName - print "its interlacing type ",fieldInterlacingType - print "and it is on ",fieldNbEntities," entities of the type ",fieldEntityType - if (fieldInterlacingType == MED_FULL_INTERLACE): - for i in range(fieldNbEntities): - value = field.getRow(fieldSupportNumber[i]) - print " * ",fieldSupportNumber[i]," --- ",value - pass - pass - elif (fieldInterlacingType == MED_FULL_INTERLACE): - for i in range(fieldNbOfComp): - value = field.getColumn(fieldSupportNumber[i]) - print " * ",fieldSupportNumber[i]," --- ",value - pass - pass - pass - -field = FIELDDOUBLE(MED_DRIVER, medFile, fieldName, - iterationNumber, orderNumber) - -analyseField(field) - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MED_SWIG/CMakeLists.txt b/src/MED_SWIG/CMakeLists.txt deleted file mode 100644 index 57da0595b..000000000 --- a/src/MED_SWIG/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INSTALL(FILES MED_shared_modules.py DESTINATION ${MED_sharedpkgpython_PYTHON}) diff --git a/src/MED_SWIG/MED_shared_modules.py b/src/MED_SWIG/MED_shared_modules.py deleted file mode 100644 index 68c848494..000000000 --- a/src/MED_SWIG/MED_shared_modules.py +++ /dev/null @@ -1,47 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -""" - -""" - -# force GEOM importation at interpretor initialization -# see salome_shared_modules.py -# (avoids incomplete import at run time) - -from launchConfigureParser import verbose - -if verbose(): - print "============== import MED_idl =======================" - print "============== import MED_Gen_idl =======================" - -import MED_idl -import MED_Gen_idl - -# this function is required - -def init_shared_modules(): - """ - This function initializes shared modules that need to be - """ - pass diff --git a/src/MED_SWIG/Makefile.am b/src/MED_SWIG/Makefile.am deleted file mode 100644 index cee7ece56..000000000 --- a/src/MED_SWIG/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MED_SWIG : binding of C++ implementaion with Python -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -dist_sharedpkgpython_DATA= MED_shared_modules.py diff --git a/src/Makefile.am b/src/Makefile.am index 510a0a303..2a54652e6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -59,16 +59,12 @@ endif if !MED_ENABLE_MICROMED - BASE_SUBDIRS = MEDWrapper MEDMEM MEDCoupling_Swig MEDMEM_SWIG MEDMEMBinTest + BASE_SUBDIRS = MEDWrapper MEDCoupling_Swig if MPI_IS_OK PARAMEDMEM_SUBDIRS += ParaMEDMEM_Swig endif -if CPPUNIT_IS_OK - BASE_SUBDIRS += MEDMEMCppTest -endif - if MED_ENABLE_SPLITTER SPLITTER_SUBDIRS = MEDSPLITTER MEDSPLITTER_Swig MEDPartitioner endif @@ -78,7 +74,7 @@ if MED_ENABLE_RENUMBER endif if MED_ENABLE_KERNEL - KERNEL_SUBDIRS = MEDCouplingCorba MEDCouplingCorba_Swig MEDMEM_I MED MedCorba_Swig MED_SWIG MedClient + KERNEL_SUBDIRS = MEDCouplingCorba MEDCouplingCorba_Swig if MPI_IS_OK KERNEL_SUBDIRS += ParaMEDCouplingCorba ParaMEDMEMComponent @@ -101,8 +97,8 @@ SUBDIRS = $(COMMON_SUBDIRS) $(PARAMEDMEM_SUBDIRS) $(BASE_SUBDIRS) $(INTERPTEST_S $(SPLITTER_SUBDIRS) $(RENUMBER_SUBDIRS) $(KERNEL_SUBDIRS) $(GUI_SUBDIRS) DIST_SUBDIRS= \ - MEDWrapper INTERP_KERNEL MEDMEM MEDCoupling MEDCoupling_Swig MEDMEM_SWIG \ - MEDMEMBinTest MEDMEMCppTest INTERP_KERNELTest ParaMEDMEM ParaMEDMEM_Swig MEDLoader \ + MEDWrapper INTERP_KERNEL MEDCoupling MEDCoupling_Swig \ + INTERP_KERNELTest ParaMEDMEM ParaMEDMEM_Swig MEDLoader \ MEDSPLITTER MEDSPLITTER_Swig MEDPartitioner RENUMBER MEDCouplingCorba MEDCouplingCorba_Swig \ - MEDMEM_I MED MED_SWIG MedCorba_Swig ParaMEDLoader MedClient ParaMEDMEMComponent \ + ParaMEDLoader ParaMEDMEMComponent \ ParaMEDCouplingCorba MEDCalculator MEDGUI MEDOP ParaMEDMEMTest diff --git a/src/MedClient/CMakeLists.txt b/src/MedClient/CMakeLists.txt deleted file mode 100644 index dfbfc9bda..000000000 --- a/src/MedClient/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -ADD_SUBDIRECTORY(src) -ADD_SUBDIRECTORY(test) diff --git a/src/MedClient/Makefile.am b/src/MedClient/Makefile.am deleted file mode 100644 index 7e9f7d8a1..000000000 --- a/src/MedClient/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object -# - -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -SUBDIRS = src test diff --git a/src/MedClient/src/CMakeLists.txt b/src/MedClient/src/CMakeLists.txt deleted file mode 100644 index 25273e471..000000000 --- a/src/MedClient/src/CMakeLists.txt +++ /dev/null @@ -1,74 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INCLUDE(${SALOME_MACROS_DIR}/InstallAndCompilePythonFile.cmake) -FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(${SWIG_USE_FILE}) - -INCLUDE_DIRECTORIES( - ${PYTHON_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIRS} - ${OMNIORB_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${XDR_INCLUDE_DIRS} - ${KERNEL_ROOT_DIR}/include/salome - ${CMAKE_CURRENT_BINARY_DIR}/../../../idl - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../../MED - ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDMEM_I - ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../../MEDMEM_SWIG - ${CMAKE_CURRENT_SOURCE_DIR}/../../MedCorba_Swig - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../../INTERP_KERNEL/GaussPoints - ) - -SET_SOURCE_FILES_PROPERTIES(libMEDClient.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(libMEDClient.i PROPERTIES SWIG_DEFINITIONS "-shadow") - -SET(MEDClientcmodule_SOURCES - COORDINATEClient.cxx - CONNECTIVITYClient.cxx - GMESHClient.cxx - MESHClient.cxx - SUPPORTClient.cxx - FAMILYClient.cxx - GROUPClient.cxx - ) - -ADD_LIBRARY(MEDClientcmodule SHARED ${MEDClientcmodule_SOURCES}) -INSTALL(FILES libMEDClient.i DESTINATION ${MED_salomeinclude_HEADERS}) -SET_TARGET_PROPERTIES(MEDClientcmodule PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS} ${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") -TARGET_LINK_LIBRARIES(MEDClientcmodule MEDMEMImpl MEDEngine ${PTHREAD_LIBS}) -INSTALL(TARGETS MEDClientcmodule DESTINATION ${MED_salomelib_LIBS}) - -SWIG_ADD_MODULE(libMEDClient python libMEDClient.i) -SWIG_LINK_LIBRARIES(libMEDClient ${PYTHON_LIBS} MEDClientcmodule) -SET_TARGET_PROPERTIES(_libMEDClient PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS} ${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") - -IF(${MACHINE} STREQUAL WINDOWS) - SET_TARGET_PROPERTIES(_libMEDClient PROPERTIES DEBUG_OUTPUT_NAME _libMEDClient_d) -ENDIF(${MACHINE} STREQUAL WINDOWS) -INSTALL(TARGETS _libMEDClient DESTINATION ${MED_salomepythondir}) -INSTALL_AND_COMPILE_PYTHON_FILE(${CMAKE_CURRENT_BINARY_DIR}/libMEDClient.py ${MED_salomescript_PYTHON}) - -FILE(GLOB libMEDClient_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") -INSTALL(FILES ${libMEDClient_HEADERS_HXX} FIELDClient.cxx DESTINATION ${MED_salomeinclude_HEADERS}) diff --git a/src/MedClient/src/CONNECTIVITYClient.cxx b/src/MedClient/src/CONNECTIVITYClient.cxx deleted file mode 100644 index 71ba606a9..000000000 --- a/src/MedClient/src/CONNECTIVITYClient.cxx +++ /dev/null @@ -1,400 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MEDMEM_convert.hxx" -#include "Utils_CorbaException.hxx" -#include "UtilClient.hxx" -#include "CONNECTIVITYClient.hxx" - -#include "ReceiverFactory.hxx" -using namespace MEDMEM; -//============================================================================= -/*! - * Constructeur - */ -//============================================================================= - -CONNECTIVITYClient::CONNECTIVITYClient(const SALOME_MED::MESH_ptr m, - medEntityMesh Entity) : - CONNECTIVITY(m->getNumberOfTypes(Entity), Entity), - _numberOfElements_client(0), - _complete(false), - IOR_Mesh(SALOME_MED::MESH::_duplicate(m)) -{ - ASSERT(m); - - blankCopy(); -} - -//============================================================================= -/*! - * Destructeur - */ -//============================================================================= -CONNECTIVITYClient::~CONNECTIVITYClient() -{ - if (_numberOfElements_client) - delete [] _numberOfElements_client; -} - -//============================================================================= -/*! - * Remplit les informations nécessaires - * 1 seul appel Corba - */ -//============================================================================= -void CONNECTIVITYClient::blankCopy() -{ - SALOME_MED::MESH::connectivityInfos_var all; - medEntityMesh Entity = getEntity(); - try - { - all= IOR_Mesh->getConnectGlobal(Entity); - } - catch (const exception & ex) - { - MESSAGE("Unable to acces Global information"); - THROW_SALOME_CORBA_EXCEPTION(ex.what() ,SALOME::INTERNAL_ERROR); - } - - _numberOfNodes = all->numberOfNodes; - _entityDimension = all->entityDimension; - medGeometryElement * Types; - - long iT, nT; - convertCorbaArray - (Types, nT, &all->meshTypes); - - ASSERT(nT == (int) getNumberOfTypes(Entity)); - SCRUTE(nT); - - setGeometricTypes(Types, Entity); - - _totalNumberOfElements_client = 0L; - if (_numberOfElements_client) - delete [] _numberOfElements_client; - _numberOfElements_client = new long[nT]; - for (iT=0; iTnumberOfElements[iT]; - _totalNumberOfElements_client += _numberOfElements_client[iT]; - SCRUTE(iT); - SCRUTE(_numberOfElements_client[iT]); - } - - if(Types) - delete [] Types; - - // create a constituent (PAL10556) -// The consequence is that, if the remote server -// has not calculated nodal connectivity of dimension d-1, heavy method -// (CPU and memory) calculateDecsendingConnectivity is called on this -// server for a potentially useless information for client side . (by Anthony GEAY) - if ( Entity == MED_CELL ) { - Entity = ( IOR_Mesh->getMeshDimension() == 3 ? MED_FACE : MED_EDGE ); - if(_constituent) - delete _constituent; - _constituent = new CONNECTIVITYClient( IOR_Mesh, Entity ); - } - - _complete = false; -} - -//============================================================================= -/*! - */ -//============================================================================= -// template< class T> -// void dumpArray(const T* array, int size, const char* msg) -// { -// if ( msg ) -// std::cout << msg << " " << std::endl; -// std::cout << "Size: " << size << std::endl; -// for ( int i = 0; i < size; i++ ) -// std::cout << " " << array[ i ]; -// std::cout << endl; -// } - -void CONNECTIVITYClient::fillCopy() -{ - if (!_complete) { - - int *pC; - long nC; - - medEntityMesh Entity = getEntity(); - int iT, nT = getNumberOfTypes(Entity); - SCRUTE(nT); - const medGeometryElement * T = getGeometricTypes(Entity); - - int * Count = new int[nT+1] ; - Count[0]=1 ; - SCRUTE(Count[0]); - for (iT=0; iTgetSenderForConnectivity(MED_NODAL, Entity, T[iT]); - pC=ReceiverFactory::getValue(senderForConnectivity,nC); - SCRUTE(nC); - ASSERT(nC == (T[iT]%100) * (Count[iT+1]-Count[iT])); - - int *index = 0; - if ( T[iT] == MED_EN::MED_POLYGON || T[iT] == MED_EN::MED_POLYHEDRA ) - { - SALOME::SenderInt_var senderForIndex=IOR_Mesh->getSenderForConnectivityIndex(MED_NODAL, Entity, T[iT]); - index=ReceiverFactory::getValue(senderForIndex,nC); - ASSERT(nC == (Count[iT+1]-Count[iT]+1)); - } - - setNodal(pC, Entity, T[iT], index); - delete [] pC; - delete [] index; - } - - delete[] Count; - if (_constituent) - ((CONNECTIVITYClient *)_constituent)->fillCopy(); - _complete = true; - } -} - -//============================================================================= -/*! - */ -//============================================================================= -int CONNECTIVITYClient::getNumberOf(medEntityMesh Entity, - medGeometryElement Type) const -{ - int n = 0; - - SCRUTE(Type); - SCRUTE(Entity); - - if (!_complete) { - - if (Entity == _entity) { - - if (Type==MED_ALL_ELEMENTS) - n = _totalNumberOfElements_client; - - for (int i=0; i<_numberOfTypes; i++) { - SCRUTE(_geometricTypes[i]); - if (_geometricTypes[i] == Type) { - n = _numberOfElements_client[i]; - break; - } - } - } - else if (_constituent != NULL) - n = _constituent->getNumberOf(Entity,Type); - - } - else - n = CONNECTIVITY::getNumberOf(Entity, Type); - - SCRUTE(n); - return n; -} - -//============================================================================= -/*! - */ -//============================================================================= -const int * CONNECTIVITYClient::getConnectivity (medConnectivity ConnectivityType, - medEntityMesh Entity, - medGeometryElement Type) const -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int * c = CONNECTIVITY::getConnectivity (ConnectivityType, Entity, Type); - - return c; -} - -int CONNECTIVITYClient::getConnectivityLength(medConnectivity ConnectivityType, - medEntityMesh Entity, - medGeometryElement Type) const -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int l = CONNECTIVITY::getConnectivityLength (ConnectivityType, Entity, Type); - - return l; -} - -//============================================================================= -/*! - */ -//============================================================================= -const int * CONNECTIVITYClient::getConnectivityIndex (medConnectivity ConnectivityType, - medEntityMesh Entity) const -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int *c = CONNECTIVITY::getConnectivityIndex - (ConnectivityType, Entity); - - return c; -} - -//============================================================================= -/*! - */ -//============================================================================= -void CONNECTIVITYClient::calculateConnectivity (medConnectivity connectivityType, - medEntityMesh Entity) -{ - if (!_complete) - fillCopy(); - - CONNECTIVITY::calculateConnectivity(connectivityType, Entity); -} - -//============================================================================= -/*! - */ -//============================================================================= -void CONNECTIVITYClient::updateFamily (vector myFamilies) -{ - if (!_complete) - fillCopy(); - - CONNECTIVITY::updateFamily(myFamilies); -} - -//============================================================================= -/*! - */ -//============================================================================= -const int * CONNECTIVITYClient::getGlobalNumberingIndex (medEntityMesh Entity) const - throw (MEDEXCEPTION) -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int * index = CONNECTIVITY::getGlobalNumberingIndex(Entity); - - return index; -} - -//============================================================================= -/*! - */ -//============================================================================= -bool CONNECTIVITYClient::existConnectivity(medConnectivity ConnectivityType, - medEntityMesh Entity) const -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - bool b = CONNECTIVITY::existConnectivity(ConnectivityType, Entity); - - return b; -} - -//============================================================================= -/*! - */ -//============================================================================= -const int * CONNECTIVITYClient::getReverseConnectivity (medConnectivity ConnectivityType, - medEntityMesh Entity) const - throw (MEDEXCEPTION) -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int *c = CONNECTIVITY::getReverseConnectivity - (ConnectivityType, Entity); - - return c; -} - -//============================================================================= -/*! - */ -//============================================================================= -const int * CONNECTIVITYClient::getReverseConnectivityIndex (medConnectivity ConnectivityType, - medEntityMesh Entity) const - throw (MEDEXCEPTION) -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int *c = CONNECTIVITY::getReverseConnectivityIndex - (ConnectivityType, Entity); - - return c; -} - -//============================================================================= -/*! - */ -//============================================================================= -const int* CONNECTIVITYClient::getValue(medConnectivity TypeConnectivity, - medGeometryElement Type) const -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int * c = CONNECTIVITY::getValue(TypeConnectivity, Type); - - return c; -} - -//============================================================================= -/*! - */ -//============================================================================= -const int* CONNECTIVITYClient::getValueIndex(medConnectivity TypeConnectivity) const -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int * c = CONNECTIVITY::getValueIndex(TypeConnectivity); - - return c; -} - -//============================================================================= -/*! - */ -//============================================================================= -const int* CONNECTIVITYClient::getNeighbourhood() const -{ - if (!_complete) - (const_cast(this))->fillCopy(); - - const int * c = CONNECTIVITY::getNeighbourhood(); - - return c; -} diff --git a/src/MedClient/src/CONNECTIVITYClient.hxx b/src/MedClient/src/CONNECTIVITYClient.hxx deleted file mode 100644 index 39e5e4b90..000000000 --- a/src/MedClient/src/CONNECTIVITYClient.hxx +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _CONNECTIVITY_CLIENT_HXX -#define _CONNECTIVITY_CLIENT_HXX - -#include -#include "MEDMEM_Connectivity.hxx" -#include CORBA_CLIENT_HEADER(MED) - -namespace MEDMEM { - class CONNECTIVITYClient : public CONNECTIVITY { - - protected: - - long *_numberOfElements_client; - long _totalNumberOfElements_client; - - mutable bool _complete; - SALOME_MED::MESH_var IOR_Mesh ; - - public: - - CONNECTIVITYClient(const SALOME_MED::MESH_ptr m, - medEntityMesh Entity=MED_CELL); - - virtual ~CONNECTIVITYClient(); - - void fillCopy(); - void blankCopy(); - - int getNumberOf(medEntityMesh Entity, medGeometryElement Type) const; - - const int * getConnectivity (medConnectivity ConnectivityType, - medEntityMesh Entity, - medGeometryElement Type) const; - int getConnectivityLength(MED_EN::medConnectivity ConnectivityType, - MED_EN::medEntityMesh Entity, - MED_EN::medGeometryElement Type) const; - const int * getConnectivityIndex (medConnectivity ConnectivityType, - medEntityMesh Entity) const; - - void calculateConnectivity (medConnectivity connectivityType, - medEntityMesh Entity); - - void updateFamily (vector myFamilies); - - const int * getGlobalNumberingIndex (medEntityMesh Entity) const throw (MEDEXCEPTION); - - bool existConnectivity(medConnectivity ConnectivityType, - medEntityMesh Entity) const; - - const int* getReverseConnectivity (medConnectivity ConnectivityType, - medEntityMesh Entity=MED_CELL) const throw (MEDEXCEPTION); - - const int* getReverseConnectivityIndex (medConnectivity ConnectivityType, - medEntityMesh Entity=MED_CELL) const throw (MEDEXCEPTION); - - const int* getValue (medConnectivity TypeConnectivity, - medGeometryElement Type) const; - - const int* getValueIndex (medConnectivity TypeConnectivity) const; - const int* getNeighbourhood() const; - }; -}; - - -#endif diff --git a/src/MedClient/src/COORDINATEClient.cxx b/src/MedClient/src/COORDINATEClient.cxx deleted file mode 100644 index efaa9874a..000000000 --- a/src/MedClient/src/COORDINATEClient.cxx +++ /dev/null @@ -1,159 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "COORDINATEClient.hxx" -#include -#include "UtilClient.hxx" -#include "Utils_CorbaException.hxx" - -#include "ReceiverFactory.hxx" - -using namespace MEDMEM; -using namespace MED_EN; - -//============================================================================= -/*! - * Constructeur - */ -//============================================================================= - -COORDINATEClient::COORDINATEClient(const SALOME_MED::MESH_ptr m, - medModeSwitch Mode) : - COORDINATE(m->getSpaceDimension(), 1, Mode), - _complete(false), - IOR_Mesh(SALOME_MED::MESH::_duplicate(m)) -{ - blankCopy(); -} -//============================================================================= -/*! - * Remplit les informations générales - */ -//============================================================================= -void COORDINATEClient::blankCopy() -{ - std::string *tA; - long nA; - SALOME_MED::GMESH::coordinateInfos_var all; - try - { - all = IOR_Mesh->getCoordGlobal(); - } - catch (const exception & ex) - { - MESSAGE("Unable to acces Global information"); - THROW_SALOME_CORBA_EXCEPTION(ex.what() ,SALOME::INTERNAL_ERROR); - } - - //convertCorbaArray(tA, nA, IOR_Mesh->getCoordinatesNames()); - convertCorbaArray(tA, nA, &all->coordNames); - ASSERT(nA == getSpaceDimension()); - setCoordinatesNames(tA); - delete [] tA; - - //convertCorbaArray(tA, nA, IOR_Mesh->getCoordinatesUnits()); - convertCorbaArray(tA, nA, &all->coordUnits); - ASSERT(nA == getSpaceDimension()); - setCoordinatesUnits(tA); - delete [] tA; - - - setCoordinatesSystem( all->coordSystem.in()); - - _complete = false; -} -//============================================================================= -/*! - * Remplit les coordonnées - */ -//============================================================================= - -void COORDINATEClient::fillCopy() -{ - //PN ?? Est-ce qu on peut pas mettre une variable dans COORDINATEClient - // qu on remplirait dans blankCopy ?? - long nN = IOR_Mesh->getNumberOfNodes(); - double *tC; - long nC; - - SALOME::SenderDouble_var senderForCoords=IOR_Mesh->getSenderForCoordinates(MED_FULL_INTERLACE); - tC=ReceiverFactory::getValue(senderForCoords,nC); - - ASSERT(nC == (getSpaceDimension() * nN)); - - MEDARRAY mC(tC, getSpaceDimension(), nN,MED_FULL_INTERLACE,true); - setCoordinates(&mC,true); - - _complete = true; -} - -//============================================================================= -/*! - * Retourne les coordonnées - */ -//============================================================================= - -const double * COORDINATEClient::getCoordinates(medModeSwitch Mode) -{ - if (!_complete) fillCopy(); - const double * c = COORDINATE::getCoordinates(Mode); - - return c; -} -//============================================================================= -/*! - * Retourne une coordonnée - */ -//============================================================================= - -double COORDINATEClient::getCoordinate(int Number,int Axis) -{ - if (!_complete) fillCopy(); - double d = COORDINATE::getCoordinate(Number, Axis); - - return d; -} -//============================================================================= -/*! - * Retourne un axe - */ -//============================================================================= -const double * COORDINATEClient::getCoordinateAxis(int Axis) -{ - if (!_complete) fillCopy(); - const double *c = COORDINATE::getCoordinateAxis(Axis); - - return c; -} -//============================================================================= -/*! - * Retourne le nombre de noeuds - */ -//============================================================================= -const int* COORDINATEClient::getNodesNumbers() const -{ - if (!_complete) (const_cast < COORDINATEClient * >(this))->fillCopy(); - - MESSAGE("NON IMPLEMENTE DANS L'API CORBA"); - - return NULL; -} diff --git a/src/MedClient/src/COORDINATEClient.hxx b/src/MedClient/src/COORDINATEClient.hxx deleted file mode 100644 index 78ed7c071..000000000 --- a/src/MedClient/src/COORDINATEClient.hxx +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _COORDINATE_CLIENT_HXX -#define _COORDINATE_CLIENT_HXX - -#include -#include "MEDMEM_Coordinate.hxx" -#include CORBA_CLIENT_HEADER(MED) - -namespace MEDMEM { -class COORDINATEClient : public COORDINATE { - -protected: - - mutable bool _complete; - SALOME_MED::MESH_var IOR_Mesh ; - -public: - - /*! - COORDINATEClient constructor - - Build an "empty" coordinate object (without the actual coordinate values). - The object hold a Corba IOR and get data from it on user demand. - - Parameters in : m (Mesh Corba IOR) - mode (FULL_ or NO_ interlace) - */ - COORDINATEClient(const SALOME_MED::MESH_ptr m, MED_EN::medModeSwitch Mode); - - - /*! - COORDINATEClient::blankCopy() - - "(Re)Blank" the coordinate object. - - Update fixed sized data from the Corba IOR (dimensions, strings). - Get rid of variable sized data (coordinate values). - Next call of getCoordinates (for instance) will update the - object. - */ - void blankCopy(); - - - /*! - COORDINATEClient::fillCopy() - - (Re)fill the coordinate object from the Corba IOR - */ - void fillCopy(); - - - virtual ~COORDINATEClient() {}; - - virtual const double * getCoordinates(MED_EN::medModeSwitch Mode); - virtual double getCoordinate(int Number,int Axis); - virtual const double * getCoordinateAxis(int Axis); - virtual const int* getNodesNumbers() const; - -}; -}; - -#endif diff --git a/src/MedClient/src/FAMILYClient.cxx b/src/MedClient/src/FAMILYClient.cxx deleted file mode 100644 index 17ffd0aee..000000000 --- a/src/MedClient/src/FAMILYClient.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "FAMILYClient.hxx" -#include "MESHClient.hxx" -#include "UtilClient.hxx" -using namespace MEDMEM; -//============================================================================= -/*! - * Constructeur - */ -//============================================================================= -FAMILYClient::FAMILYClient(const SALOME_MED::FAMILY_ptr S, - GMESH * M) - : SUPPORTClient(S, M), - FAMILY(), - IOR_Family(SALOME_MED::FAMILY::_duplicate(S)) -{ - SCRUTE(S); - SCRUTE(M); - - blankCopy(false); -} -//============================================================================= -/*! - * Remplit les informations générales - */ -//============================================================================= -void FAMILYClient::blankCopy(bool blankSupport) -{ - if (blankSupport) - SUPPORTClient::blankCopy(); - - setIdentifier(IOR_Family->getIdentifier()); - - int nAttr, nGr, n; - int *i; - std::string *s; - - nAttr = IOR_Family->getNumberOfAttributes(); - setNumberOfAttributes(nAttr); - - SALOME_TYPES::ListOfLong* attrId= IOR_Family->getAttributesIdentifiers(); - convertCorbaArray(i, n, attrId); - delete attrId; - ASSERT(n == nAttr); - setAttributesIdentifiers(i); - - attrId=IOR_Family->getAttributesValues(); - i=0; - convertCorbaArray(i, n, attrId); - delete attrId; - ASSERT(n == _numberOfAttribute); - setAttributesValues(i); - - SALOME_TYPES::ListOfString * attrDesc=IOR_Family->getAttributesDescriptions(); - convertCorbaArray(s, n, attrDesc); - delete attrDesc; - ASSERT(n == _numberOfAttribute); - setAttributesDescriptions(s); - - nGr = IOR_Family->getNumberOfGroups(); - setNumberOfGroups(nGr); - - attrDesc=IOR_Family->getGroupsNames(); - s=0; - convertCorbaArray(s, n, attrDesc); - delete attrDesc; - ASSERT(n == _numberOfGroup); - setGroupsNames(s,true); - - _complete = false; -} - -//============================================================================= -/*! - * Remplit les informations générales - */ -//============================================================================= -void FAMILYClient::fillCopy(bool fillSupport) -{ - if (!_complete) { - - if (fillSupport) - SUPPORTClient::fillCopy(); - - // Get other FAMILY attributes - - _complete = true; - } -} - -//============================================================================= -/*! - * Destructeur - */ -//============================================================================= - -FAMILYClient::~FAMILYClient() -{ -} diff --git a/src/MedClient/src/FAMILYClient.hxx b/src/MedClient/src/FAMILYClient.hxx deleted file mode 100644 index 9605f81d1..000000000 --- a/src/MedClient/src/FAMILYClient.hxx +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _FAMILYCLIENT_HXX -#define _FAMILYCLIENT_HXX - -#include -#include -#include "MEDMEM_Family.hxx" -#include CORBA_CLIENT_HEADER(MED) -#include "SUPPORTClient.hxx" - - -namespace MEDMEM { -class FAMILYClient : - public SUPPORTClient, public FAMILY { - -private : - - const SALOME_MED::FAMILY_var IOR_Family; - - mutable bool _complete; - -public : - - FAMILYClient(const SALOME_MED::FAMILY_ptr S, - GMESH * M = NULL); - virtual ~FAMILYClient(); - - virtual void blankCopy(bool blankSupport = true); - virtual void fillCopy(bool fillSupport = true); -}; - -}; - -#endif diff --git a/src/MedClient/src/FIELDClient.cxx b/src/MedClient/src/FIELDClient.cxx deleted file mode 100644 index 9f1228202..000000000 --- a/src/MedClient/src/FIELDClient.cxx +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -template -FIELDClient::FIELDClient(typename FIELDI_TRAITS::SimpleFieldCorbaPtrType ptrCorba,MEDMEM::SUPPORT * S):_fieldPtr(FIELDI_TRAITS::SimpleFieldGlobalType::_duplicate(ptrCorba)),_refCounter(1) -{ - if (!S) - { - SCRUTE(_fieldPtr); - SCRUTE(_fieldPtr->getSupport()); - MEDMEM::FIELD::_support=new MEDMEM::SUPPORTClient(_fieldPtr->getSupport()); - } - else - MEDMEM::FIELD::setSupport(S); - - this->setName(_fieldPtr->getName()); - - MEDMEM::FIELD::setDescription(_fieldPtr->getDescription()); - int nc = _fieldPtr->getNumberOfComponents(); - MEDMEM::FIELD::setNumberOfComponents(nc); - - MEDMEM::FIELD::setNumberOfValues( MEDMEM::FIELD::_support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS)); - - string * _s = new string[nc]; - - SALOME_TYPES::ListOfString_var s; - s = _fieldPtr->getComponentsNames(); - for (int i=0; i::setComponentsNames(_s); - - s = _fieldPtr->getComponentsDescriptions(); - for (int i=0; i::setComponentsDescriptions(_s); - - s = _fieldPtr->getComponentsUnits(); - for (int i=0; i::setMEDComponentsUnits(_s); - - delete [] _s; - this->setIterationNumber(_fieldPtr->getIterationNumber()); - this->setTime(_fieldPtr->getTime()); - this->setOrderNumber(_fieldPtr->getOrderNumber()); - fillCopy(); -} - -template -void FIELDClient::fillCopy() -{ - long n; - typename FIELDI_TRAITS::SenderVarType sender=_fieldPtr->getSenderForValue(MEDMEM::FIELD::_interlacingType); - T *v = (T *)ReceiverFactory::getValue(sender,n); - MEDMEM::MEDMEM_Array_ * array; - if(_fieldPtr->getGaussPresence()) - array=0; - //array=new typename MEDMEM::MEDMEM_ArrayInterface::Array - // (v, MEDMEM::FIELD::getNumberOfComponents(),MEDMEM::FIELD::getNumberOfValues(),true,true); - else - array=new typename MEDMEM::MEDMEM_ArrayInterface::Array - (v, MEDMEM::FIELD::getNumberOfComponents(),MEDMEM::FIELD::getNumberOfValues(),true,true); - MEDMEM::FIELD::setArray(array); -} - -template -FIELDClient::~FIELDClient() -{ - CORBA::release(_fieldPtr); - /* CCAR : better put in FIELD_ destructor if support is a SUPPORTClient - if(FIELD::_support) - FIELD::_support->removeReference(); - */ -} - diff --git a/src/MedClient/src/FIELDClient.hxx b/src/MedClient/src/FIELDClient.hxx deleted file mode 100644 index 8f422ef7b..000000000 --- a/src/MedClient/src/FIELDClient.hxx +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _FIELDCLIENT_HXX -#define _FIELDCLIENT_HXX - -#include -#include -#include "MEDMEM_Field.hxx" -#include "SUPPORTClient.hxx" -#include "ReceiverFactory.hxx" -#include "SenderFactory.hxx" -#include "MEDMEM_TraitsForFields.hxx" -#include "MEDMEM_InterlacingTraits.hxx" -#include CORBA_CLIENT_HEADER(MED) - -namespace MEDMEM{ - -template -class FIELDClient : public MEDMEM::FIELD -{ -private: - typename FIELDI_TRAITS::SimpleFieldCorbaPtrType _fieldPtr; - int _refCounter; -public: - FIELDClient(typename FIELDI_TRAITS::SimpleFieldCorbaPtrType ptrCorba,MEDMEM::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 deleted file mode 100644 index 02dc37b9b..000000000 --- a/src/MedClient/src/FIELDDOUBLEClient.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "FIELDDOUBLEClient.hxx" -namespace MEDMEM{ - -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -FIELDDOUBLEClient::FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba, - MEDMEM::SUPPORT * S) : - FIELDClient(ptrCorba,S) -{ - const char* LOC = "Constructor with arguments (for Python API) FIELDDOUBLEClient"; - BEGIN_OF(LOC); - - END_OF(LOC); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -FIELDDOUBLEClient::~FIELDDOUBLEClient() -{ - const char* LOC = "Default Destructor (for Python API) FIELDDOUBLEClient"; - BEGIN_OF(LOC); - - END_OF(LOC); -} - -} diff --git a/src/MedClient/src/FIELDDOUBLEClient.hxx b/src/MedClient/src/FIELDDOUBLEClient.hxx deleted file mode 100644 index a82b1210d..000000000 --- a/src/MedClient/src/FIELDDOUBLEClient.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _FIELDDOUBLECLIENT_HXX -#define _FIELDDOUBLECLIENT_HXX - -#include "FIELDClient.hxx" - -namespace MEDMEM{ - -class FIELDDOUBLEClient : - public FIELDClient -{ -public: - FIELDDOUBLEClient(SALOME_MED::FIELDDOUBLE_ptr ptrCorba, - MEDMEM::SUPPORT * S = NULL); - ~FIELDDOUBLEClient(); -}; - -} -#endif diff --git a/src/MedClient/src/FIELDINTClient.cxx b/src/MedClient/src/FIELDINTClient.cxx deleted file mode 100644 index d72110673..000000000 --- a/src/MedClient/src/FIELDINTClient.cxx +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "FIELDINTClient.hxx" -namespace MEDMEM{ - -//============================================================================= -/*! - * Constructor with arguments - */ -//============================================================================= -FIELDINTClient::FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba, - MEDMEM::SUPPORT * S) : - FIELDClient(ptrCorba,S) -{ - const char* LOC = "Constructor with arguments (for Python API) FIELDINTClient"; - BEGIN_OF(LOC); - - END_OF(LOC); -} -//============================================================================= -/*! - * Destructor - */ -//============================================================================= -FIELDINTClient::~FIELDINTClient() -{ - const char* LOC = "Default Destructor (for Python API) FIELDINTClient"; - BEGIN_OF(LOC); - - END_OF(LOC); -} - -} diff --git a/src/MedClient/src/FIELDINTClient.hxx b/src/MedClient/src/FIELDINTClient.hxx deleted file mode 100644 index 0995dae5f..000000000 --- a/src/MedClient/src/FIELDINTClient.hxx +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _FIELDINTCLIENT_HXX -#define _FIELDINTCLIENT_HXX - -#include "FIELDClient.hxx" - -namespace MEDMEM{ -class FIELDINTClient : - public FIELDClient -{ -public: - FIELDINTClient(SALOME_MED::FIELDINT_ptr ptrCorba, - MEDMEM::SUPPORT * S = NULL); - ~FIELDINTClient(); -}; -} -#endif diff --git a/src/MedClient/src/GMESHClient.cxx b/src/MedClient/src/GMESHClient.cxx deleted file mode 100644 index f01850c2d..000000000 --- a/src/MedClient/src/GMESHClient.cxx +++ /dev/null @@ -1,460 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "GMESHClient.hxx" -#include "MEDMEM_convert.hxx" -#include "UtilClient.hxx" -#include "COORDINATEClient.hxx" -#include "CONNECTIVITYClient.hxx" -#include "FAMILYClient.hxx" -#include "GROUPClient.hxx" -#include "MESHClient.hxx" -#include "Utils_CorbaException.hxx" - -using namespace MEDMEM; -using namespace MED_EN; - -//============================================================================= -/*! - * Constructeur - */ -//============================================================================= - -GMESHClient::GMESHClient(const SALOME_MED::GMESH_ptr m) : - GMESH(), //_refCounter(1), - IOR_Mesh(SALOME_MED::GMESH::_duplicate(m)), - _complete(false), _uMesh(0) - -{ - ASSERT(m); - - blankCopy(); -} -//============================================================================= -/*! - * Transforme un IOR Famille en Famille Client - */ -//============================================================================= - -FAMILY * convertFamily(const SALOME_MED::FAMILY_ptr &F, GMESH *M) -{ - return new FAMILYClient(F, M); -} -//============================================================================= -/*! - * Transforme un IOR groupe en groupe Client - */ -//============================================================================= -GROUP * convertGroup(const SALOME_MED::GROUP_ptr &F, GMESH *M) -{ - return new GROUPClient(F, M); -} - -//============================================================================= -/*! - * Remplit les informations générales - */ -//============================================================================= -void GMESHClient::blankCopy() -{ - SALOME_MED::GMESH::meshInfos_var all = IOR_Mesh->getMeshGlobal(); - - _name = all->name; - _spaceDimension = all->spaceDimension; - - convertCorbaArray - (_familyNode, - //IOR_Mesh->getFamilies(MED_NODE), - &all->famNode, - (void *) (convertFamily), this); - - convertCorbaArray - (_familyEdge, - //IOR_Mesh->getFamilies(MED_EDGE), - &all->famEdge, - (void *) (convertFamily), this); - - convertCorbaArray - (_familyFace, - //IOR_Mesh->getFamilies(MED_FACE), - &all->famFace, - (void *) (convertFamily), this); - - convertCorbaArray - (_familyCell, - //IOR_Mesh->getFamilies(MED_CELL), - &all->famCell, - (void *) (convertFamily), this); - - convertCorbaArray - (_groupNode, - //IOR_Mesh->getGroups(MED_NODE), - &all->groupNode, - (void *) (convertGroup), this); - - convertCorbaArray - (_groupEdge, - //IOR_Mesh->getGroups(MED_EDGE), - &all->groupEdge, - (void *) (convertGroup), this); - - convertCorbaArray - (_groupFace, - //IOR_Mesh->getGroups(MED_FACE), - &all->groupFace, - (void *) (convertGroup), this); - - convertCorbaArray - (_groupCell, - //IOR_Mesh->getGroups(MED_CELL), - &all->groupCell, - (void *) (convertGroup), this); - - if ( !IOR_Mesh->getIsAGrid() && !dynamic_cast(this)) - { - SALOME_MED::MESH_var umeshIOR = IOR_Mesh->convertInMESH(); - _uMesh = new MESHClient( umeshIOR ); - } - - _complete = false; -} -//============================================================================= -/*! - * Remplit les informations sur les coordonnees et la connectivite - */ -//============================================================================= - -void GMESHClient::fillCopy() -{ - int size = _familyNode.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyNode[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - size = _familyCell.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyCell[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - size = _familyFace.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyFace[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - size = _familyEdge.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyEdge[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - if ( _uMesh ) - _uMesh->fillCopy(); - else - THROW_SALOME_CORBA_EXCEPTION("GRID client does not exists",SALOME::INTERNAL_ERROR); - - _complete = true; -} - -//============================================================================= -/*! - * Test equality between 2 GMESHClients. - */ -//============================================================================= -bool GMESHClient::operator==(const GMESH& other) const -{ - const GMESHClient* otherClt=dynamic_cast(&other); - if(otherClt) - { - if(this==otherClt) - { - return true; - } - return IOR_Mesh->areEquals(otherClt->IOR_Mesh); - } - return false; -} - -//============================================================================= -/*! - * Destructeur - */ -//============================================================================= - -GMESHClient::~GMESHClient() -{ - if ( _uMesh ) - _uMesh->removeReference(); - IOR_Mesh->UnRegister(); -} - -//============================================================================= -/*! - * Write all the content of the GMESH using driver referenced by the integer handler index - */ -//============================================================================= - -void GMESHClient::write(int index/*=0*/) const -{ - if ( index < 0 || index >= (int)_drivers.size() || !_drivers[index] ) - throw MED_EXCEPTION ( LOCALIZED( STRING("GMESHClient::write(int index): ") - << "The index given is invalid, index must be between 0 and |" - << _drivers.size() )); - - const_cast(this)->fillCopy(); - _uMesh->write( *_drivers[index], _drivers[index]->getAccessMode() ); -} - -//============================================================================= -/*! - * Write all the content of the GMESH using genDriver - */ -//============================================================================= - -void GMESHClient::write(const GENDRIVER & genDriver, - MED_EN::med_mode_acces medMode) const -{ - const_cast(this)->fillCopy(); - _uMesh->write(genDriver,medMode); -} - -//============================================================================= -/*! - * Write all the content of the GMESH - */ -//============================================================================= - -void GMESHClient::write(driverTypes driverType, - const std::string& filename, - const std::string& meshname, - MED_EN::med_mode_acces medMode) const -{ - const_cast(this)->fillCopy(); - _uMesh->write(driverType, filename,meshname,medMode); -} - -//================================================================================ -/*! - * \brief fillCopy() and then print myself to a stream - */ -//================================================================================ - -void GMESHClient::printMySelf(ostream &os) const -{ - GMESHClient* that = (GMESHClient*)this; - that->fillCopy(); - if ( _uMesh ) - _uMesh->printMySelf( os ); - else - os << "GMESHClient " << (void*) this; -} - -bool GMESHClient::isEmpty() const -{ - return _uMesh ? _uMesh->isEmpty() : (IOR_Mesh->getNumberOfNodes() < 1); -} - -bool GMESHClient::deepCompare(const GMESH& other) const -{ - if ( getIsAGrid() != other.getIsAGrid() || - getIsAGrid()) // no client nor server for GRID -> can't compare - return false; - - return _uMesh ? _uMesh->deepCompare( other ) : false; -} - -int GMESHClient::getMeshDimension() const -{ - return IOR_Mesh->getMeshDimension(); -} - -bool GMESHClient::getIsAGrid() const -{ - return IOR_Mesh->getIsAGrid(); -} - -std::string GMESHClient::getCoordinatesSystem() const -{ - CORBA::String_var s = IOR_Mesh->getCoordinatesSystem(); - return s._retn(); -} - -const std::string* GMESHClient::getCoordinatesNames() const -{ - return _uMesh ? _uMesh->getCoordinatesNames() : (std::string*) 0; -} - -const std::string* GMESHClient::getCoordinatesUnits() const -{ - return _uMesh ? _uMesh->getCoordinatesUnits() : (std::string*) 0; -} - -int GMESHClient::getNumberOfNodes() const -{ - return IOR_Mesh->getNumberOfNodes(); -} - -int GMESHClient::getNumberOfTypes(MED_EN::medEntityMesh entity) const -{ - return IOR_Mesh->getNumberOfTypes(entity); -} - -int GMESHClient::getNumberOfElements(MED_EN::medEntityMesh entity, - MED_EN::medGeometryElement type) const -{ - return IOR_Mesh->getNumberOfElements(entity,type); -} - -const MED_EN::medGeometryElement* GMESHClient::getTypes(MED_EN::medEntityMesh entity) const -{ - return _uMesh ? _uMesh->getTypes(entity) : (MED_EN::medGeometryElement*) 0; -} - -MED_EN::medGeometryElement GMESHClient::getElementType(MED_EN::medEntityMesh entity, - int i) const -{ - return IOR_Mesh->getElementType(entity,i); -} - -const MESH* GMESHClient::convertInMESH() const -{ - if ( !_uMesh ) - { - SALOME_MED::MESH_var umeshIOR = IOR_Mesh->convertInMESH(); - const_cast(this)->_uMesh = new MESHClient( umeshIOR ); - } - _uMesh->addReference(); - return _uMesh; -} - -SUPPORT* GMESHClient::getBoundaryElements(MED_EN::medEntityMesh entity) const throw (MEDEXCEPTION) -{ - SALOME_MED::SUPPORT_var s = IOR_Mesh->getBoundaryElements(entity); - return new SUPPORTClient( s ); -} - -SUPPORT* GMESHClient::getSkin(const SUPPORT* sup) throw (MEDEXCEPTION) -{ - return _uMesh ? _uMesh->getSkin( sup ) : (SUPPORT*)0; -} - -SUPPORT* GMESHClient::buildSupportOnNodeFromElementList(const std::list& elems, - MED_EN::medEntityMesh entity) const - throw (MEDEXCEPTION) -{ - return _uMesh ? _uMesh->buildSupportOnNodeFromElementList(elems,entity ) : (SUPPORT*)0; -} - -void GMESHClient::fillSupportOnNodeFromElementList(const std::list& elems, - SUPPORT* sup) const - throw (MEDEXCEPTION) -{ - if ( _uMesh ) _uMesh->fillSupportOnNodeFromElementList(elems,sup); -} - -FIELD* GMESHClient::getVolume(const SUPPORT* sup , bool isAbs) const - throw (MEDEXCEPTION) -{ - FIELD* f = (FIELD*) 0; - if ( _uMesh && sup ) - { - sup->setMesh( _uMesh ); - f = _uMesh->getVolume(sup,isAbs); - sup->setMesh( this ); - } - return f; -} - -FIELD* GMESHClient::getArea(const SUPPORT* sup) const throw (MEDEXCEPTION) -{ - FIELD* f = (FIELD*) 0; - if ( _uMesh && sup ) - { - sup->setMesh( _uMesh ); - f = _uMesh->getArea(sup); - sup->setMesh( this ); - } - return f; -} - -FIELD* GMESHClient::getLength(const SUPPORT* sup) const throw (MEDEXCEPTION) -{ - FIELD* f = (FIELD*) 0; - if ( _uMesh && sup ) - { - sup->setMesh( _uMesh ); - f = _uMesh->getLength(sup); - sup->setMesh( this ); - } - return f; -} - -FIELD* GMESHClient::getNormal(const SUPPORT* sup) const throw (MEDEXCEPTION) -{ - FIELD* f = (FIELD*) 0; - if ( _uMesh && sup ) - { - sup->setMesh( _uMesh ); - f = _uMesh->getNormal(sup); - sup->setMesh( this ); - } - return f; -} - -FIELD* GMESHClient::getBarycenter(const SUPPORT* sup) const throw (MEDEXCEPTION) -{ - FIELD* f = (FIELD*) 0; - if ( _uMesh && sup ) - { - sup->setMesh( _uMesh ); - f = _uMesh->getBarycenter(sup); - sup->setMesh( this ); - } - return f; -} - -std::vector > GMESHClient::getBoundingBox() const -{ - std::vector > bb; - if ( _uMesh ) - bb = _uMesh->getBoundingBox(); - return bb; -} - diff --git a/src/MedClient/src/GMESHClient.hxx b/src/MedClient/src/GMESHClient.hxx deleted file mode 100644 index d1a735026..000000000 --- a/src/MedClient/src/GMESHClient.hxx +++ /dev/null @@ -1,95 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _GMESHCLIENT_HXX -#define _GMESHCLIENT_HXX - -#include "MEDClient.hxx" - -#include -#include -#include "MEDMEM_GMesh.hxx" -#include CORBA_CLIENT_HEADER(MED) - -namespace MEDMEM { -class MESHClient; - -class MEDCLIENT_EXPORT GMESHClient : public GMESH -{ -private : - - const SALOME_MED::GMESH_var IOR_Mesh; - - mutable bool _complete; - - //mutable int _refCounter; - MESHClient* _uMesh; - -public : - - GMESHClient(const SALOME_MED::GMESH_ptr m); - virtual bool operator==(const GMESH& other) const; - - void blankCopy(); - void fillCopy(); -// virtual void addReference() const; -// virtual void removeReference() const; - virtual void write(int index=0) const; - virtual void write(const GENDRIVER & genDriver, - MED_EN::med_mode_acces medMode=MED_EN::WRONLY) const; - virtual void write(driverTypes driverType, - const std::string& filename, - const std::string& meshname="", - MED_EN::med_mode_acces medMode=MED_EN::WRONLY) const; - virtual void printMySelf(ostream &os) const; - - virtual bool isEmpty() const; - virtual bool deepCompare(const GMESH&) const; - virtual int getMeshDimension() const; - virtual bool getIsAGrid() const; - virtual std::string getCoordinatesSystem() const; - virtual const std::string* getCoordinatesNames() const; - virtual const std::string* getCoordinatesUnits() const; - virtual int getNumberOfNodes() const; - virtual int getNumberOfTypes(MED_EN::medEntityMesh) const; - virtual int getNumberOfElements(MED_EN::medEntityMesh, MED_EN::medGeometryElement) const; - virtual const MED_EN::medGeometryElement* getTypes(MED_EN::medEntityMesh) const; - virtual MED_EN::medGeometryElement getElementType(MED_EN::medEntityMesh, int) const; - virtual const MESH* convertInMESH() const; - virtual SUPPORT* getBoundaryElements(MED_EN::medEntityMesh) const throw (MEDEXCEPTION); - virtual SUPPORT* getSkin(const SUPPORT*) throw (MEDEXCEPTION); - virtual SUPPORT* buildSupportOnNodeFromElementList(const std::list&, MED_EN::medEntityMesh) const throw (MEDEXCEPTION); - virtual void fillSupportOnNodeFromElementList(const std::list&, SUPPORT*) const throw (MEDEXCEPTION); - virtual FIELD* getVolume(const SUPPORT*, bool) const throw (MEDEXCEPTION); - virtual FIELD* getArea(const SUPPORT*) const throw (MEDEXCEPTION); - virtual FIELD* getLength(const SUPPORT*) const throw (MEDEXCEPTION); - virtual FIELD* getNormal(const SUPPORT*) const throw (MEDEXCEPTION); - virtual FIELD* getBarycenter(const SUPPORT*) const throw (MEDEXCEPTION); - virtual std::vector > getBoundingBox() const; - -private: - virtual ~GMESHClient(); -}; -} - -#endif - diff --git a/src/MedClient/src/GROUPClient.cxx b/src/MedClient/src/GROUPClient.cxx deleted file mode 100644 index df3aea0ea..000000000 --- a/src/MedClient/src/GROUPClient.cxx +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "GROUPClient.hxx" -#include "MESHClient.hxx" -using namespace MEDMEM; - -//============================================================================= -/*! - * Constructeur - */ -//============================================================================= - -GROUPClient::GROUPClient(const SALOME_MED::GROUP_ptr G, - GMESH * M) - : SUPPORTClient(G, M), - GROUP(), - IOR_Group(SALOME_MED::GROUP::_duplicate(G)) -{ - SCRUTE(G); - SCRUTE(M); -} - -//============================================================================= -/*! - * Remplit les informations générales - */ -//============================================================================= -void GROUPClient::blankCopy() -{ - SUPPORTClient::blankCopy(); - _complete = false; -} -//============================================================================= -/*! - * Remplit les informations - */ -//============================================================================= - -void GROUPClient::fillCopy() -{ - SUPPORTClient::fillCopy(); - _complete = true; -} - -//============================================================================= -/*! - * Destructeur - */ -//============================================================================= - -GROUPClient::~GROUPClient() -{ -} diff --git a/src/MedClient/src/GROUPClient.hxx b/src/MedClient/src/GROUPClient.hxx deleted file mode 100644 index 0503b8e71..000000000 --- a/src/MedClient/src/GROUPClient.hxx +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _GROUPCLIENT_HXX -#define _GROUPCLIENT_HXX - -#include -#include -#include "MEDMEM_Group.hxx" -#include CORBA_CLIENT_HEADER(MED) -#include "SUPPORTClient.hxx" - -namespace MEDMEM { -class GROUPClient : - public SUPPORTClient, - public GROUP -{ - -private : - - const SALOME_MED::GROUP_var IOR_Group; - - mutable bool _complete; - -public : - - GROUPClient(const SALOME_MED::GROUP_ptr S, - GMESH * M = NULL); - virtual ~GROUPClient(); - - virtual void blankCopy(); - virtual void fillCopy(); -}; - -} - -#endif diff --git a/src/MedClient/src/MEDClient.hxx b/src/MedClient/src/MEDClient.hxx deleted file mode 100644 index 980df0f95..000000000 --- a/src/MedClient/src/MEDClient.hxx +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -// File : MEDMEM.hxx -// Author : E.A. -// Module : MED -// -#ifndef _MEDCLIENT_HXX_ -#define _MEDCLIENT_HXX_ - -#ifdef WIN32 -# if defined MEDCLIENT_EXPORTS || defined MEDClientcmodule_EXPORTS -# define MEDCLIENT_EXPORT __declspec( dllexport ) -# else -# define MEDCLIENT_EXPORT __declspec( dllimport ) -# endif -#else -# define MEDCLIENT_EXPORT -#endif - -#endif diff --git a/src/MedClient/src/MESHClient.cxx b/src/MedClient/src/MESHClient.cxx deleted file mode 100644 index 7f20d0143..000000000 --- a/src/MedClient/src/MESHClient.cxx +++ /dev/null @@ -1,317 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MESHClient.hxx" -#include "MEDMEM_convert.hxx" -#include "UtilClient.hxx" -#include "COORDINATEClient.hxx" -#include "CONNECTIVITYClient.hxx" -#include "FAMILYClient.hxx" -#include "GROUPClient.hxx" - -using namespace MEDMEM; -using namespace MED_EN; - -//============================================================================= -/*! - * Constructeur - */ -//============================================================================= - -MESHClient::MESHClient(const SALOME_MED::MESH_ptr m) : - IOR_Mesh(SALOME_MED::MESH::_duplicate(m)), - _complete(false)//,_refCounter(1) -{ - if ( CORBA::is_nil( m )) - throw MEDEXCEPTION("MESHClient(const SALOME_MED::MESH_ptr mesh): NULL mesh!"); - - _coordinate = new COORDINATEClient(m, MED_FULL_INTERLACE); - _connectivity = new CONNECTIVITYClient(m, MED_FULL_INTERLACE); - - blankCopy(); -} -//============================================================================= -/*! - * Transforme un IOR Famille en Famille Client - */ -//============================================================================= - -FAMILY * convertFamily(const SALOME_MED::FAMILY_ptr &F, MESH *M) -{ - return new FAMILYClient(F, M); -} -//============================================================================= -/*! - * Transforme un IOR groupe en groupe Client - */ -//============================================================================= -GROUP * convertGroup(const SALOME_MED::GROUP_ptr &F, MESH *M) -{ - return new GROUPClient(F, M); -} -//============================================================================= -/*! - * Remplit les informations générales - */ -//============================================================================= -void MESHClient::blankCopy() -{ - SALOME_MED::GMESH::meshInfos_var all = IOR_Mesh->getMeshGlobal(); - - //CORBA::String_var s; - //s= IOR_Mesh->getName(); _name = s; - //_spaceDimension = IOR_Mesh->getSpaceDimension(); - //_meshDimension = IOR_Mesh->getMeshDimension(); - //_numberOfNodes = IOR_Mesh->getNumberOfNodes(); - - _name = all->name; - _spaceDimension = all->spaceDimension; - _numberOfNodes = all->numberOfNodes; - - COORDINATEClient *_coord - = dynamic_cast(_coordinate); - ASSERT(_coord); - CONNECTIVITYClient *_connect - = dynamic_cast(_connectivity); - ASSERT(_connect); - - _coord->blankCopy(); - _connect->blankCopy(); - - convertCorbaArray - (_familyNode, - //IOR_Mesh->getFamilies(MED_NODE), - &all->famNode, - (void *) (convertFamily), this); - - convertCorbaArray - (_familyEdge, - //IOR_Mesh->getFamilies(MED_EDGE), - &all->famEdge, - (void *) (convertFamily), this); - - convertCorbaArray - (_familyFace, - //IOR_Mesh->getFamilies(MED_FACE), - &all->famFace, - (void *) (convertFamily), this); - - convertCorbaArray - (_familyCell, - //IOR_Mesh->getFamilies(MED_CELL), - &all->famCell, - (void *) (convertFamily), this); - - convertCorbaArray - (_groupNode, - //IOR_Mesh->getGroups(MED_NODE), - &all->groupNode, - (void *) (convertGroup), this); - - convertCorbaArray - (_groupEdge, - //IOR_Mesh->getGroups(MED_EDGE), - &all->groupEdge, - (void *) (convertGroup), this); - - convertCorbaArray - (_groupFace, - //IOR_Mesh->getGroups(MED_FACE), - &all->groupFace, - (void *) (convertGroup), this); - - convertCorbaArray - (_groupCell, - //IOR_Mesh->getGroups(MED_CELL), - &all->groupCell, - (void *) (convertGroup), this); - - _complete = false; -} -//============================================================================= -/*! - * Remplit les informations sur les coordonnees et la connectivite - */ -//============================================================================= - -void MESHClient::fillCopy() -{ - COORDINATEClient *_coord - = dynamic_cast (_coordinate); - ASSERT(_coord); - CONNECTIVITYClient *_connect - = dynamic_cast (_connectivity); - ASSERT(_connect); - - _coord->fillCopy(); - _connect->fillCopy(); - - int size = _familyNode.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyNode[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - size = _familyCell.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyCell[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - size = _familyFace.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyFace[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - size = _familyEdge.size(); - - for (int i = 0; i < size; i++) - { - FAMILYClient * _fam = dynamic_cast (_familyEdge[i]); - ASSERT(_fam); - - _fam->fillCopy(); - } - - _complete = true; -} - -//============================================================================= -/*! - * Test equality between 2 MESHClients. - */ -//============================================================================= -bool MESHClient::operator==(const MESH& other) const -{ - const MESHClient* otherClt=dynamic_cast(&other); - if(otherClt) - { - if(this==otherClt) - { - return true; - } - return IOR_Mesh->areEquals(otherClt->IOR_Mesh); - } - return false; -} - -//============================================================================= -/*! - * Destructeur - */ -//============================================================================= - -MESHClient::~MESHClient() -{ - IOR_Mesh->UnRegister(); -} - -//============================================================================= -/*! - * For refCounter - */ -//============================================================================= - -/*void MESHClient::addReference() const -{ - _refCounter++; -}*/ - -//============================================================================= -/*! - * For refCounter - */ -//============================================================================= - -/*void MESHClient::removeReference() const -{ - if (--_refCounter <= 0) - { - delete this; - } -}*/ - -//============================================================================= -/*! - * Write all the content of the MESH using driver referenced by the integer handler index - */ -//============================================================================= - -void MESHClient::write(int index/*=0*/) const -{ - const_cast(this)->fillCopy(); - GMESH::write(index); -} - -//============================================================================= -/*! - * Write all the content of the GMESH using genDriver - */ -//============================================================================= - -void MESHClient::write(const GENDRIVER & genDriver, - MED_EN::med_mode_acces medMode) const -{ - const_cast(this)->fillCopy(); - GMESH::write(genDriver); -} - -//============================================================================= -/*! - * Write all the content of the GMESH - */ -//============================================================================= - -void MESHClient::write(driverTypes driverType, - const std::string& filename, - const std::string& meshname, - MED_EN::med_mode_acces medMode) const -{ - const_cast(this)->fillCopy(); - GMESH::write(driverType, filename); -} - -//================================================================================ -/*! - * \brief fillCopy() and then print myself to a stream - */ -//================================================================================ - -void MESHClient::printMySelf(ostream &os) const -{ - MESHClient* that = (MESHClient*)this; - that->fillCopy(); - MESH::printMySelf( os ); -} diff --git a/src/MedClient/src/MESHClient.hxx b/src/MedClient/src/MESHClient.hxx deleted file mode 100644 index df73a5620..000000000 --- a/src/MedClient/src/MESHClient.hxx +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _MESHCLIENT_HXX -#define _MESHCLIENT_HXX - -#include -#include -#include "MEDClient.hxx" -#include "MEDMEM_Mesh.hxx" -#include CORBA_CLIENT_HEADER(MED) - -namespace MEDMEM { -class MEDCLIENT_EXPORT MESHClient : public MESH { - -private : - - const SALOME_MED::MESH_var IOR_Mesh; - - mutable bool _complete; - -// mutable int _refCounter; - -public : - - MESHClient(const SALOME_MED::MESH_ptr m); - virtual bool operator==(const MESH& other) const; - - void blankCopy(); - void fillCopy(); -// virtual void addReference() const; -// virtual void removeReference() const; - virtual void write(int index=0) const; - virtual void write(const GENDRIVER & genDriver, - MED_EN::med_mode_acces medMode=MED_EN::WRONLY) const; - virtual void write(driverTypes driverType, - const std::string& filename, - const std::string& meshname="", - MED_EN::med_mode_acces medMode=MED_EN::WRONLY) const; - virtual void printMySelf(ostream &os) const; - -private: - virtual ~MESHClient(); -}; -} - -#endif - diff --git a/src/MedClient/src/Makefile.am b/src/MedClient/src/Makefile.am deleted file mode 100644 index 01fc923eb..000000000 --- a/src/MedClient/src/Makefile.am +++ /dev/null @@ -1,117 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -salomeinclude_HEADERS = \ - MEDClient.hxx \ - COORDINATEClient.hxx \ - CONNECTIVITYClient.hxx \ - GMESHClient.hxx \ - MESHClient.hxx \ - SUPPORTClient.hxx \ - FAMILYClient.hxx \ - GROUPClient.hxx \ - FIELDClient.hxx \ - FIELDClient.cxx \ - UtilClient.hxx \ - libMEDClient.i - -if MED_SWIG_1_3_21 -SWIG_DEF = libMEDClient.i dummy.i - -dummy_wrap.cxx: libMEDClient_wrap.cxx - sed -e 's/SwigValueWrapper< vector >/vector/g' libMEDClient_wrap.cxx > toto - mv toto libMEDClient_wrap.cxx - sed -e 's/SwigValueWrapper< vector const >/vector/g' libMEDClient_wrap.cxx > toto - mv toto libMEDClient_wrap.cxx - touch dummy_wrap.cxx -else !MED_SWIG_1_3_21 -SWIG_DEF = libMEDClient.i -endif - -dist_salomescript_DATA = \ - medClient_test.py \ - testMeshAlliances.py -nodist_salomescript_DATA = libMEDClient.py - -lib_LTLIBRARIES = libMEDClientcmodule.la _libMEDClient.la - -dist_libMEDClientcmodule_la_SOURCES = \ - COORDINATEClient.cxx \ - CONNECTIVITYClient.cxx \ - GMESHClient.cxx \ - MESHClient.cxx \ - SUPPORTClient.cxx \ - FAMILYClient.cxx \ - GROUPClient.cxx - -dist__libMEDClient_la_SOURCES = libMEDClient.i -nodist__libMEDClient_la_SOURCES = libMEDClient_wrap.cxx - -libMEDClientcmodule_la_CPPFLAGS = $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \ - $(MED3_INCLUDES) $(HDF5_INCLUDES) $(PYTHON_INCLUDES) ${KERNEL_CXXFLAGS} \ - -I$(srcdir)/../../MEDMEM_I -I$(srcdir)/../../MEDMEM -I$(top_builddir)/idl \ - -I$(srcdir)/../../MEDMEM_SWIG \ - -I$(srcdir)/../../MED \ - -I$(srcdir)/../../INTERP_KERNEL \ - -I$(srcdir)/../../INTERP_KERNEL/Bases \ - -I$(srcdir)/../../INTERP_KERNEL/GaussPoints - -libMEDClientcmodule_la_LDFLAGS = ${KERNEL_LDFLAGS} -lOpUtil -lSalomeCommunication \ - ../../MEDMEM/libmedmem.la \ - ../../MEDMEM_I/libMEDMEMImpl.la \ - ../../INTERP_KERNEL/libinterpkernel.la \ - ../../MED/libMEDEngine.la - -_libMEDClient_la_CPPFLAGS = $(libMEDClientcmodule_la_CPPFLAGS) -_libMEDClient_la_LDFLAGS = $(PYTHON_LIBS) -module $(libMEDClientcmodule_la_LDFLAGS) -_libMEDClient_la_LIBADD = libMEDClientcmodule.la - -SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../../MedCorba_Swig -I$(srcdir)/../../MEDMEM_SWIG -SWIG_DEP = $(srcdir)/../../MedCorba_Swig/libMedCorba_Swig.i $(srcdir)/../../MEDMEM_SWIG/libMEDMEM_Swig.i - -libMEDClient.py: libMEDClient_wrap.cxx - -libMEDClient_wrap.cxx: $(SWIG_DEF) $(SWIG_DEP) - $(SWIG) $(SWIG_FLAGS) -o $@ $(SWIG_DEF) - -CLEANFILES = libMEDClient.py libMEDClient_wrap.cxx - -OBSOLETE_FILES = \ - FIELDDOUBLEClient.cxx \ - FIELDDOUBLEClient.hxx \ - FIELDINTClient.cxx \ - FIELDINTClient.hxx \ - MakefileForTest \ - MemorySpy.cxx \ - MemorySpy.hxx \ - README_medclient_test \ - TESTMEDCLIENT_Gen.idl \ - TESTMEDCLIENT_Gen_i.cxx \ - TESTMEDCLIENT_Gen_i.hxx \ - create_mesh_c2q4.c \ - create_mesh_c2t3.c \ - create_mesh_c3h8.c \ - create_mesh_c3t4.c \ - test_medclient.py - -EXTRA_DIST += $(OBSOLETE_FILES) diff --git a/src/MedClient/src/MakefileForTest b/src/MedClient/src/MakefileForTest deleted file mode 100644 index e5da7d30e..000000000 --- a/src/MedClient/src/MakefileForTest +++ /dev/null @@ -1,73 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -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/med/$@ - 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 deleted file mode 100644 index d719b7b7e..000000000 --- a/src/MedClient/src/MemorySpy.cxx +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "MemorySpy.hxx" - -#if defined(PCLINUX) || defined(PCLINUX64) || defined(PCLINUX64_32) -#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 deleted file mode 100644 index 54558d1d3..000000000 --- a/src/MedClient/src/MemorySpy.hxx +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef __MEMORYSPY_HXX__ -#define __MEMORYSPY_HXX__ - -#include -#include - -class MemorySpy -{ -public: - MemorySpy(); - ~MemorySpy(); - long getCurrentMemoryUsage(); -#if defined(PCLINUX) || defined(PCLINUX64) || defined(PCLINUX64_32) - //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 deleted file mode 100644 index f6a0956f4..000000000 --- a/src/MedClient/src/README_medclient_test +++ /dev/null @@ -1,35 +0,0 @@ -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 deleted file mode 100644 index 62ec104dc..000000000 --- a/src/MedClient/src/SUPPORTClient.cxx +++ /dev/null @@ -1,209 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "Utils_CorbaException.hxx" -#include "UtilClient.hxx" -#include "SUPPORTClient.hxx" -#include "GMESHClient.hxx" -#include "ReceiverFactory.hxx" - -using namespace MEDMEM; -using namespace MED_EN; - -//============================================================================= -/*! - * Constructeur - */ -//============================================================================= - -SUPPORTClient::SUPPORTClient(const SALOME_MED::SUPPORT_ptr S, - GMESH * M) : - SUPPORT(), - IOR_Support(SALOME_MED::SUPPORT::_duplicate(S))//,_refCounter(1) -{ - SCRUTE(S); - SCRUTE(M); - if(M) - { - _mesh=M; - _mesh->addReference(); - } - else - { - SALOME_MED::GMESH_var ior_mesh=IOR_Support->getMesh(); - _mesh=new GMESHClient(ior_mesh); - } - blankCopy(); -} -//============================================================================= -/*! - * Remplit les informations générales - */ -//============================================================================= -void SUPPORTClient::blankCopy() -{ - try - { - SALOME_MED::SUPPORT::supportInfos_var all = IOR_Support->getSupportGlobal(); - - _name = all->name; - _description = all->description; - setAll(all->isOnAllElements); - setEntity(all->entity); -// modifs PN - setNumberOfGeometricType(all->numberOfGeometricType); - convertCorbaArray2(_geometricType, _numberOfGeometricType, all->types); - - SCRUTE(_name); - SCRUTE(_description); - - int *nE = new int[_numberOfGeometricType]; - int i; - for (i=0; i<_numberOfGeometricType; i++) - { - nE[i] = all->nbEltTypes[i]; - } - setNumberOfElements(nE); - - delete [] nE; - - SCRUTE(_totalNumberOfElements); - _complete_support = false; - } - catch( const CORBA::Exception &ex ) - { - MESSAGE("Erreur CORBA dans la communication" ) ; - THROW_SALOME_CORBA_EXCEPTION("No associated Support", \ - SALOME::INTERNAL_ERROR); - } -} -//============================================================================= -/*! - * - */ -//============================================================================= -void SUPPORTClient::fillCopy() -{ - if (!_complete_support) { - if(!_isOnAllElts) { - const int * index, * value; - long n_index, n_value; - - SALOME::SenderInt_var senderForValue=IOR_Support->getSenderForNumber(MED_ALL_ELEMENTS); - value=(const int *)ReceiverFactory::getValue(senderForValue,n_value); - SALOME::SenderInt_var senderForIndex=IOR_Support->getSenderForNumberIndex(); - index=(const int *)ReceiverFactory::getValue(senderForIndex,n_index); - - SCRUTE(n_index); - SCRUTE(n_value); - setNumber(index, value,true); - } - _complete_support = true; - } -} -//============================================================================= -/*! - * Destructeur - */ -//============================================================================= -SUPPORTClient::~SUPPORTClient() -{ - IOR_Support->UnRegister(); - if(_mesh) - _mesh->removeReference(); -} - -//============================================================================= -/*! - * Destructeur - */ -//============================================================================= -MEDSKYLINEARRAY * SUPPORTClient::getnumber() const throw (MEDEXCEPTION) -{ - if (!_complete_support) (const_cast(this))->fillCopy(); - MEDSKYLINEARRAY *m = SUPPORT::getnumber(); - - return m; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -const int * SUPPORTClient::getNumber(medGeometryElement GeometricType) - const throw (MEDEXCEPTION) -{ - if (!_complete_support) (const_cast(this))->fillCopy(); - const int *n = SUPPORT::getNumber(GeometricType); - - return n; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -const int * SUPPORTClient::getNumberIndex() const throw (MEDEXCEPTION) -{ - if (!_complete_support) (const_cast(this))->fillCopy(); - const int * n = SUPPORT::getNumberIndex(); - - return n; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -int SUPPORTClient::getValIndFromGlobalNumber(const int number) const throw (MEDEXCEPTION) -{ - if (!_complete_support) (const_cast(this))->fillCopy(); - const int n = SUPPORT::getValIndFromGlobalNumber(number); - - return n; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -/*void SUPPORTClient::addReference() const -{ - _refCounter++; -}*/ - -//============================================================================= -/*! - * - */ -//============================================================================= -/*void SUPPORTClient::removeReference() const -{ - if (--_refCounter <= 0) - { - delete this; - } -}*/ diff --git a/src/MedClient/src/SUPPORTClient.hxx b/src/MedClient/src/SUPPORTClient.hxx deleted file mode 100644 index bfdf51ee7..000000000 --- a/src/MedClient/src/SUPPORTClient.hxx +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _SUPPORTCLIENT_HXX -#define _SUPPORTCLIENT_HXX - -#include -#include -#include "MEDClient.hxx" -#include "MEDMEM_Support.hxx" -#include CORBA_CLIENT_HEADER(MED) - - -namespace MEDMEM { -class MEDCLIENT_EXPORT SUPPORTClient : virtual public SUPPORT { - -private : - - const SALOME_MED::SUPPORT_var IOR_Support; - - mutable bool _complete_support; - -// mutable int _refCounter; - -protected: - - virtual ~SUPPORTClient(); - -public : - - SUPPORTClient(const SALOME_MED::SUPPORT_ptr S, - GMESH * M = NULL); - - void blankCopy(); - void fillCopy(); - - MEDSKYLINEARRAY * getnumber() - const throw (MEDEXCEPTION); - const int * getNumber(MED_EN::medGeometryElement GeometricType) - const throw (MEDEXCEPTION); - const int * getNumberIndex() - const throw (MEDEXCEPTION); - int getValIndFromGlobalNumber(const int number) - const throw (MEDEXCEPTION); -// void addReference() const; -// void removeReference() const; -}; -} - - -#endif - diff --git a/src/MedClient/src/TESTMEDCLIENT_Gen.idl b/src/MedClient/src/TESTMEDCLIENT_Gen.idl deleted file mode 100644 index 270747dfc..000000000 --- a/src/MedClient/src/TESTMEDCLIENT_Gen.idl +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#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 deleted file mode 100755 index 950724abc..000000000 --- a/src/MedClient/src/TESTMEDCLIENT_Gen_i.cxx +++ /dev/null @@ -1,196 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#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 deleted file mode 100644 index 23d5e17c0..000000000 --- a/src/MedClient/src/TESTMEDCLIENT_Gen_i.hxx +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#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/UtilClient.hxx b/src/MedClient/src/UtilClient.hxx deleted file mode 100644 index efbee2d3f..000000000 --- a/src/MedClient/src/UtilClient.hxx +++ /dev/null @@ -1,152 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef UTILCLIENT_HXX_ -#define UTILCLIENT_HXX_ - -#include -#include -#include "MEDMEM_PointerOf.hxx" - -namespace MEDMEM { -template -inline void convertCorbaArray (TLocal * & T, Tint &nT, const TCorbaSeq & S) -{ - Tint i, n = S->length(); - - nT = n; - T = n > 0 ? new TLocal[n] : NULL; - - for (i=0; i -inline void convertCorbaArray2 (TLocal& tab, Tint &nT, const TCorbaSeq s) -{ - Tint i, n = s.length(); - - nT = n; - tab.set(n); - for (i=0; i -inline void convertCorbaArray (TLocal * & T, long &nT, const TCorbaSeq & S, - void *f) -{ - int i, n = S->length(); - SCRUTE(n); - - nT = n; - T = n > 0 ? new TLocal[n] : NULL; - - typedef TLocal (*pfn) (const TCorba &T); - - pfn convert = pfn(f); - for (i=0; i -inline void convertCorbaArray (std::vector & T, int &nT, - const TCorbaSeq & S) -{ - int i, n = S->length(); - SCRUTE(n); - - nT = n; - T.resize(nT); - - for (i=0; i -inline void convertCorbaArray (std::vector & T, int &nT, - const TCorbaSeq & S, - void *f) -{ - int i, n = S->length(); - SCRUTE(n); - - nT = n; - T.resize(nT); - - typedef TLocal (*pfn) (const TCorba &T); - - pfn convert = pfn(f); - for (i=0; i -inline void convertCorbaArray (std::vector & T, - const TCorbaSeq & S, - void *f, TInfo M) -{ - int i, n = S->length(); - SCRUTE(n); - - int nT = n; - T.resize(nT); - - typedef TLocal (*pfn) (const TCorba & , TInfo); - - pfn convert = pfn(f); - for (i=0; i -#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, WRONLY, 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, WRONLY, 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 deleted file mode 100644 index c5c490828..000000000 --- a/src/MedClient/src/create_mesh_c2t3.c +++ /dev/null @@ -1,363 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - 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, WRONLY, 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, WRONLY, 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 deleted file mode 100644 index d1cd2ff43..000000000 --- a/src/MedClient/src/create_mesh_c3h8.c +++ /dev/null @@ -1,380 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - 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, WRONLY, 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, WRONLY, 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 deleted file mode 100644 index 2820fa94b..000000000 --- a/src/MedClient/src/create_mesh_c3t4.c +++ /dev/null @@ -1,431 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -/* - 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, WRONLY, 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, WRONLY, 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 deleted file mode 100644 index 48523add3..000000000 --- a/src/MedClient/src/libMEDClient.i +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module libMEDClient - -%{ -#include "GMESHClient.hxx" -#include "MESHClient.hxx" -#include "SUPPORTClient.hxx" -#include "FIELDClient.hxx" -#include CORBA_CLIENT_HEADER(MED) - - using namespace MEDMEM; - using namespace MED_EN; -%} - -%typemap(in) MESH* { - if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor, 0)) == -1) { - MESHClient *client; - if ((SWIG_ConvertPtr($input, (void **) &client, $descriptor(MESHClient *), 0)) == -1) { - SWIG_Python_TypeError("MESH* or MESHClient*", $input); - return NULL; - } - $1 = (MESH *) client; - } -} - -%include "libMedCorba_Swig.i" -%include "libMEDMEM_Swig.i" - -%typecheck(SWIG_TYPECHECK_POINTER) SALOME_MED::FIELDDOUBLE_ptr, SALOME_MED::FIELDINT_ptr -{ - $1 = ($input != 0); -} - -/* - managing C++ exception in the Python API -*/ -/*%exception -{ - class PyAllowThreadsGuard { - public: - PyAllowThreadsGuard() { _save = PyEval_SaveThread(); } - ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); } - private: - PyThreadState *_save; - }; - - PyAllowThreadsGuard guard; - - $action -}*/ - -class GMESHClient : public GMESH { - - public: - - GMESHClient(const SALOME_MED::GMESH_ptr m); - - void blankCopy(); - void fillCopy(); - %extend { - ~GMESHClient(){ - self->removeReference(); - } - } -}; - -class MESHClient : public MESH { - - public: - - MESHClient(const SALOME_MED::MESH_ptr m); - - void blankCopy(); - void fillCopy(); - %extend { - ~MESHClient(){ - self->removeReference(); - } - } -}; - -MESH * getMeshPointer(MESHClient * input); -%{ - MESH * getMeshPointer(MESHClient * input) - { - return (MESH *) input; - } -%} - -class SUPPORTClient : public SUPPORT { - - public: - - SUPPORTClient(const SALOME_MED::SUPPORT_ptr S, - MESH * M = NULL); - - void blankCopy(); - void fillCopy(); - %extend { - ~SUPPORTClient() { - self->removeReference(); - } - } - -}; - -template -class FIELDClient : public FIELD -{ -public: - template - FIELDClient(U ptrCorba,MEDMEM::SUPPORT * S = NULL); - ~FIELDClient(); -}; - -%template (FIELDDOUBLEClient) FIELDClient; -%template (FIELDDOUBLENOINTERLACEClient) FIELDClient; -%template (FIELDDOUBLENOINTERLACEBYTYPEClient) FIELDClient; -%template (FIELDINTClient) FIELDClient; -%template (FIELDINTNOINTERLACEClient) FIELDClient; -%template (FIELDINTNOINTERLACEBYTYPEClient) FIELDClient; - -%extend FIELDClient -{ - %template(FIELDDOUBLEClient) FIELDClient; -}; - -%extend FIELDClient -{ - %template(FIELDDOUBLENOINTERLACEClient) FIELDClient; -}; - -%extend FIELDClient -{ - %template(FIELDDOUBLENOINTERLACEBYTYPEClient) FIELDClient; -}; - -%extend FIELDClient -{ - %template(FIELDINTClient) FIELDClient; -}; - -%extend FIELDClient -{ - %template(FIELDINTNOINTERLACEClient) FIELDClient; -}; - -%extend FIELDClient -{ - %template(FIELDINTNOINTERLACEBYTYPEClient) FIELDClient; -}; - -FIELD * getDoublePointer(FIELDClient * input); - -FIELD *getDoubleNoInterlacePointer(FIELDClient * input); - -FIELD *getDoubleNoInterlaceByTypePointer(FIELDClient * input); - -FIELD * getIntPointer(FIELDClient * input); - -FIELD * getIntNoInterlacePointer(FIELDClient * input); - -FIELD * getIntNoInterlaceByTypePointer(FIELDClient * input); - -%{ - FIELD * getDoublePointer(FIELDClient * input) - { - return (FIELD *) input; - } - - FIELD *getDoubleNoInterlacePointer(FIELDClient * input) - { - return (FIELD *) input; - } - - FIELD *getDoubleNoInterlaceByTypePointer(FIELDClient * input) - { - return (FIELD *) input; - } - - FIELD * getIntPointer(FIELDClient * input) - { - return (FIELD *) input; - } - - FIELD * getIntNoInterlacePointer(FIELDClient * input) - { - return (FIELD *) input; - } - - FIELD * getIntNoInterlaceByTypePointer(FIELDClient * input) - { - return (FIELD *) input; - } -%} diff --git a/src/MedClient/src/medClient_test.py b/src/MedClient/src/medClient_test.py deleted file mode 100644 index 7f412f73c..000000000 --- a/src/MedClient/src/medClient_test.py +++ /dev/null @@ -1,331 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -#################################################################################################### -# Test the MedClient classes: mounting in Memory a .med file and using this file as a client of -# the MED component we try -#################################################################################################### -# -from libMEDClient import * - -import string - -import salome - -import SALOME_MED - -from libSALOME_Swig import * -sg = SALOMEGUI_Swig() - -def print_ord(i): - if i == 0: - return 'first' - elif i == 1: - return 'second' - elif i == 2: - return 'third' - else: - return `(i+1)`+'th' - -def changeBlankToUnderScore(stringWithBlank): - blank = ' ' - underscore = '_' - decompString = string.split(stringWithBlank,blank) - length = len(decompString) - stringWithUnderScore = decompString[0] - for i in range(1,length): - stringWithUnderScore += underscore - stringWithUnderScore += decompString[i] - return stringWithUnderScore - -def getMedObjectFromStudy(file): - objNameInStudy = "MED_OBJECT_FROM_FILE_"+file - compNameInStudy= "MED" - listOfSO = salome.myStudy.FindObjectByName(objNameInStudy,compNameInStudy) - listLength = len(listOfSO) - if (listLength == 0) : - print objNameInStudy," cannot be found in the Study under the component ",compNameInStudy - return None - elif (listLength > 1) : - print "there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy - return None - mySO = listOfSO[0] - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getMeshObjectFromStudy(meshName): - objNameInStudy = "/Med/MEDMESH/"+meshName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MESH) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getSupportObjectFromStudy(meshName,supportName): - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDMESH/MEDSUPPORTS_OF_"+meshNameStudy+"/"+supportName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.SUPPORT) - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -def getFieldObjectFromStudy(dt,it,fieldName,supportName,meshName): - type = -1 - meshNameStudy = changeBlankToUnderScore(meshName) - objNameInStudy = "/Med/MEDFIELD/"+fieldName+"/("+str(dt)+","+str(it)+")_ON_"+supportName+"_OF_"+meshNameStudy - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print objNameInStudy," cannot be found in the Study" - return -1,-1 - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - type = 0 - if (myObj == None): - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - type = 1 - if (myObj == None) : - print objNameInStudy," has been found in the Study but with the wrong type" - return myObj,type - -fileName = "cube_hexa8_quad4.med" - -#fileName = "carre_en_quad4_seg2.med" -# fileName = "polygones.med" -# fileName = "poly3D.med" - -medComp=salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -import os - -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join(filePath, "share", "salome", "resources", "med") - -filePathName = os.path.join( filePath, fileName ) - -print "Reading the .med file ",filePathName," and pushing corba objects in the SALOME study" -medComp.readStructFileWithFieldType(filePathName,salome.myStudyName) -sg.updateObjBrowser(1) - -print "getting the MED object from the study" -medObj = getMedObjectFromStudy(fileName) - -nbOfMeshes = medObj.getNumberOfMeshes() -meshNames = medObj.getMeshNames() - -print "in this med file there is(are) ",nbOfMeshes," mesh(es):" -for i in range(nbOfMeshes): - meshName = meshNames[i] - print " - the ",print_ord(i)," mesh is named ",meshName - print " getting the distant MESH object using the API of the corba object MED" - meshObj = medObj.getMeshByName(meshName) - - - - print " getting mesh information using the API of the corba object MESH but corba objects are obtained from the Study" - for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL, - SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - nbFam = meshObj.getNumberOfFamilies(entity) - nbGrp = meshObj.getNumberOfGroups(entity) - if (entity == SALOME_MED.MED_NODE): - print " this mesh has ",nbFam," Node Family(ies) and ",nbGrp," Node Group(s)" - elif (entity == SALOME_MED.MED_CELL): - print " ",nbFam," Cell Family(ies) and ",nbGrp," Cell Group(s)" - elif (entity == SALOME_MED.MED_FACE): - print " ",nbFam," Face Family(ies) and ",nbGrp," Face Group(s)" - elif (entity == SALOME_MED.MED_EDGE): - print " ",nbFam," Edge Family(ies) and ",nbGrp," Cell Group(s)" - - if nbFam > 0: - for j in range(nbFam): - familyName = (meshObj.getFamily(entity,j+1)).getName() - familyObj = getSupportObjectFromStudy(meshName,familyName) - print familyObj - - if nbGrp > 0: - for j in range(nbGrp): - groupName = (meshObj.getGroup(entity,j+1)).getName() - groupObj = getSupportObjectFromStudy(meshName,groupName) - print groupObj - - print "let's get other SUPPORT object from the Study" - for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL, - SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - - if entity == SALOME_MED.MED_NODE : - entitySupport = "MED_NOEUD" - elif entity == SALOME_MED.MED_CELL : - entitySupport = "MED_MAILLE" - elif entity == SALOME_MED.MED_FACE : - entitySuppor = "MED_FACE" - elif entity == SALOME_MED.MED_EDGE : - entitySupport = "MED_ARETE" - - supportName = "SupportOnAll_"+entitySupport - supportObj = getSupportObjectFromStudy(meshName,supportName) - - - - meshLocalCopy0 = MESHClient(meshObj) - print "\n=============== Test printing of MESHClient (bug NPAL14100) =======================" - print meshLocalCopy0 - print "============= End Test printing of MESHClient (bug NPAL14100) =======================\n\n" - - - meshLocalCopy = MESHClient(meshObj) - print " getting information from the local copy of the distant mesh" - name = meshLocalCopy.getName() - spaceDimension = meshLocalCopy.getSpaceDimension() - meshDimension = meshLocalCopy.getMeshDimension() - numberOfNodes = meshLocalCopy.getNumberOfNodes() - print " Name = ", name, " space Dim = ", spaceDimension, " mesh Dim = ", meshDimension, " Nb of Nodes = ", numberOfNodes - coordSyst = meshLocalCopy.getCoordinatesSystem() - print " The coordinates system is",coordSyst - print " The Coordinates :" - coordNames = [] - coordUnits = [] - for isd in range(spaceDimension): - coordNames.append(meshLocalCopy.getCoordinateName(isd)) - coordUnits.append(meshLocalCopy.getCoordinateUnit(isd)) - - print " names:", coordNames - print " units", coordUnits - print " values:" - coordinates = meshLocalCopy.getCoordinates(MED_FULL_INTERLACE) - for k in range(numberOfNodes): - kp1 = k+1 - print " ---- ", coordinates[k*spaceDimension:(kp1*spaceDimension)] - print "" - print " The Cell Nodal Connectivity of the Cells:" - nbTypesCell = meshLocalCopy.getNumberOfTypes(MED_CELL) - print "" - if (nbTypesCell>0): - print " The Mesh has",nbTypesCell,"Type(s) of Cell" - types = meshLocalCopy.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = meshLocalCopy.getNumberOfElements(MED_CELL,type) - print " For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = meshLocalCopy.getConnectivity(MED_NODAL,MED_CELL,MED_ALL_ELEMENTS) - index = meshLocalCopy.getConnectivityIndex(MED_NODAL,MED_CELL) - if type == MED_POLYHEDRA: - pass - else: - nbNodesPerCell = type%100 - for j in range(nbElemType): - print " Element",(j+1)," ",connectivity[ index[j]-1 : index[j+1]-1 ] - pass - pass - pass - pass - pass - -nbOfFields = medObj.getNumberOfFields() -print "in the considered .med file there is(are) ",nbOfFields," field(s):" -fieldNames = medObj.getFieldNames() -for i in range(nbOfFields): - fieldName = fieldNames[i] - nbOfIt = medObj.getFieldNumberOfIteration(fieldName) - print " - the ",print_ord(i)," field is name ",fieldName," and has ",nbOfIt," iteration(s)" - for j in range(nbOfIt): - dtitfield = medObj.getFieldIteration(fieldName,j) - dt = dtitfield[0] - it = dtitfield[1] - print " * Iteration:",dt,"Order number:",it - meshName = meshNames[0] - for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL, - SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - if entity == SALOME_MED.MED_NODE : - entitySupport = "MED_NOEUD" - elif entity == SALOME_MED.MED_CELL : - entitySupport = "MED_MAILLE" - elif entity == SALOME_MED.MED_FACE : - entitySuppor = "MED_FACE" - elif entity == SALOME_MED.MED_EDGE : - entitySupport = "MED_ARETE" - supportName = "SupportOnAll_"+entitySupport - print " getting a corba object Field from the study iteration ",dt," order number ",it," on the support ",supportName," from the mesh ",meshName - fieldObj,type = getFieldObjectFromStudy(dt,it,fieldName,supportName,meshName) - print fieldObj - - if ((fieldObj != None) and (fieldObj != -1)): - if(type == 1): - fieldTyped = FIELDDOUBLEClient(fieldObj) - elif (type == 0): - fieldTyped = FIELDINTClient(fieldObj) - - type = fieldTyped.getValueType() - print " * Iteration:",dt,"Order number:",it,"Type:",type - name = fieldTyped.getName() - desc = fieldTyped.getDescription() - nbOfComp = fieldTyped.getNumberOfComponents() - print " Field",name," : ",desc - print " Number Of Components:",nbOfComp - iterationNb = fieldTyped.getIterationNumber() - orderNb = fieldTyped.getOrderNumber() - time = fieldTyped.getTime() - print " Iteration Number",iterationNb - print " Order Number",orderNb - print " Time",time - support = fieldTyped.getSupport() - nbOf = support.getNumberOfElements(MED_ALL_ELEMENTS) - print " Values:",nbOf - for k in range(nbOf): - valueI = fieldTyped.getRow(k+1) - print " *",valueI[:nbOfComp] - - - - - - - - - - - - -print "" -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MedClient/src/testMeshAlliances.py b/src/MedClient/src/testMeshAlliances.py deleted file mode 100755 index 2577ec87f..000000000 --- a/src/MedClient/src/testMeshAlliances.py +++ /dev/null @@ -1,164 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import salome -import SALOME -import os - -from libMEDClient import * - -filePath=os.environ["MED_ROOT_DIR"] -filePath=os.path.join( filePath, "share", "salome", "resources", "med" ) - -medFiles = [] -medFiles.append("extendedtransport53_triangles.med") -medFiles.append("maillage_5_5_5.med") -medFiles.append("maillage_chemvalIV_cas1_40elts.med") -medFiles.append("Old_maillage_chemvalIV_cas1_40elts.med") - -meshNames = [] -meshNames.append("TestA3_2094_0.1_rsurf_tri") -meshNames.append("maillage_5_5_5") -meshNames.append("maillage_chemvalIV_cas1_40elts") -meshNames.append("maillage_chemvalIV_cas1_40elts") - -nbOfFiles = len(medFiles) - -med=salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -for i in range(nbOfFiles): - medFile = os.path.join( filePath, medFiles[i] ) - meshName = meshNames[i] - - - try: - meshCorba = med.readMeshInFile(medFile, salome.myStudyName,meshName) - except SALOME.SALOME_Exception, ex: - print ex.details - print ex.details.type - print ex.details.text - print ex.details.sourceFile - print ex.details.lineNumber - - raise - - print "meshName = ",meshCorba.getName() - print "mesh number of nodes", meshCorba.getNumberOfNodes() - - - - - - - meshLocalCopy = MESHClient(meshCorba) - print " getting information from the local copy of the distant mesh" - name = meshLocalCopy.getName() - spaceDimension = meshLocalCopy.getSpaceDimension() - meshDimension = meshLocalCopy.getMeshDimension() - numberOfNodes = meshLocalCopy.getNumberOfNodes() - print " Name = ", name, " space Dim = ", spaceDimension, " mesh Dim = ", meshDimension, " Nb of Nodes = ", numberOfNodes - coordSyst = meshLocalCopy.getCoordinatesSystem() - print " The coordinates system is",coordSyst - print " The Coordinates :" - coordNames = [] - coordUnits = [] - for isd in range(spaceDimension): - coordNames.append(meshLocalCopy.getCoordinateName(isd)) - coordUnits.append(meshLocalCopy.getCoordinateUnit(isd)) - - print " names:", coordNames - print " units", coordUnits - print " values:" - coordinates = meshLocalCopy.getCoordinates(MED_FULL_INTERLACE) - for k in range(numberOfNodes): - kp1 = k+1 - print " ---- ", coordinates[k*spaceDimension:(kp1*spaceDimension)] - print "" - print " The Cell Nodal Connectivity of the Cells:" - nbTypesCell = meshLocalCopy.getNumberOfTypes(MED_CELL) - print "" - if (nbTypesCell>0): - print " The Mesh has",nbTypesCell,"Type(s) of Cell" - types = meshLocalCopy.getTypes(MED_CELL) - for k in range(nbTypesCell): - type = types[k] - nbElemType = meshLocalCopy.getNumberOfElements(MED_CELL,type) - print " For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - connectivity = meshLocalCopy.getConnectivity(MED_NODAL,MED_CELL,type) - nbNodesPerCell = type%100 - for j in range(nbElemType): - print " Element",(j+1)," ",connectivity[j*nbNodesPerCell:(j+1)*nbNodesPerCell] - pass - pass - pass - - ## - ## TEST METHODS ABOUT POLY ELEMENTS ## - ## - nbTypesCellWithPoly = meshLocalCopy.getNumberOfTypesWithPoly(MED_CELL) - if (nbTypesCell == nbTypesCellWithPoly): - print "" - print " No Poly Cells in the mesh" - print "" - pass - else: - print "" - print " The Cell Nodal Connectivity of the Poly Cells:" - print "" - print " The Mesh has",nbTypesCellWithPoly-nbTypesCell,"Type(s) of Poly Cell" - types = meshLocalCopy.getTypesWithPoly(MED_CELL) - for k in range(nbTypesCellWithPoly): - type = types[k] - if type == MED_POLYGON: - nbElemType = meshLocalCopy.getNumberOfPolygons() - elif type == MED_POLYHEDRA: - nbElemType = meshLocalCopy.getNumberOfPolyhedron() - else: - continue - print "" - print " For the type:",type,"there is(are)",nbElemType,"elemnt(s)" - if type == MED_POLYGON: - connectivity = meshLocalCopy.getPolygonsConnectivity(MED_NODAL,MED_CELL) - index = meshLocalCopy.getPolygonsConnectivityIndex(MED_NODAL,MED_CELL) - for j in range(nbElemType): - print " Polygon",(j+1)," ",connectivity[ index[j]-1 : index[j+1]-1 ] - pass - pass - else: - connectivity = meshLocalCopy.getPolyhedronConnectivity(MED_NODAL) - fIndex = meshLocalCopy.getPolyhedronFacesIndex() - index = meshLocalCopy.getPolyhedronIndex(MED_NODAL) - for j in range(nbElemType): - print " Polyhedra",(j+1) - iF1, iF2 = index[ j ]-1, index[ j+1 ]-1 - for f in range( iF2 - iF1 ): - iN1, iN2 = fIndex[ iF1+f ]-1, fIndex[ iF1+f+1 ]-1 - print " Face",f+1," ",connectivity[ iN1 : iN2 ] - pass - pass - pass - pass - pass - pass - -print "END of the Pyhton script ..... Ctrl D to exit" diff --git a/src/MedClient/src/test_medclient.py b/src/MedClient/src/test_medclient.py deleted file mode 100644 index df5e5f0a4..000000000 --- a/src/MedClient/src/test_medclient.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -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) diff --git a/src/MedClient/test/CMakeLists.txt b/src/MedClient/test/CMakeLists.txt deleted file mode 100644 index 2969856da..000000000 --- a/src/MedClient/test/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -ADD_SUBDIRECTORY(environ) -ADD_SUBDIRECTORY(test1) -ADD_SUBDIRECTORY(test2) diff --git a/src/MedClient/test/Makefile.am b/src/MedClient/test/Makefile.am deleted file mode 100644 index e8853d47d..000000000 --- a/src/MedClient/test/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -dist_salomeres_DATA= \ - resources/pointe.med \ - resources/carre_en_quad4_seg2.med \ - resources/maill.0.med \ - resources/test_hydro_darcy1a_out.med - -SUBDIRS = environ test1 test2 diff --git a/src/MedClient/test/environ/CMakeLists.txt b/src/MedClient/test/environ/CMakeLists.txt deleted file mode 100644 index fb6cf2ba3..000000000 --- a/src/MedClient/test/environ/CMakeLists.txt +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -ADD_SUBDIRECTORY(csh) - -SET(MedClientTestsConfig -# runTestMedCorba - runContainer -) - -FOREACH(MedClientTestConfig ${MedClientTestsConfig}) - SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${MedClientTestConfig}.in) - SET(output ${CMAKE_CURRENT_BINARY_DIR}/${MedClientTestConfig}) - MESSAGE(STATUS "Creation of ${output}") - CONFIGURE_FILE(${input} ${output}) - INSTALL(FILES ${output} PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ DESTINATION Tests/environ/csh) -ENDFOREACH(MedClientTestConfig ${MedClientTestsConfig}) diff --git a/src/MedClient/test/environ/Makefile.am b/src/MedClient/test/environ/Makefile.am deleted file mode 100644 index 04d4dc3c6..000000000 --- a/src/MedClient/test/environ/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -SUBDIRS = csh - -nodist_purebin_SCRIPTS = runTestMedCorba - -nodist_testsenviron_SCRIPTS = runEnvironTests diff --git a/src/MedClient/test/environ/csh/CMakeLists.txt b/src/MedClient/test/environ/csh/CMakeLists.txt deleted file mode 100644 index 6ab46dbbd..000000000 --- a/src/MedClient/test/environ/csh/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -SET(MedClientTestsConfigCsh init1 init2 init3 runContainer runEnvironTests stopContainer) - -FOREACH(MedClientTestConfigCsh ${MedClientTestsConfigCsh}) - SET(input ${CMAKE_CURRENT_SOURCE_DIR}/${MedClientTestConfigCsh}.in) - SET(output ${CMAKE_CURRENT_BINARY_DIR}/${MedClientTestConfigCsh}) - MESSAGE(STATUS "Creation of ${output}") - CONFIGURE_FILE(${input} ${output} @ONLY) - INSTALL(FILES ${output} - PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ - DESTINATION Tests/environ/csh) -ENDFOREACH(MedClientTestConfigCsh ${MedClientTestsConfigCsh}) diff --git a/src/MedClient/test/environ/csh/Makefile.am b/src/MedClient/test/environ/csh/Makefile.am deleted file mode 100644 index ba33e045f..000000000 --- a/src/MedClient/test/environ/csh/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -nodist_testsenvironcsh_SCRIPTS = \ - init1 \ - init2 \ - init3 \ - runContainer \ - runEnvironTests \ - stopContainer diff --git a/src/MedClient/test/environ/csh/init1.in b/src/MedClient/test/environ/csh/init1.in deleted file mode 100644 index e13f393ab..000000000 --- a/src/MedClient/test/environ/csh/init1.in +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -cd ${KERNEL_ROOT_DIR}/bin/salome -pwd -./allkill || true -./killall python || true -./runSession -csh - diff --git a/src/MedClient/test/environ/csh/init2.in b/src/MedClient/test/environ/csh/init2.in deleted file mode 100644 index c2e76e192..000000000 --- a/src/MedClient/test/environ/csh/init2.in +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/csh -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -cd ${SALOME_BIN_TESTS} - -while ( `ps | grep omniNames > /dev/null ` ) - sleep 2 -end -sleep 2 - -./csh/runContainer TrucPy -csh diff --git a/src/MedClient/test/environ/csh/init3.in b/src/MedClient/test/environ/csh/init3.in deleted file mode 100644 index 0eb51380f..000000000 --- a/src/MedClient/test/environ/csh/init3.in +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -cd ${KERNEL_ROOT_DIR}/bin/salome -csh diff --git a/src/MedClient/test/environ/csh/runContainer.in b/src/MedClient/test/environ/csh/runContainer.in deleted file mode 100644 index 80b2e0591..000000000 --- a/src/MedClient/test/environ/csh/runContainer.in +++ /dev/null @@ -1,78 +0,0 @@ -#! /bin/csh -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -set CONTAINER_NAME=$1 - -set PYTHON_VERSION=python@PYTHON_VERSION@ - -# you must define KERNEL_ROOT_DIR and MED_ROOT_DIR (if you need it) - -setenv KERNEL_ROOT_DIR @prefix@ - -if ( ${?KERNEL_ROOT_DIR} ) then - setenv PATH ${KERNEL_ROOT_DIR}/bin/salome:${KERNEL_ROOT_DIR}/Tests:${PATH} - setenv LD_LIBRARY_PATH ${KERNEL_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${LD_LIBRARY_PATH} - setenv PYTHONPATH ${KERNEL_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${KERNEL_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH} -endif - -if ( ${?MED_ROOT_DIR} ) then - setenv PATH ${MED_ROOT_DIR}/bin/salome:${PATH} - setenv LD_LIBRARY_PATH ${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${LD_LIBRARY_PATH} - setenv PYTHONPATH ${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH} -endif - -if ( -d ${HOME}/.salome/bin ) then - setenv PATH ${HOME}/.salome/bin:${PATH} -endif - -if ( -d ${HOME}/.salome/lib ) then - setenv LD_LIBRARY_PATH ${HOME}/.salome/lib:${LD_LIBRARY_PATH} -endif - -setenv tmp /usr/tmp - -echo -./csh/stopContainer ${CONTAINER_NAME} - -switch ($?) -case 11: - echo " Start container ${CONTAINER_NAME}" - breaksw -case 12: - echo " Restart container ${CONTAINER_NAME}" - breaksw -default: - exit 0 - breaksw -endsw -echo - -set CONTAINER_TYPE = `echo ${CONTAINER_NAME} | grep 'Py$'` -echo ${?CONTAINER_TYPE} - -if ( ${?CONTAINER_TYPE} ) then - ( ${KERNEL_ROOT_DIR}/bin/salome/SALOME_ContainerPy.py ${CONTAINER_NAME} &) -else - ( ${KERNEL_ROOT_DIR}/bin/salome/SALOME_Container ${CONTAINER_NAME} & ) -endif - diff --git a/src/MedClient/test/environ/csh/runEnvironTests.in b/src/MedClient/test/environ/csh/runEnvironTests.in deleted file mode 100644 index f9fe918b5..000000000 --- a/src/MedClient/test/environ/csh/runEnvironTests.in +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# -[ -f ~/.Xresources ] && xrdb ~/.Xresources - -setenv SALOME_BIN_TESTS ${MED_ROOT_DIR}/MED/src/MedClient/test/environ - -[ -f ${SALOME_BIN_TESTS}/killEnviron ] && ${SALOME_BIN_TESTS}/killEnviron - - -set TERMINAL="konsole --caption" -set TERMINAL="xterm -vb -sl 1000 -title" - -\rm -f ${SALOME_BIN_TESTS}/killEnviron -touch ${SALOME_BIN_TESTS}/killEnviron -chmod u+x ${SALOME_BIN_TESTS}/killEnviron - -set TITRE1="Session" -set TITRE2="Container" -set TITRE3="Essais" - -setenv PATH .:${PATH} - -echo "#! /bin/sh" >> ${SALOME_BIN_TESTS}/killEnviron -${TERMINAL} ${TITRE1} -e ${SALOME_BIN_TESTS}/csh/init1 & -echo "kill -9 $! >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron -${TERMINAL} ${TITRE2} -e ${SALOME_BIN_TESTS}/csh/init2 & -echo "kill -9 $! >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron -${TERMINAL} ${TITRE3} -e ${SALOME_BIN_TESTS}/csh/init3 & -echo "kill -9 $! >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron - -echo "cd ${MED_ROOT_DIR}/bin ; ./allkill ; killall python >& /dev/null" >> ${SALOME_BIN_TESTS}/killEnviron -echo "\\rm -f ${SALOME_BIN_TESTS}/killEnviron" >> ${SALOME_BIN_TESTS}/killEnviron -chmod u+x ${SALOME_BIN_TESTS}/killEnviron diff --git a/src/MedClient/test/environ/csh/stopContainer.in b/src/MedClient/test/environ/csh/stopContainer.in deleted file mode 100644 index 852b703a8..000000000 --- a/src/MedClient/test/environ/csh/stopContainer.in +++ /dev/null @@ -1,104 +0,0 @@ -#! /bin/sh -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -EXEC_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"` - -removeTree() { - - local list - local noeud=$1 - - case $noeud in - *.dir/ | *.dir) - j=`echo $noeud | sed -e 's,^/,,' -e 's,/$,,' -` - list=`nameclt list $j 2> /dev/null` - for i in "$list" - do - [ -n "$i" ] && removeTree "$j/$i" - done - nameclt remove_context $j 2> /dev/null - ;; - *) - nameclt unbind $noeud 2> /dev/null - ;; - esac - -} - -CONTAINER_NAME="$1" -if test -z ${CONTAINER_NAME=} -then - echo "Usage : $0 " - exit -1 -fi - - -PYTHON_VERSION=python2.2 - -# you must define KERNEL_ROOT_DIR and MED_ROOT_DIR (if you need it) - -if test -n ${KERNEL_ROOT_DIR} -then - export PATH=${KERNEL_ROOT_DIR}/bin/salome:${PATH} - export LD_LIBRARY_PATH=${KERNEL_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${LD_LIBRARY_PATH} - export PYTHONPATH=${KERNEL_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${KERNEL_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH} -fi -if test -n ${MED_ROOT_DIR} -then - export PATH=${MED_ROOT_DIR}/bin/salome:${PATH} - export LD_LIBRARY_PATH=${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${LD_LIBRARY_PATH} - export PYTHONPATH=${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/${PYTHON_VERSION}/site-packages/salome:${PYTHONPATH} -fi - -if test -d ${HOME}/.salome/bin -then - export PATH=${HOME}/.salome/bin:${PATH} -fi -if test -d ${HOME}/.salome/lib -then - export LD_LIBRARY_PATH=${HOME}/.salome/lib:${LD_LIBRARY_PATH} -fi - -export tmp=/usr/tmp - -NODE=Containers.dir/${HOSTNAME}.dir/${CONTAINER_NAME} -removeTree ${NODE}.object -removeTree ${NODE}.dir/ - - -PROCESS=`ps --width 200 -f -u ${USER} | \ - grep -w ${CONTAINER_NAME} | \ - grep SALOME_Container | - awk '{print \$2}'` - - -if test -n "${PROCESS}" -then - kill -9 `echo ${PROCESS}` >& /dev/null - echo - echo " Stop container ${CONTAINER_NAME}" - echo - exit 12 -fi - -exit 11 diff --git a/src/MedClient/test/environ/runContainer.in b/src/MedClient/test/environ/runContainer.in deleted file mode 100644 index a26a3bc5d..000000000 --- a/src/MedClient/test/environ/runContainer.in +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -set xTest = 1 -test "$xTest" = 1 && goto CSH - -echo BASH -`dirname $0`/bash/runContainer $1 - -exit 0 - -CSH: - -echo CSH -set dir=`expr "x$0" : 'x\(.*\)/[^/]*' \| '.'` -${dir}/csh/runContainer $1 - - diff --git a/src/MedClient/test/environ/runEnvironTests.in b/src/MedClient/test/environ/runEnvironTests.in deleted file mode 100644 index 643a0d57b..000000000 --- a/src/MedClient/test/environ/runEnvironTests.in +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -set xTest = 1 -test "$xTest" = 1 && goto CSH - -echo BASH -`dirname $0`/bash/runEnvironTests - -exit 0 - -CSH: - -echo CSH -set dir=`expr "x$0" : 'x\(.*\)/[^/]*' \| '.'` -${dir}/csh/runEnvironTests - - diff --git a/src/MedClient/test/environ/runTestMedCorba.in b/src/MedClient/test/environ/runTestMedCorba.in deleted file mode 100644 index bdc57c59d..000000000 --- a/src/MedClient/test/environ/runTestMedCorba.in +++ /dev/null @@ -1,43 +0,0 @@ -#! /bin/bash -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -PYTHON_VERSION=python@PYTHON_VERSION@ - -if test -n $MED_ROOT_DIR -then - export PATH=$MED_ROOT_DIR/bin/salome:${PATH} - export LD_LIBRARY_PATH=$MED_ROOT_DIR/lib@LIB_LOCATION_SUFFIX@/salome${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} - export PYTHONPATH=${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/$PYTHON_VERSION/site-packages/salome:${MED_ROOT_DIR}/share/salome/resources/med:${PYTHONPATH} - # add bin, because some script are in (SALOME_SWIG) !!!! - export PYTHONPATH=${MED_ROOT_DIR}/bin/salome:${PYTHONPATH} -fi -if test -n $MED_ROOT_DIR -then - export PATH=$MED_ROOT_DIR/bin/salome:${PATH} - export LD_LIBRARY_PATH=$MED_ROOT_DIR/lib@LIB_LOCATION_SUFFIX@/salome${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} - export PYTHONPATH=${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/salome:${MED_ROOT_DIR}/lib@LIB_LOCATION_SUFFIX@/$PYTHON_VERSION/site-packages/salome:${MED_ROOT_DIR}/share/salome/resources/med:${PYTHONPATH} -fi - -mkdir -p resultats -((python $1 2>&1 1>&3 | tee resultats/$1_err) 3>&1 1>&2 | tee resultats/$1_out ) 2>&1 - diff --git a/src/MedClient/test/environ/stopContainer.in b/src/MedClient/test/environ/stopContainer.in deleted file mode 100644 index cedaed06a..000000000 --- a/src/MedClient/test/environ/stopContainer.in +++ /dev/null @@ -1,37 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -set xTest = 1 -test "$xTest" = 1 && goto CSH - -echo BASH -`dirname $0`/bash/stopContainer $1 - -exit 0 - -CSH: - -echo CSH -set dir=`expr "x$0" : 'x\(.*\)/[^/]*' \| '.'` -${dir}/csh/stopContainer $1 - - diff --git a/src/MedClient/test/resources/carre_en_quad4_seg2.med b/src/MedClient/test/resources/carre_en_quad4_seg2.med deleted file mode 100644 index a0ca945a5..000000000 Binary files a/src/MedClient/test/resources/carre_en_quad4_seg2.med and /dev/null differ diff --git a/src/MedClient/test/resources/maill.0.med b/src/MedClient/test/resources/maill.0.med deleted file mode 100644 index 4994e63a1..000000000 Binary files a/src/MedClient/test/resources/maill.0.med and /dev/null differ diff --git a/src/MedClient/test/resources/pointe.med b/src/MedClient/test/resources/pointe.med deleted file mode 100644 index 0dbc1e8fb..000000000 Binary files a/src/MedClient/test/resources/pointe.med and /dev/null differ diff --git a/src/MedClient/test/resources/test_hydro_darcy1a_out.med b/src/MedClient/test/resources/test_hydro_darcy1a_out.med deleted file mode 100644 index cca7b963f..000000000 Binary files a/src/MedClient/test/resources/test_hydro_darcy1a_out.med and /dev/null differ diff --git a/src/MedClient/test/test1/CMakeLists.txt b/src/MedClient/test/test1/CMakeLists.txt deleted file mode 100644 index f035a4d37..000000000 --- a/src/MedClient/test/test1/CMakeLists.txt +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -SET(MedClientTestsTest1 Compo1.py Compo1Py.py TestMedCorba1.py TestMedCorba2.py TestMedCorba3.py TestMedCorba4.py TestMedCorba5.py) - -INSTALL(FILES ${MedClientTestsTest1} DESTINATION ${MED_salomescript_PYTHON}) -INSTALL(FILES resources/Compo1PyCatalog.xml DESTINATION ${MED_salomeres_DATA}) diff --git a/src/MedClient/test/test1/Compo1.py b/src/MedClient/test/test1/Compo1.py deleted file mode 100644 index 27d26dc6b..000000000 --- a/src/MedClient/test/test1/Compo1.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -from libMEDMEM_Swig import * - - -class Compo1: - - def __init__(self): - print "Initialisation Compo1" - self.mesh = None - self.support = None - self.md = None - self.medFile = None - - def __del__(self): - print "destruction Compo1" - - def Initialise(self, medFile): - if ((self.medFile != medFile) | (self.md is None)): - print "fichier MED monte" - self.md = MED() - mdDriver = MED_MED_RDONLY_DRIVER(medFile, self.md) - mdDriver.open() - mdDriver.readFileStruct() - mdDriver.close() - self.mesh = None - self.support = None - self.medFile = medFile - else: - print "fichier MED deja monte" - - def Test(self): - if (self.md is None): - raise RuntimeError, 'call Initialise first' - - def Calcul1(self): - - self.Test(); - if (self.mesh is None): - self.mesh = self.md.getMesh(self.md.getMeshName(0)) - self.mesh.read() - - return self.mesh - - def Calcul2(self): - - self.Test(); - if (self.mesh is None): - self.Calcul1() - - if (self.support is None): - self.support = SUPPORT(self.mesh, "my_support", MED_CELL) - self.support.setAll(1) - - return self.support diff --git a/src/MedClient/test/test1/Compo1Py.idl b/src/MedClient/test/test1/Compo1Py.idl deleted file mode 100644 index d61b50baf..000000000 --- a/src/MedClient/test/test1/Compo1Py.idl +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#include "SALOME_Component.idl" -#include "MED.idl" - -module Engines -{ - - interface Compo1Py : Component - { - void Initialise(in string medFile); - SALOME_MED::MESH Calcul1(); - SALOME_MED::SUPPORT Calcul2(); - }; - -}; diff --git a/src/MedClient/test/test1/Compo1Py.py b/src/MedClient/test/test1/Compo1Py.py deleted file mode 100644 index 19132552f..000000000 --- a/src/MedClient/test/test1/Compo1Py.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import sys -from omniORB import CORBA, PortableServer -import CosNaming -import Compo1Py_ORB, Compo1Py_ORB__POA -from SALOME_ComponentPy import * -from libMedCorba_Swig import * - -import Compo1 - -class Compo1Py( Compo1Py_ORB__POA.Compo1Py, SALOME_ComponentPy_i): - - def __init__(self, orb, poa, contID, \ - containerName, instanceName, interfaceName): - notif = 1 - SALOME_ComponentPy_i.__init__(self, orb, poa, contID, \ - containerName, instanceName, \ - interfaceName, notif) - - self.C = Compo1.Compo1() - - print "Compo1Py_Impl::__init__" - - - def Initialise(self, medFile): - self.C.Initialise(medFile); - - def Calcul1(self): - m = self.C.Calcul1() - return createCorbaMesh(m) - - def Calcul2(self): - s = self.C.Calcul2() - return createCorbaSupport(s) - diff --git a/src/MedClient/test/test1/Makefile.am b/src/MedClient/test/test1/Makefile.am deleted file mode 100644 index 5753783a5..000000000 --- a/src/MedClient/test/test1/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -dist_salomeres_DATA = \ - resources/CatalogModuleTest.xml \ - resources/Compo1PyCatalog.xml - -dist_salomescript_DATA= \ - Compo1.py \ - Compo1Py.py \ - TestMedCorba1.py \ - TestMedCorba2.py \ - TestMedCorba3.py \ - TestMedCorba4.py \ - TestMedCorba5.py - -EXTRA_DIST += \ - Compo1Py.idl diff --git a/src/MedClient/test/test1/TestMedCorba1.py b/src/MedClient/test/test1/TestMedCorba1.py deleted file mode 100644 index dc1e215fa..000000000 --- a/src/MedClient/test/test1/TestMedCorba1.py +++ /dev/null @@ -1,102 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) -fileName = os.path.join( BASE, 'test_hydro_darcy1a_out.med' ) - -# MED Mesh read from a (local) file - -from libMEDMEM_Swig import * - -md = MED() - -mdDriver = MED_MED_RDONLY_DRIVER(fileName, md) - -mdDriver.open() -mdDriver.readFileStruct() -mdDriver.close() - -mLocal = md.getMesh(md.getMeshName(0)) -mLocal.read() - -# MED Mesh recieved from a distant component (via CORBA) - -from omniORB import CORBA -from LifeCycleCORBA import * -#CCRTfrom libSALOME_Swig import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") -C.Initialise(fileName) - -mDistant = C.Calcul1() - -# Compare local and distant copies - -def ecart(x, y): - s = 0. - if (len(x) != len(y)): - return 1. - - for i in xrange(len(x)): - s = s + abs(x[i] - y[i]); - return s - -def compare(x, y): - if (len(x) != len(y)): - return 0 - for i in xrange(len(x)): - if x[i] != y[i]: - return 0 - return 1 - -print "Name : ", mDistant.getName() -if (mLocal.getName() != mDistant.getName()): - raise RuntimeError, "MESH::getName()" - -print "SpaceDimension : ", mDistant.getSpaceDimension() -if (mLocal.getSpaceDimension() != mDistant.getSpaceDimension()): - raise RuntimeError, "MESH::getSpaceDimension()" - -print "MeshDimension : ", mDistant.getMeshDimension() -if (mLocal.getMeshDimension() != mDistant.getMeshDimension()): - raise RuntimeError, "MESH::getMeshDimension()" - -print "CoordinatesSystem : ", mDistant.getCoordinatesSystem() -if (mLocal.getCoordinatesSystem() != mDistant.getCoordinatesSystem()): - raise RuntimeError, "MESH::getCoordinatesSystem()" - -print "NumberOfNodes : ", mDistant.getNumberOfNodes() -if (mLocal.getNumberOfNodes() != mDistant.getNumberOfNodes()): - raise RuntimeError, "MESH::getNumberOfNodes()" - - -print -print "All tests passed" diff --git a/src/MedClient/test/test1/TestMedCorba2.py b/src/MedClient/test/test1/TestMedCorba2.py deleted file mode 100644 index 16d8c9e81..000000000 --- a/src/MedClient/test/test1/TestMedCorba2.py +++ /dev/null @@ -1,108 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) - -# MED Mesh read from a (local) file - -from libMEDMEM_Swig import * - -md = MED() - -mdDriver = MED_MED_RDONLY_DRIVER(fileName, md) - -mdDriver.open() -mdDriver.readFileStruct() -mdDriver.close() - -mLocal = md.getMesh(md.getMeshName(0)) -mLocal.read() - -# MED Mesh recieved from a distant component (via CORBA) - -from omniORB import CORBA -from LifeCycleCORBA import * -from libSALOME_Swig import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") -C.Initialise(fileName) - -mDistant = C.Calcul1() - -# Compare local and distant copies - -def ecart(x, y): - s = 0. - if (len(x) != len(y)): - return 1. - - for i in xrange(len(x)): - s = s + abs(x[i] - y[i]); - return s - -def compare(x, y): - if (len(x) != len(y)): - return 0 - for i in xrange(len(x)): - if x[i] != y[i]: - return 0 - return 1 - -def transpose(x, n, m): - y = range(len(x)); - for i in xrange(n): - for j in xrange(m): - y[i + j*n] = x[i*m + j]; - return y - -m = mDistant.getSpaceDimension(); -print "SpaceDimension : ", m -n = mDistant.getNumberOfNodes(); -print "NumberOfNodes : ", n - -x1 = mDistant.getCoordinates(MED_FULL_INTERLACE); -x2 = mDistant.getCoordinates(MED_NO_INTERLACE); -x3 = mDistant.getCoordinates(MED_FULL_INTERLACE); - -print "Coordinates (MED_FULL_INTERLACE) : ", x1 -print "Coordinates (MED_NO_INTERLACE) : ", x2 - -if (ecart(x1, x3) > 1e-7): - raise RuntimeError, "getCoordinates : INTERLACE" - -x4 = transpose(x1, n, m); -print "Coordinates (MED_NO_INTERLACE) : ", x4 - -if (ecart(x2, x4) > 1e-7): - raise RuntimeError, "getCoordinates : NO_INTERLACE" - -print -print "All tests passed" diff --git a/src/MedClient/test/test1/TestMedCorba3.py b/src/MedClient/test/test1/TestMedCorba3.py deleted file mode 100644 index 91940bc0c..000000000 --- a/src/MedClient/test/test1/TestMedCorba3.py +++ /dev/null @@ -1,129 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) - -# MED Mesh read from a (local) file - -from libMEDMEM_Swig import * - -md = MED() - -mdDriver = MED_MED_RDONLY_DRIVER(fileName, md) - -mdDriver.open() -mdDriver.readFileStruct() -mdDriver.close() - -mLocal = md.getMesh(md.getMeshName(0)) -mLocal.read() - -# MED Mesh recieved from a distant component (via CORBA) - -from omniORB import CORBA -from LifeCycleCORBA import * -from libSALOME_Swig import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") -C.Initialise(fileName) - -mDistant = C.Calcul1() - -# Compare local and distant copies - -def ecart(x, y): - s = 0. - if (len(x) != len(y)): - return 1. - - for i in xrange(len(x)): - s = s + abs(x[i] - y[i]); - return s - -def compare(x, y): - if (len(x) != len(y)): - return 0 - for i in xrange(len(x)): - if x[i] != y[i]: - return 0 - return 1 - -print "Name : ", mDistant.getName() -if (mLocal.getName() != mDistant.getName()): - raise RuntimeError, "MESH::getName()" - -print "SpaceDimension : ", mDistant.getSpaceDimension() -if (mLocal.getSpaceDimension() != mDistant.getSpaceDimension()): - raise RuntimeError, "MESH::getSpaceDimension()" - -print "MeshDimension : ", mDistant.getMeshDimension() -if (mLocal.getMeshDimension() != mDistant.getMeshDimension()): - raise RuntimeError, "MESH::getMeshDimension()" - -print "CoordinatesSystem : ", mDistant.getCoordinatesSystem() -if (mLocal.getCoordinatesSystem() != mDistant.getCoordinatesSystem()): - raise RuntimeError, "MESH::getCoordinatesSystem()" - -print "NumberOfNodes : ", mDistant.getNumberOfNodes() -if (mLocal.getNumberOfNodes() != mDistant.getNumberOfNodes()): - raise RuntimeError, "MESH::getNumberOfNodes()" - -x1 = mLocal.getCoordinates(MED_FULL_INTERLACE); -x2 = mDistant.getCoordinates(MED_FULL_INTERLACE); - -print "Coordinates (local) : ", x1 -print "Coordinates (distant) : ", x2 - -d = ecart(x1, x2); -print " (differences between local and distant) : ", d -if (d > 1.0e-7): - raise RuntimeError, "MESH::getCoordinates()" - -s1 = mLocal.getCoordinatesNames(); -s2 = mDistant.getCoordinatesNames(); -print "CoordinatesNames (local) : ", s1 -print "CoordinatesNames (distant) : ", s2 - -if (not compare(s1, s2)): - raise RuntimeError, "MESH::CoordinatesNames()" - -s1 = mLocal.getCoordinatesUnits(); -s2 = mDistant.getCoordinatesUnits(); -print "CoordinatesUnits (local) : ", s1 -print "CoordinatesUnits (distant) : ", s2 - -if (not compare(s1, s2)): - raise RuntimeError, "MESH::CoordinatesUnits()" - - - -print -print "All tests passed" diff --git a/src/MedClient/test/test1/TestMedCorba4.py b/src/MedClient/test/test1/TestMedCorba4.py deleted file mode 100644 index 387df2768..000000000 --- a/src/MedClient/test/test1/TestMedCorba4.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) - -# MED Mesh read from a (local) file - -from libMEDMEM_Swig import * - -md = MED() - -mdDriver = MED_MED_RDONLY_DRIVER(fileName, md) - -mdDriver.open() -mdDriver.readFileStruct() -mdDriver.close() - -mLocal = md.getMesh(md.getMeshName(0)) -mLocal.read() - -# MED Mesh recieved from a distant component (via CORBA) - -from omniORB import CORBA -from LifeCycleCORBA import * -from libSALOME_Swig import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") -C.Initialise(fileName) - -mDistant = C.Calcul1() - - -print "Name : ", mDistant.getName() - - -for i in [MED_CELL, - MED_FACE, - MED_EDGE, - MED_NODE, - MED_ALL_ENTITIES ]: - - n1 = mLocal.getNumberOfTypes(i); - n2 = mDistant.getNumberOfTypes(i); - - if (n1 != n2): - raise RuntimeError, "MESH::getNumberOfTypes()" - - if ((n1 > 0) & (i != MED_NODE)): - T1 = mLocal.getTypes(i); - T2 = mDistant.getTypes(i); - print "types (local) : ", i, " : ", T1; - print "types (distant) : ", i, " : ", T2; - - if (n2 != len(T2)): - raise RuntimeError, \ - "len(MESH::getTypes()) <> MESH::getNumberOfTypes()" - - for j in range(n2): - if (T1[j] != eval(T2[j].__str__())): - raise RuntimeError, "MESH::getTypes()" - - e1 = mLocal.getNumberOfElements(i, T1[j]); - e2 = mDistant.getNumberOfElements(i, T2[j]); - - print "elements (local) : ", T1[j], " : ", e1; - print "elements (distant) : ", T2[j], " : ", e2; - - if (e1 != e2): - raise RuntimeError, "MESH::getNumberOfElements" - -print -print "All tests passed" diff --git a/src/MedClient/test/test1/TestMedCorba5.py b/src/MedClient/test/test1/TestMedCorba5.py deleted file mode 100644 index 7710c6f99..000000000 --- a/src/MedClient/test/test1/TestMedCorba5.py +++ /dev/null @@ -1,109 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) - - -def compare(x, y): - if (len(x) != len(y)): - return 0 - for i in xrange(len(x)): - if x[i] != y[i]: - return 0 - return 1 - -# MED Mesh read from a (local) file - -from libMEDMEM_Swig import * - -md = MED() - -mdDriver = MED_MED_RDONLY_DRIVER(fileName, md) - -mdDriver.open() -mdDriver.readFileStruct() -mdDriver.close() - -mLocal = md.getMesh(md.getMeshName(0)) -mLocal.read() - -# MED Mesh recieved from a distant component (via CORBA) - -from omniORB import CORBA -from LifeCycleCORBA import * -from libSALOME_Swig import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") -C.Initialise(fileName) - -mDistant = C.Calcul1() - - -print "Name : ", mDistant.getName() - - -for i in [MED_CELL, - MED_FACE, - MED_EDGE, - MED_NODE, - MED_ALL_ENTITIES ]: - - n1 = mLocal.getNumberOfTypes(i); - n2 = mDistant.getNumberOfTypes(i); - - if (n1 != n2): - raise RuntimeError, "MESH::getNumberOfTypes()" - - if ((n1 > 0) & (i != MED_NODE)): - T1 = mLocal.getTypes(i); - T2 = mDistant.getTypes(i); - - if (n2 != len(T2)): - raise RuntimeError, \ - "len(MESH::getTypes()) <> MESH::getNumberOfTypes()" - - for j in range(n2): - if (T1[j] != T2[j]): - raise RuntimeError, "MESH::getTypes()" - - c1 = mLocal.getConnectivity(MED_FULL_INTERLACE, MED_NODAL, \ - i, T1[j]); - c2 = mDistant.getConnectivity(MED_FULL_INTERLACE, MED_NODAL, \ - i, T2[j]); - - print "connectivity (local) : ", T1[j], " : ", c1; - print "connectivity (distant) : ", T2[j], " : ", c2; - - if (compare(c1, c2) == 0): - raise RuntimeError, "MESH::getConnectivity()" - -print -print "All tests passed" diff --git a/src/MedClient/test/test1/resources/CatalogModuleTest.xml b/src/MedClient/test/test1/resources/CatalogModuleTest.xml deleted file mode 100644 index 3c11f0428..000000000 --- a/src/MedClient/test/test1/resources/CatalogModuleTest.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - - - - - - - - - - - - - - Compo1Py - Solver - RASCLE - 1.0 - Essai Aster - 1 - ModuleASTER.png - hostname = localhost - - - diff --git a/src/MedClient/test/test1/resources/Compo1PyCatalog.xml b/src/MedClient/test/test1/resources/Compo1PyCatalog.xml deleted file mode 100644 index ad389f8ff..000000000 --- a/src/MedClient/test/test1/resources/Compo1PyCatalog.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - - - - - - Compo1Py - Compo1Py - OTHER - tajchman - 1.3.0 - unknown - 1 - - - - Compo1Py - unknown - - - Initialise - tajchman - 1.3.0 - unknown - 0 - - - string - medFile - unknown - - - - - - Calcul1 - tajchman - 1.3.0 - unknown - 0 - - - - MESH - return - unknown - - - - - Calcul2 - tajchman - 1.3.0 - unknown - 0 - - - - SUPPORT - return - unknown - - - - - - - - diff --git a/src/MedClient/test/test2/CMakeLists.txt b/src/MedClient/test/test2/CMakeLists.txt deleted file mode 100644 index 33985580e..000000000 --- a/src/MedClient/test/test2/CMakeLists.txt +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -INCLUDE(${SALOME_MACROS_DIR}/InstallAndCompilePythonFile.cmake) -FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(${SWIG_USE_FILE}) - -INCLUDE_DIRECTORIES( - ${PYTHON_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIRS} - ${OMNIORB_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${XDR_INCLUDE_DIRS} - ${KERNEL_ROOT_DIR}/include/salome - ${CMAKE_CURRENT_BINARY_DIR}/../../../../idl - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../../src - ${CMAKE_CURRENT_SOURCE_DIR}/../../../MED - ${CMAKE_CURRENT_SOURCE_DIR}/../../../MEDMEM_I - ${CMAKE_CURRENT_SOURCE_DIR}/../../../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../../../MEDMEM_SWIG - ${CMAKE_CURRENT_SOURCE_DIR}/../../../MedCorba_Swig - ${CMAKE_CURRENT_SOURCE_DIR}/../../../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../../../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../../../INTERP_KERNEL/GaussPoints - ) - -SET_SOURCE_FILES_PROPERTIES(libCompo2.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(libCompo2.i PROPERTIES SWIG_DEFINITIONS "-shadow") - -SWIG_ADD_MODULE(libCompo2 python libCompo2.i Compo2.cxx) -SWIG_LINK_LIBRARIES(libCompo2 ${PYTHON_LIBS} MEDClientcmodule) -SET_TARGET_PROPERTIES(_libCompo2 PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS} ${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") - -IF(${MACHINE} STREQUAL WINDOWS) - SET_TARGET_PROPERTIES(_libCompo2 PROPERTIES DEBUG_OUTPUT_NAME _libCompo2_d) -ENDIF(${MACHINE} STREQUAL WINDOWS) - -INSTALL(TARGETS _libCompo2 DESTINATION ${MED_salomepythondir}) -INSTALL_AND_COMPILE_PYTHON_FILE(${CMAKE_CURRENT_BINARY_DIR}/libCompo2.py ${MED_salomescript_PYTHON}) - -FILE(GLOB libCompo2_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx") -INSTALL(FILES ${libCompo2_HEADERS_HXX} DESTINATION ${MED_salomeinclude_HEADERS}) diff --git a/src/MedClient/test/test2/Compo2.cxx b/src/MedClient/test/test2/Compo2.cxx deleted file mode 100644 index 296d4c3e6..000000000 --- a/src/MedClient/test/test2/Compo2.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -#ifndef _DEBUG_ -#define _DEBUG_ -#endif - -#include "Compo2.hxx" -#include -#include -#include - -using namespace MEDMEM; -using namespace MED_EN; - -Compo2::Compo2() : _F(NULL) -{ -} - -Compo2::~Compo2() -{ - if (_F) delete _F; -} - -std::string Compo2::Calcul(const MESH &M) -{ - const char* LOC = "std::string Compo2::Calcul(MESH &M)"; - BEGIN_OF(LOC); - - MESSAGE("type virtuel : MESH"); - MESSAGE("type reel : " << typeid(M).name()); - - std::string name = M.getName(); - - name += " recu"; - - try { - std::cerr << M << std::endl; - } - catch (...) { - std::cerr << "erreur Compo2::Calcul" << std::endl; - } - - END_OF(LOC); - return name; -} - -const FAMILY * Compo2::Calcul2(const MESH &M) -{ - const char* LOC = "const FAMILY * Compo2::Calcul2(const MESH &M)"; - BEGIN_OF(LOC); - - const FAMILY * F = M.getFamily(MED_CELL, 1); - std::cerr << "ok ici 2" << std::endl; - try { - std::cout << F << std::endl; - } - catch (...) { - std::cerr << "erreur Compo2::Calcul2" << std::endl; - } - - END_OF(LOC); - return F; -} - -void Compo2::Calcul3(const FIELD &F) -{ - const char* LOC = "void Compo2::Calcul3(const FIELD *)"; - BEGIN_OF(LOC); - - const double *v = F.getValue(); - long i, n = F.getSupport()->getNumberOfElements(MED_CELL); - int j, m = F.getNumberOfComponents(); - - for (i=0; i * _F; - -public: - Compo2(); - ~Compo2(); - - std::string Calcul(const MEDMEM::MESH &M); - const MEDMEM::FAMILY * Calcul2(const MEDMEM::MESH &M); - void Calcul3(const MEDMEM::FIELD &S); -}; - -#endif diff --git a/src/MedClient/test/test2/Makefile.am b/src/MedClient/test/test2/Makefile.am deleted file mode 100644 index 3702db464..000000000 --- a/src/MedClient/test/test2/Makefile.am +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedClient : tool to transfer MED CORBA from server producer of MED object to a client using those MED object -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -if MED_SWIG_1_3_21 -SWIG_DEF = libCompo2.i dummy.i - -dummy_wrap.cxx: libCompo2_wrap.cxx - sed -e 's/SwigValueWrapper< vector >/vector/g' libCompo2_wrap.cxx > toto - mv toto libCompo2_wrap.cxx - sed -e 's/SwigValueWrapper< vector const >/vector/g' libCompo2_wrap.cxx > toto - mv toto libCompo2_wrap.cxx - touch dummy_wrap.cxx -else !MED_SWIG_1_3_21 -SWIG_DEF = libCompo2.i -endif - -dist_salomescript_DATA = \ - TestMedCorba6.py \ - TestMedCorba7.py \ - TestMedCorba8.py -nodist_salomescript_DATA = \ - libCompo2.py - -# Libraries targets -lib_LTLIBRARIES = _libCompo2.la - -dist__libCompo2_la_SOURCES = Compo2.hxx Compo2.cxx libCompo2.i -nodist__libCompo2_la_SOURCES = libCompo2_wrap.cxx - -_libCompo2_la_CPPFLAGS = $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \ - ${MED3_INCLUDES} ${HDF5_INCLUDES} ${PYTHON_INCLUDES} ${KERNEL_CXXFLAGS} \ - -I$(srcdir)/../../../MEDMEM_I -I$(srcdir)/../../../MEDMEM -I$(top_builddir)/idl \ - -I$(srcdir)/../../../MEDWrapper/V2_1/Core -I$(srcdir)/../../../MEDMEM_SWIG -I$(srcdir)/../../../MED -I$(srcdir)/../../src \ - -I$(srcdir)/../../../INTERP_KERNEL -I$(srcdir)/../../../INTERP_KERNEL/Bases \ - -I$(srcdir)/../../../INTERP_KERNEL/GaussPoints -_libCompo2_la_LDFLAGS = ${PYTHON_LIBS} -module ${KERNEL_LDFLAGS} ${MED3_LIBS_C_ONLY} ${HDF5_LIBS} \ - ../../../MEDMEM/libmedmem.la ../../../MEDMEM_I/libMEDMEMImpl.la ../../../INTERP_KERNEL/libinterpkernel.la \ - ../../../MED/libMEDEngine.la ../../src/libMEDClientcmodule.la - -SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../../src -I$(srcdir)/../../../MEDMEM_SWIG -I$(srcdir)/../../../MedCorba_Swig -SWIG_DEP = ../../src/libMEDClient.i ../../../MEDMEM_SWIG/libMEDMEM_Swig.i ../../../MedCorba_Swig/libMedCorba_Swig.i - -libCompo2.py: libCompo2_wrap.cxx - -libCompo2_wrap.cxx: $(SWIG_DEF) - $(SWIG) $(SWIG_FLAGS) -o $@ $< - -CLEANFILES = libCompo2_wrap.cxx libCompo2.py diff --git a/src/MedClient/test/test2/TestMedCorba6.py b/src/MedClient/test/test2/TestMedCorba6.py deleted file mode 100644 index a7458fd8b..000000000 --- a/src/MedClient/test/test2/TestMedCorba6.py +++ /dev/null @@ -1,93 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os - -## ne fonctionne pas ? -## import salome - -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) - - -def compare(x, y): - if (len(x) != len(y)): - return 0 - for i in xrange(len(x)): - if x[i] != y[i]: - return 0 - return 1 - -# MED Mesh read from a (local) file - -from libMEDMEM_Swig import * - -md = MED() - -mdDriver = MED_MED_RDONLY_DRIVER(fileName, md) - -mdDriver.open() -mdDriver.readFileStruct() -mdDriver.close() - -mLocal = md.getMesh(md.getMeshName(0)) -mLocal.read() - -# MED Mesh received from a distant component (via CORBA) - -from omniORB import CORBA -from LifeCycleCORBA import * -from libSALOME_Swig import * -from libMEDClient import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") -C.Initialise(fileName) - -mDistant = C.Calcul1() -mDistantCopy = MESHClient(mDistant) - -from libCompo2 import * -C2 = Compo2() - -print "Local ", C2.Calcul(mLocal) -print "DistantCopy ", C2.Calcul(mDistantCopy) - -testDistant = 0; -try: - print "Distant ", C2.Calcul(mDistant) -except: - print "an exception has been received, it's the normal behaviour" - testDistant = 1 - -if (testDistant == 0): - raise RuntimeError, "no exception has been received, test failed" - - -print -print "All tests passed" diff --git a/src/MedClient/test/test2/TestMedCorba7.py b/src/MedClient/test/test2/TestMedCorba7.py deleted file mode 100644 index b53b0586a..000000000 --- a/src/MedClient/test/test2/TestMedCorba7.py +++ /dev/null @@ -1,100 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os - -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'test_hydro_darcy1a_out.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) - -def compare(x, y): - if (len(x) != len(y)): - return 0 - for i in xrange(len(x)): - if x[i] != y[i]: - return 0 - return 1 - -# MED Mesh read from a (local) file - -from libMEDMEM_Swig import * - -md = MED() - -mdDriver = MED_MED_RDONLY_DRIVER(fileName, md) - -mdDriver.open() -mdDriver.readFileStruct() -mdDriver.close() - -mLocal = md.getMesh(md.getMeshName(0)) -mLocal.read() - -# MED Mesh received from a distant component (via CORBA) - -from omniORB import CORBA -from LifeCycleCORBA import * -from libSALOME_Swig import * -from libMEDClient import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") -C.Initialise(fileName) - -mDistant = C.Calcul1() -mDistantCopy = MESHClient(mDistant) - -from libCompo2 import * -C2 = Compo2() - -for i in xrange(10): - print "-" - -print "Local " -print C2.Calcul(mLocal) - -for i in xrange(10): - print "-" - -print "DistantCopy " -s = C2.Calcul(mDistantCopy) -print - -##print "ok ici" -##for i in xrange(10): -## print "-" - -##try: -## sDistant = C.Calcul2() -##except: -## print "erreur" - -##sDistantCopy = SUPPORTClient(sDistant) -##print sDistant -print -print "All tests passed" diff --git a/src/MedClient/test/test2/TestMedCorba8.py b/src/MedClient/test/test2/TestMedCorba8.py deleted file mode 100644 index 6bcd03f65..000000000 --- a/src/MedClient/test/test2/TestMedCorba8.py +++ /dev/null @@ -1,63 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -import os - -# import salome - -BASE = os.environ["MED_ROOT_DIR"] -BASE = os.path.join( BASE, 'share', 'salome', 'resources', 'med' ) - -fileName = os.path.join( BASE, 'pointe.med' ) -fileName = os.path.join( BASE, 'test_hydro_darcy1a_out.med' ) -fileName = os.path.join( BASE, 'carre_en_quad4_seg2.med' ) - - -from omniORB import CORBA -from LifeCycleCORBA import * -from libSALOME_Swig import * -from libMEDClient import * - -orb = CORBA.ORB_init([''], CORBA.ORB_ID) -lcc = LifeCycleCORBA(orb) - -C = lcc.FindOrLoadComponent("FactoryServerPy", "Compo1Py") - -print "ok" -C.Initialise(fileName) - -mDistant = C.Calcul1() -print mDistant -mDistantCopy = MESHClient(mDistant) -print mDistantCopy - -print "###################################" -for i in xrange(10): - print mDistantCopy.getName() - -for i in xrange(1): - print "-" - - -print -print "All tests passed" diff --git a/src/MedClient/test/test2/libCompo2.i b/src/MedClient/test/test2/libCompo2.i deleted file mode 100644 index a663b1aa0..000000000 --- a/src/MedClient/test/test2/libCompo2.i +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module libCompo2 - -%{ -#include "Compo2.hxx" - - using namespace MEDMEM; - using namespace MED_EN; -%} - -%include "std_string.i" -%include "libMEDClient.i" - -%include "Compo2.hxx" diff --git a/src/MedCorba_Swig/CMakeLists.txt b/src/MedCorba_Swig/CMakeLists.txt deleted file mode 100644 index 07c1cd930..000000000 --- a/src/MedCorba_Swig/CMakeLists.txt +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (C) 2012-2013 CEA/DEN, EDF R&D -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(${SWIG_USE_FILE}) - -SET_SOURCE_FILES_PROPERTIES(libMedCorba_Swig.i PROPERTIES CPLUSPLUS ON) -SET_SOURCE_FILES_PROPERTIES(libMedCorba_Swig.i PROPERTIES SWIG_DEFINITIONS "-shadow") - -INCLUDE_DIRECTORIES( - ${PYTHON_INCLUDE_DIRS} - ${PTHREAD_INCLUDE_DIRS} - ${OMNIORB_INCLUDE_DIRS} - ${MED3_INCLUDE_DIRS} - ${HDF5_INCLUDE_DIRS} - ${KERNEL_ROOT_DIR}/include/salome - ${CMAKE_CURRENT_BINARY_DIR}/../../idl - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/../MED - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM_I - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM - ${CMAKE_CURRENT_SOURCE_DIR}/../MEDMEM_SWIG - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases - ${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/GaussPoints - ) - -SWIG_ADD_MODULE(libMedCorba_Swig python libMedCorba_Swig.i) -SWIG_LINK_LIBRARIES(libMedCorba_Swig ${PYTHON_LIBS} MEDMEMImpl MEDEngine ${PLATFORM_LIBS}) -SET_TARGET_PROPERTIES(_libMedCorba_Swig PROPERTIES COMPILE_FLAGS "${OMNIORB_DEFINITIONS} ${HDF5_DEFINITIONS} ${MED3_DEFINITIONS} ${XDR_DEFINITIONS} ${PLATFORM_DEFINITIONS}") - -SET(MED_MedCorba_Swig_salomescript_DATA - medcorba_test.py batchmode_medcorba_test.py batchmode_medcorba_test1.py - ) - -IF(${MACHINE} STREQUAL WINDOWS) - SET_TARGET_PROPERTIES(_libMedCorba_Swig PROPERTIES DEBUG_OUTPUT_NAME _libMedCorba_Swig_d) -ENDIF(${MACHINE} STREQUAL WINDOWS) -INSTALL(TARGETS _libMedCorba_Swig DESTINATION ${MED_salomepythondir}) -INSTALL(FILES libMedCorba_Swig.i DESTINATION ${MED_salomeinclude_HEADERS}) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libMedCorba_Swig.py DESTINATION ${MED_salomescript_PYTHON}) -INSTALL(FILES ${MED_MedCorba_Swig_salomescript_DATA} DESTINATION ${MED_salomescript_DATA}) diff --git a/src/MedCorba_Swig/Makefile.am b/src/MedCorba_Swig/Makefile.am deleted file mode 100644 index e4c68579a..000000000 --- a/src/MedCorba_Swig/Makefile.am +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedCorba_Swig : binding of MED CORBA objects woth Python -# -include $(top_srcdir)/adm_local/unix/make_common_starter.am - -salomepython_PYTHON = libMedCorba_Swig.py -salomepyexec_LTLIBRARIES = _libMedCorba_Swig.la - -if MED_SWIG_1_3_21 -SWIG_DEF = libMedCorba_Swig.i dummy.i - -dummy_wrap.cxx: libMedCorba_Swig_wrap.cxx - sed -e 's/SwigValueWrapper< vector >/vector/g' libMedCorba_Swig_wrap.cxx > toto - mv toto libMedCorba_Swig_wrap.cxx - sed -e 's/SwigValueWrapper< vector const >/vector/g' libMedCorba_Swig_wrap.cxx > toto - mv toto libMedCorba_Swig_wrap.cxx - touch dummy_wrap.cxx -else !MED_SWIG_1_3_21 -SWIG_DEF = libMedCorba_Swig.i -endif - -SWIG_FLAGS = @SWIG_FLAGS@ -I$(srcdir) -I$(srcdir)/../MEDMEM_SWIG -SWIG_DEP = ../MEDMEM_SWIG/libMEDMEM_Swig.i - -dist__libMedCorba_Swig_la_SOURCES = libMedCorba_Swig.i -nodist__libMedCorba_Swig_la_SOURCES = libMedCorba_Swig_wrap.cxx -salomeinclude_HEADERS = libMedCorba_Swig.i - -libMedCorba_Swig.py: libMedCorba_Swig_wrap.cxx - -libMedCorba_Swig_wrap.cxx: $(SWIG_DEF) $(SWIG_DEP) - $(SWIG) $(SWIG_FLAGS) -o $@ $(SWIG_DEF) - -############################################################################# - -_libMedCorba_Swig_la_CPPFLAGS = $(CORBA_CXXFLAGS) $(CORBA_INCLUDES) \ - $(PYTHON_INCLUDES) $(MED3_INCLUDES) $(HDF5_INCLUDES) ${KERNEL_CXXFLAGS} \ - -I$(srcdir)/../MEDMEM_I -I$(srcdir)/../MEDMEM -I$(srcdir)/../MEDMEM_SWIG -I$(srcdir)/../MED -I$(srcdir)/../MEDWrapper/V2_1/Core \ - -I$(srcdir)/../INTERP_KERNEL -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../INTERP_KERNEL/GaussPoints -I$(top_builddir)/idl -_libMedCorba_Swig_la_LDFLAGS = -module $(PYTHON_LIBS) $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) ${KERNEL_LDFLAGS} -lSALOMELocalTrace \ - ../MEDMEM_I/libMEDMEMImpl.la ../MEDMEM/libmedmem.la ../INTERP_KERNEL/libinterpkernel.la ../MED/libMEDEngine.la -### ../MEDMEM_SWIG/_libMEDMEM_Swig.la - -dist_salomescript_DATA = medcorba_test.py batchmode_medcorba_test.py batchmode_medcorba_test1.py - -CLEANFILES = libMedCorba_Swig.py libMedCorba_Swig_wrap.cxx diff --git a/src/MedCorba_Swig/batchmode_medcorba_test.py b/src/MedCorba_Swig/batchmode_medcorba_test.py deleted file mode 100755 index 833f3f1f5..000000000 --- a/src/MedCorba_Swig/batchmode_medcorba_test.py +++ /dev/null @@ -1,325 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedCorba_Swig : binding of MED CORBA objects woth Python -# File : batchmode_medcorba_test.py -# Module : MED -# -import batchmode_salome - -import SALOME_MED - -from libMedCorba_Swig import * -from libMEDClient import * - -from random import * - -import os - -filePath = os.environ["MED_ROOT_DIR"] -filePath = os.path.join( filePath, "share", "salome", "resources", "med" ) - -#============================================================================== - -def AnalyzeField(field): - name = field.getName() - desc = field.getDescription() - nbComp = field.getNumberOfComponents() - itNum = field.getIterationNumber() - ordNum = field.getOrderNumber() - - print "Analysis of the field ",name," with the description ",desc - print "iteration number ",itNum," order Number ",ordNum - print "It has ",nbComp," component(s)" - - fieldValue = field.getValue(SALOME_MED.MED_FULL_INTERLACE) - fieldSupport = field.getSupport() - fieldMesh = fieldSupport.getMesh() - fieldEntity = fieldSupport.getEntity() - bool = fieldSupport.isOnAllElements() - - if bool: - print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName() - if fieldEntity == SALOME_MED.MED_NODE: - nbValByComp = fieldMesh.getNumberOfNodes() - else: - nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,SALOME_MED.MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - else: - print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName() - nbValByComp = fieldSupport.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - - for i in range(nbComp): - compName = field.getComponentName(i+1) - compUnit = field.getComponentUnit(i+1) - print "The ",(i+1),"-th component ",compName," with the unit ",compUnit - - for i in range(nbValByComp): - print " * ",fieldValue[i*nbComp:(i+1)*nbComp] - -#============================================================================== - -def getMeshObjectFromStudy(meshName): - objNameInStudy = "/Med/MEDMESH/"+meshName - mySO = batchmode_salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print "ERROR: ",objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MESH) - if (myObj == None) : - print "ERROR: ",objNameInStudy," has been found in the Study but with the wrong type" - return myObj - - -#============================================================================== - -def getFieldDoubleObjectFromStudy(number,subnumber): - mySO = batchmode_salome.myStudy.FindObject("MEDFIELD") - mysub = mySO.FindSubObject(number)[1] - if mysub: - mysubsub = mysub.FindSubObject(subnumber)[1] - if mysubsub: - Builder = batchmode_salome.myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - return myObj - else: - print "ERROR: No FieldDouble Object stored in this Study" - return None - else: - print "ERROR: No FieldDouble Object stored in this Study" - return None - - -#============================================================================== - -def getFieldIntObjectFromStudy(number,subnumber): - mySO = batchmode_salome.myStudy.FindObject("MEDFIELD") - mysub = mySO.FindSubObject(number)[1] - if mysub: - mysubsub = mysub.FindSubObject(subnumber)[1] - if mysubsub: - Builder = batchmode_salome.myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - return myObj - else: - print "ERROR: No FieldInt Object stored in this Study" - return None - else: - print "ERROR: No FieldInt Object stored in this Study" - return None - -#============================================================================== - -def getMedObjectFromStudy(file): - objNameInStudy = "MED_OBJECT_FROM_FILE_"+file - compNameInStudy= "MED" - listOfSO = batchmode_salome.myStudy.FindObjectByName(objNameInStudy, - compNameInStudy) - listLength = len(listOfSO) - if (listLength == 0) : - print "ERROR: ",objNameInStudy," cannot be found in the Study under the component ",compNameInStudy - return None - elif (listLength > 1) : - print "ERROR: there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy - return None - mySO = listOfSO[0] - if (mySO == None) : - print "ERROR: ",objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - if (myObj == None) : - print "ERROR: ",objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -#============================================================================== -# -# Since Corba pointeurs will be generated in this Python script -# a POA has to be registred to activate those Corba pointeurs -# and make them available by any clients (in general). In our -# case, it is to make those pointeurs avail able to itself -#============================================================================== - -print "Activation of a POA to make available any Corba pointeurs" -poa = batchmode_salome.orb.resolve_initial_references("RootPOA") -poaManager = poa._get_the_POAManager() -poaManager.activate() - -#============================================================================== - -studyCurrent = batchmode_salome.myStudyName -studyCurrentId = batchmode_salome.myStudyId - -print "We are working in the study ",studyCurrent," with the ID ",studyCurrentId -print "" - -fileName = "cube_hexa8_quad4.med" -#medFile = "carre_en_quad4_seg2.med" -medFile = os.path.join( filePath, fileName ) - -print "Loading of the Med Component" -print "" - -med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -med_comp.readStructFileWithFieldType(medFile,studyCurrent) - -med_obj = getMedObjectFromStudy(fileName) - -nbMeshes = med_obj.getNumberOfMeshes() - -nbFields = med_obj.getNumberOfFields() - -meshNames = med_obj.getMeshNames() - -print "" -print "The med file ",medFile," has ",nbMeshes," Meshe(s) and ",nbFields," Field(s)" -print "" - -meshName = meshNames[0] - -meshcorba = getMeshObjectFromStudy(meshName) - -nbNodes = meshcorba.getNumberOfNodes() - -spaceDim = meshcorba.getSpaceDimension() - -print "The mesh from the Study is ",meshName,".It is a ",spaceDim,"-D mesh and it has ",nbNodes," Nodes" -print "" - -for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL,SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - nbFam = meshcorba.getNumberOfFamilies(entity) - if (entity == SALOME_MED.MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - elif (entity == SALOME_MED.MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - elif (entity == SALOME_MED.MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - elif (entity == SALOME_MED.MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - - if nbFam > 0: - for j in range(nbFam): - print "" - familycorba = meshcorba.getFamily(entity,j+1) - familyName = familycorba.getName() - familyDescription = familycorba.getDescription() - familyEntity = familycorba.getEntity() - familyBool = familycorba.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = familycorba.getIdentifier() - nbOfAtt = familycorba.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = familycorba.getAttributesIdentifiers() - attributesvals = familycorba.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",familycorba.getAttributeDescription(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - types = familycorba.getTypes() - nbOfTypes = len(types) - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = familycorba.getNumberOfElements(type) - number = familycorba.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - lengthValue = familycorba.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS) - nbOfComp = 1 - - supportOutLocal = SUPPORTClient( familycorba ) - supportOutCorba = createCorbaSupport( supportOutLocal ) - - print "\nGenerate a Local scalar double field" - fieldScalDblLoc = createLocalFieldDouble(nbOfComp,lengthValue) - value = [ random() for k in range(lengthValue*nbOfComp) ] - fieldScalDblLoc.setValue( value ) ## the only way as field support not defined - valueIverif = fieldScalDblLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba scalar double field" - fieldScalDblLoc.setSupport( supportOutLocal ) - fieldScalDblCorba = createCorbaFieldDouble(supportOutCorba,fieldScalDblLoc) - AnalyzeField(fieldScalDblCorba) - - print "Generate a Local scalar integer field" - fieldScalIntLoc = createLocalFieldInt(nbOfComp,lengthValue) - value = [ randint(0,100) for k in range(lengthValue*nbOfComp) ] - fieldScalIntLoc.setValue( value ) ## the only way as field support not defined - valueIverif = fieldScalIntLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba scalar integer field" - fieldScalIntLoc.setSupport( supportOutLocal ) - fieldScalIntCorba = createCorbaFieldInt(supportOutCorba,fieldScalIntLoc) - AnalyzeField(fieldScalIntCorba) - - nbOfComp = spaceDim - print "\nGenerate a Local vector double field" - fieldVectDblLoc = createLocalFieldDouble(nbOfComp,lengthValue) - value = [ random() for k in range(lengthValue*nbOfComp) ] - fieldVectDblLoc.setValue(value) - valueIverif = fieldVectDblLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba vector double field" - fieldVectDblLoc.setSupport( supportOutLocal ) - fieldVectDblCorba = createCorbaFieldDouble(supportOutCorba,fieldVectDblLoc) - AnalyzeField(fieldVectDblCorba) - - print "\nGenerate a Local vector integer field" - fieldVectIntLoc = createLocalFieldInt(nbOfComp,lengthValue) - value = [ randint(0,100) for k in range(lengthValue*nbOfComp) ] - fieldVectIntLoc.setValue(value) - valueIverif = fieldVectIntLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba vector integer field" - fieldVectIntLoc.setSupport( supportOutLocal ) - fieldVectIntCorba = createCorbaFieldInt(supportOutCorba,fieldVectIntLoc) - AnalyzeField(fieldVectIntCorba) - print "" -print "Fin du script Python ...." - - diff --git a/src/MedCorba_Swig/batchmode_medcorba_test1.py b/src/MedCorba_Swig/batchmode_medcorba_test1.py deleted file mode 100644 index de8980381..000000000 --- a/src/MedCorba_Swig/batchmode_medcorba_test1.py +++ /dev/null @@ -1,180 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedCorba_Swig : binding of MED CORBA objects woth Python -# File : batchmode_medcorba_test.py -# Module : MED -# -import batchmode_salome - -import SALOME_MED - -from libMedCorba_Swig import * - -from random import * - -import os - -filePath = os.environ["MED_ROOT_DIR"] -filePath = os.path.join( filePath, "share", "salome", "resources", "med" ) - -#============================================================================== - -def AnalyzeField(field): - name = field.getName() - desc = field.getDescription() - nbComp = field.getNumberOfComponents() - itNum = field.getIterationNumber() - ordNum = field.getOrderNumber() - - print "Analysis of the field ",name," with the description ",desc - print "iteration number ",itNum," order Number ",ordNum - print "It has ",nbComp," component(s)" - - fieldValue = field.getValue(SALOME_MED.MED_FULL_INTERLACE) - fieldSupport = field.getSupport() - fieldMesh = fieldSupport.getMesh() - fieldEntity = fieldSupport.getEntity() - bool = fieldSupport.isOnAllElements() - - if bool: - print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName() - if fieldEntity == SALOME_MED.MED_NODE: - nbValByComp = fieldMesh.getNumberOfNodes() - else: - nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,SALOME_MED.MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - else: - print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName() - nbValByComp = fieldSupport.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - - for i in range(nbComp): - compName = field.getComponentName(i+1) - compUnit = field.getComponentUnit(i+1) - print "The ",(i+1),"-th component ",compName," with the unit ",compUnit - - for i in range(nbValByComp): - print " * ",fieldValue[i*nbComp:(i+1)*nbComp] - -#============================================================================== - -def getMeshObjectFromStudy(number): - mySO = batchmode_salome.myStudy.FindObject("MEDMESH") - mysub = mySO.FindSubObject(number)[1] - if mysub: - Builder = batchmode_salome.myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mysub, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MESH) - return myObj - else: - print "ERROR: No Mesh Object stored in this Study" - return None - - -#============================================================================== - -def getFieldDoubleObjectFromStudy(number,subnumber): - mySO = batchmode_salome.myStudy.FindObject("MEDFIELD") - mysub = mySO.FindSubObject(number)[1] - if mysub: - mysubsub = mysub.FindSubObject(subnumber)[1] - if mysubsub: - Builder = batchmode_salome.myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeName") - myObj = obj._narrow(SALOME_MED.FIELDDOUBLE) - return myObj - else: - print "ERROR: No FieldDouble Object stored in this Study" - return None - else: - print "ERROR: No FieldDouble Object stored in this Study" - return None - - -#============================================================================== - -def getFieldIntObjectFromStudy(number,subnumber): - mySO = batchmode_salome.myStudy.FindObject("MEDFIELD") - mysub = mySO.FindSubObject(number)[1] - if mysub: - mysubsub = mysub.FindSubObject(subnumber)[1] - if mysubsub: - Builder = batchmode_salome.myStudy.NewBuilder() - anAttr = Builder.FindOrCreateAttribute(mysubsub, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.FIELDINT) - return myObj - else: - print "ERROR: No FieldInt Object stored in this Study" - return None - else: - print "ERROR: No FieldInt Object stored in this Study" - return None - -#============================================================================== - -def getMedObjectFromStudy(fileName=None): - myObj=None; Builder = batchmode_salome.myStudy.NewBuilder() - if fileName is not None: - objNameInStudy = "MED_OBJECT_FROM_FILE_"+fileName - mySO = batchmode_salome.myStudy.FindObject(objNameInStudy) - if mySO is not None: - anAttr = Builder.FindOrCreateAttribute(mySO, "AttributeIOR") - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - if obj is not None: - myObj = obj._narrow(SALOME_MED.MED) - else: - print "ERROR: ",myObj," has been found in the Study, but with the type different of SALOME_MED.MED!!!" - else: - print "ERROR: ",objNameInStudy," hasn't been found in the Study!!!" - else: - SObj_root = batchmode_salome.myStudy.FindObjectByPath("/Med/") - if SObj_root is not None: - iter = batchmode_salome.myStudy.NewChildIterator(SObj_root) - try: - iter.Init(); - while iter.More(): - Obj = iter.Value() - if Obj is not None: - Ok, anAttr = Builder.FindAttribute(Obj, "AttributeIOR") - if Ok: - if len(anAttr.Value()) > 0: - obj = batchmode_salome.orb.string_to_object(anAttr.Value()) - if obj is not None: - myObj = obj._narrow(SALOME_MED.MED) - if myObj is not None: - break - iter.Next() - except: - print "Exception!!!" - else: print "Root object Med hasn't been found in the study!!!" - return myObj - -studyCurrent = batchmode_salome.myStudyName -studyCurrentId = batchmode_salome.myStudyId - -med_comp = batchmode_salome.lcc.FindOrLoadComponent("FactoryServer", "MED") diff --git a/src/MedCorba_Swig/libMedCorba_Swig.i b/src/MedCorba_Swig/libMedCorba_Swig.i deleted file mode 100644 index f72feed88..000000000 --- a/src/MedCorba_Swig/libMedCorba_Swig.i +++ /dev/null @@ -1,794 +0,0 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// - -%module libMedCorba_Swig - -%include "libMEDMEM_Swig.i" - -%{ -#include "MEDMEM_convert.hxx" -#include "MEDMEM_Family_i.hxx" -#include "MEDMEM_Field_i.hxx" -#include "MEDMEM_FieldTemplate_i.hxx" -#include "MEDMEM_Group_i.hxx" -#include "MEDMEM_Med_i.hxx" -#include "MEDMEM_GMesh_i.hxx" -#include "MEDMEM_Mesh_i.hxx" -#include "MEDMEM_Support_i.hxx" -#include "Med_Gen_i.hxx" - - using namespace MEDMEM; - using namespace MED_EN; -%} - -/* - typemap in, out and typecheck for Corba Objects (MESH, FIELDDOUBLE, FIELDINT and - Support) between C++ and Python - - WARNING (NB) to the user of those typmaps (SWIG wrapping for C++ routines - ------------------------------------------------------------------------- - - You have to be quite careful about the SWIG version your are currently - using, because CORBA pointeur _ptr or _var could be wrapped by SWIG using - their reference rather than the pointeur itself (differences detected using - SWIG 1.1.x, SWIG 1.3.13 and SWIG 1.3.17) - - typecheck always says OK, as currently all overloaded methods HERE differ - only in nb of parameters (there are default ones) -*/ - -#if defined(SWIGPYTHON) -%typemap(out) SALOME_MED::GMESH_ptr, SALOME_MED::MESH_ptr, SALOME_MED::FIELDDOUBLE_ptr, - SALOME_MED::FIELDINT_ptr, SALOME_MED::SUPPORT_ptr, - const SALOME_MED::GMESH_ptr, const SALOME_MED::MESH_ptr, const SALOME_MED::FIELDDOUBLE_ptr, - const SALOME_MED::FIELDINT_ptr, const SALOME_MED::SUPPORT_ptr -{ - MESSAGE("typemap out sur Objet Corba version ptr"); - - SCRUTE($1); - - // Get the orb corba python - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Get the orb Corba C++ - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - - string s = ORB->object_to_string($1); - SCRUTE(s); - PyObject * tmp = PyString_FromString(s.c_str()); - SCRUTE(tmp); - PyObject * corbaObj = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp); - $result = corbaObj; - - // cast CORBA object, if necessary - - // make target class name -// string className = "$1_type"; -// className.replace( className.find(':'), 2, "."); -// className.erase( className.find("_ptr")); - -// // get target class object -// string getClassCmd = ( "cls = " + className ); -// PyRun_String("import SALOME_MED", Py_single_input, pdict, pdict); -// PyRun_String(getClassCmd.c_str(), Py_single_input, pdict, pdict); -// PyObject* cls = PyDict_GetItemString(pdict, "cls"); - -// // cast -// $result = PyObject_CallMethod(corbaObj, (char*)"_narrow", (char*)"O", cls); - - SCRUTE($result); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(out) SALOME_MED::GMESH_var, SALOME_MED::MESH_var, SALOME_MED::FIELDDOUBLE_var, - SALOME_MED::FIELDINT_var, SALOME_MED::SUPPORT_var, - const SALOME_MED::GMESH_var, const SALOME_MED::MESH_var, const SALOME_MED::FIELDDOUBLE_var, - const SALOME_MED::FIELDINT_var, const SALOME_MED::SUPPORT_var -{ - MESSAGE("typemap out sur Objet Corba version var"); - - // Get the orb corba python - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Get the orb Corba C++ - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - - string s = ORB->object_to_string(*$1); - SCRUTE(s); - PyObject * tmp = PyString_FromString(s.c_str()); - SCRUTE(tmp); - $result = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp); - SCRUTE($result); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(typecheck) SALOME_MED::GMESH_ptr, SALOME_MED::MESH_ptr, SALOME_MED::FIELDDOUBLE_ptr, - SALOME_MED::FIELDINT_ptr, SALOME_MED::SUPPORT_ptr, - const SALOME_MED::MESH_ptr, const SALOME_MED::FIELDDOUBLE_ptr, - const SALOME_MED::FIELDINT_ptr, const SALOME_MED::SUPPORT_ptr, - SALOME_MED::GMESH_var, SALOME_MED::MESH_var, SALOME_MED::FIELDDOUBLE_var, - SALOME_MED::FIELDINT_var, SALOME_MED::SUPPORT_var, - const SALOME_MED::MESH_var, const SALOME_MED::FIELDDOUBLE_var, - const SALOME_MED::FIELDINT_var, const SALOME_MED::SUPPORT_var -{ - $1 = 1; -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::MESH_ptr &, SALOME_MED::MESH_ptr & -{ - - MESSAGE("typemap in sur Objet Corba MESH avec reference"); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform MESH (python Corba) ptr to IOR string - - PyObject* iorMesh - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorMesh == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorMesh)); - - // Ask omniORB to convert IOR string to MESH (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::MESH_ptr t = SALOME_MED::MESH::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = &t; - SCRUTE(*$1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::FIELDDOUBLE_ptr &, - SALOME_MED::FIELDDOUBLE_ptr & -{ - - MESSAGE("typemap in sur Objet Corba FIELDDOUBLE avec reference"); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform FIELDDOUBLE (python Corba) ptr to IOR string - - PyObject* iorFieldDouble - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorFieldDouble == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorFieldDouble)); - - // Ask omniORB to convert IOR string to FIELDDOUBLE (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::FIELDDOUBLE_ptr t = SALOME_MED::FIELDDOUBLE::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = &t; - SCRUTE(*$1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::FIELDINT_ptr &, - SALOME_MED::FIELDINT_ptr & -{ - - MESSAGE("typemap in sur Objet Corba FIELDINT avec reference"); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform FIELDINT (python Corba) ptr to IOR string - - PyObject* iorFieldInt - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorFieldInt == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorFieldInt)); - - // Ask omniORB to convert IOR string to FIELDINT (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::FIELDINT_ptr t = SALOME_MED::FIELDINT::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = &t; - SCRUTE(*$1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::FIELDDOUBLE_ptr, - SALOME_MED::FIELDDOUBLE_ptr -{ - - MESSAGE("typemap in sur Objet Corba FIELDDOUBLE sans reference"); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform FIELDDOUBLE (python Corba) ptr to IOR string - - PyObject* iorFieldDouble - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorFieldDouble == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorFieldDouble)); - - // Ask omniORB to convert IOR string to FIELDDOUBLE (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::FIELDDOUBLE_ptr t = SALOME_MED::FIELDDOUBLE::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = t; - SCRUTE($1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::FIELDINT_ptr, - SALOME_MED::FIELDINT_ptr -{ - - MESSAGE("typemap in sur Objet Corba FIELDINT sans reference"); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform FIELDINT (python Corba) ptr to IOR string - - PyObject* iorFieldInt - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorFieldInt == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorFieldInt)); - - // Ask omniORB to convert IOR string to FIELDINT (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::FIELDINT_ptr t = SALOME_MED::FIELDINT::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = t; - SCRUTE($1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::SUPPORT_ptr &, SALOME_MED::SUPPORT_ptr & -{ - - MESSAGE("typemap in sur Objet Corba SUPPORT avec reference"); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string - - PyObject* iorSupport - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorSupport == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorSupport)); - - // Ask omniORB to convert IOR string to SUPPORT (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::SUPPORT_ptr t = SALOME_MED::SUPPORT::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = &t; - SCRUTE(*$1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::SUPPORT_ptr, SALOME_MED::SUPPORT_ptr -{ - - MESSAGE("typemap in sur Objet Corba SUPPORT sans reference"); - - SCRUTE($input); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string - - PyObject* iorSupport - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorSupport == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorSupport)); - - // Ask omniORB to convert IOR string to SUPPORT (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::SUPPORT_ptr t = SALOME_MED::SUPPORT::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = t; - SCRUTE($1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::GMESH_ptr, SALOME_MED::GMESH_ptr -{ - - MESSAGE("typemap in sur Objet Corba MESH sans reference"); - - SCRUTE($input); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform MESH (python Corba) ptr to IOR string - - PyObject* iorMesh - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorMesh == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorMesh)); - - // Ask omniORB to convert IOR string to MESH (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::GMESH_ptr t = SALOME_MED::GMESH::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = t; - SCRUTE($1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::MESH_ptr, SALOME_MED::MESH_ptr -{ - - MESSAGE("typemap in sur Objet Corba MESH sans reference"); - - SCRUTE($input); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform MESH (python Corba) ptr to IOR string - - PyObject* iorMesh - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorMesh == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorMesh)); - - // Ask omniORB to convert IOR string to MESH (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::MESH_ptr t = SALOME_MED::MESH::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = t; - SCRUTE($1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::FIELDDOUBLE_ptr, - SALOME_MED::FIELDDOUBLE_ptr & -{ - - MESSAGE("typemap in sur Objet Corba FIELDDOUBLE sans reference"); - - SCRUTE($input); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform FIELDDOUBLE (python Corba) ptr to IOR string - - PyObject* iorFieldDouble - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorFieldDouble == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorFieldDouble)); - - // Ask omniORB to convert IOR string to FIELDDOUBLE (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::FIELDDOUBLE_ptr t = SALOME_MED::FIELDDOUBLE::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = t; - SCRUTE($1); -} -#endif - -#if defined(SWIGPYTHON) -%typemap(in) const SALOME_MED::FIELDINT_ptr, - SALOME_MED::FIELDINT_ptr -{ - - MESSAGE("typemap in sur Objet Corba FIELDINT sans reference"); - - SCRUTE($input); - - PyObject* pdict = PyDict_New(); - PyDict_SetItemString(pdict, "__builtins__", PyEval_GetBuiltins()); - PyRun_String("import CORBA", Py_single_input, pdict, pdict); - - PyRun_String("o = CORBA.ORB_init([''], CORBA.ORB_ID);", Py_single_input, - pdict, pdict); - - PyObject* orb = PyDict_GetItemString(pdict, "o"); - - // Ask omniORBpy to transform FIELDINT (python Corba) ptr to IOR string - - PyObject* iorFieldInt - = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); - - if (iorFieldInt == Py_None) - return NULL; - char * s = PyString_AsString(PyObject_Str(iorFieldInt)); - - // Ask omniORB to convert IOR string to FIELDINT (C++ Corba) ptr - - int argc = 0; - char *xargv = (char*)""; - char **argv = &xargv; - CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); - CORBA::Object_var O = ORB->string_to_object(s); - SCRUTE(O); - SALOME_MED::FIELDINT_ptr t = SALOME_MED::FIELDINT::_narrow(O); - SCRUTE(CORBA::is_nil(t)); - - $1 = t; - SCRUTE($1); -} -#endif - - -/* - managing C++ exception in the Python API -*/ -/*%exception -{ - class PyAllowThreadsGuard { - public: - PyAllowThreadsGuard() { _save = PyEval_SaveThread(); } - ~PyAllowThreadsGuard() { PyEval_RestoreThread(_save); } - private: - PyThreadState *_save; - }; - - PyAllowThreadsGuard guard; - - $action -}*/ - -SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble(SALOME_MED::SUPPORT_ptr, - FIELDDOUBLE *, - bool ownCppPtr=false); - -SALOME_MED::FIELDINT_ptr createCorbaFieldInt(SALOME_MED::SUPPORT_ptr, - FIELDINT *, - bool ownCppPtr=false); - -SALOME_MED::SUPPORT_ptr createCorbaSupport(const SUPPORT *); - -FIELDDOUBLE * createLocalFieldDouble(const int, const int); - -FIELDINT * createLocalFieldInt(const int, const int); - -SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh); - -%{ - SALOME_MED::FIELDDOUBLE_ptr createCorbaFieldDouble(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDDOUBLE * field, bool ownCppPtr=false) - { - SCRUTE(field); - - // MT : Keep the local field name - // field->setName("Corba Double Field"); - - field->setDescription("Got From A Local One"); - - FIELDTEMPLATE_I *fieldimpl = new FIELDTEMPLATE_I(field, ownCppPtr); - - SALOME_MED::FIELDDOUBLE_ptr fieldcorba2 = fieldimpl->_this(); - - SCRUTE(fieldimpl); - - SCRUTE(fieldcorba2); - - MESSAGE("Test de tirarge sur le pointeur Corba Field dans le cxx"); - - char * name = fieldcorba2->getName(); - - SCRUTE(name); - - delete [] name; - - // try to set support to field - ::MEDMEM::SUPPORT * sup = 0; - if ( SUPPORT_i * sup_i = Med_Gen_i::DownCast< SUPPORT_i * >( mySupportIOR )) - { - std::map < int,::MEDMEM::SUPPORT *>::iterator index_supp = - SUPPORT_i::supportMap.find( sup_i->getCorbaIndex() ); - if ( index_supp != SUPPORT_i::supportMap.end() ) - sup = index_supp->second; - } - SCRUTE( sup ); - if ( sup ) - field->setSupport( sup ); - - return fieldcorba2; - } - - SALOME_MED::FIELDINT_ptr createCorbaFieldInt(SALOME_MED::SUPPORT_ptr mySupportIOR,FIELDINT * field, bool ownCppPtr=false) - { - SCRUTE(field); - - // MT : Keep the local field name - // field->setName("Corba Integer Field"); - - field->setDescription("Got From A Local One"); - - FIELDTEMPLATE_I * fieldimpl = new FIELDTEMPLATE_I(field, ownCppPtr); - - SALOME_MED::FIELDINT_ptr fieldcorba2 = fieldimpl->_this(); - - SCRUTE(fieldimpl); - - SCRUTE(fieldcorba2); - - MESSAGE("Test de tirarge sur le pointeur Corba Field dans le cxx"); - - char * name = fieldcorba2->getName(); - - SCRUTE(name); - - delete [] name; - - // try to set support to field - ::MEDMEM::SUPPORT * sup = 0; - if ( SUPPORT_i * sup_i = Med_Gen_i::DownCast< SUPPORT_i * >( mySupportIOR )) - { - std::map < int,::MEDMEM::SUPPORT *>::iterator index_supp = - SUPPORT_i::supportMap.find( sup_i->getCorbaIndex() ); - if ( index_supp != SUPPORT_i::supportMap.end() ) - sup = index_supp->second; - } - SCRUTE( sup ); - if ( sup ) - field->setSupport( sup ); - - return fieldcorba2; - } - - SALOME_MED::SUPPORT_ptr createCorbaSupport(const SUPPORT * const support) - { - SCRUTE(support); - - SUPPORT_i * supportimpl = new SUPPORT_i(support); - - SALOME_MED::SUPPORT_ptr supportcorba = - supportimpl->POA_SALOME_MED::SUPPORT::_this(); - - SCRUTE(supportimpl); - - SCRUTE(supportcorba); - - return supportcorba; - } - - SALOME_MED::MESH_ptr createCorbaMesh(MESH * mesh) - { - SCRUTE(mesh); - - MESH_i * meshimpl = new MESH_i(mesh); - - SALOME_MED::MESH_ptr meshcorba = - meshimpl->POA_SALOME_MED::MESH::_this(); - - SCRUTE(meshimpl); - - SCRUTE(meshcorba); - - return meshcorba; - } - - FIELDDOUBLE * createLocalFieldDouble(const int NumberOfComponents, - const int LengthValue) - { - SCRUTE(NumberOfComponents); - SCRUTE(LengthValue); - - //FIELD * fieldloc = new FIELD(); - FIELDDOUBLE * fieldloc = new FIELDDOUBLE(); - fieldloc -> allocValue(NumberOfComponents,LengthValue); - - return fieldloc; - } - - FIELDINT * createLocalFieldInt(const int NumberOfComponents, - const int LengthValue) - { - SCRUTE(NumberOfComponents); - SCRUTE(LengthValue); - - //FIELD * fieldloc = new FIELD(); - FIELDINT * fieldloc = new FIELDINT(); - fieldloc -> allocValue(NumberOfComponents,LengthValue); - - return fieldloc; - } -%} diff --git a/src/MedCorba_Swig/medcorba_test.py b/src/MedCorba_Swig/medcorba_test.py deleted file mode 100644 index ce143bc28..000000000 --- a/src/MedCorba_Swig/medcorba_test.py +++ /dev/null @@ -1,286 +0,0 @@ -# -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# MED MedCorba_Swig : binding of MED CORBA objects woth Python -# File : medcorba_test.py -# Module : MED -# -import salome - -import SALOME_MED - -from libSALOME_Swig import * -sg = SALOMEGUI_Swig() - -from libMedCorba_Swig import * -from libMEDClient import * - -from random import * - -import os - -filePath = os.environ["MED_ROOT_DIR"] -filePath = os.path.join( filePath, "share", "salome", "resources", "med" ) - -#============================================================================== - -def AnalyzeField(field): - name = field.getName() - desc = field.getDescription() - nbComp = field.getNumberOfComponents() - itNum = field.getIterationNumber() - ordNum = field.getOrderNumber() - - print "Analysis of the field ",name," with the description ",desc - print "iteration number ",itNum," order Number ",ordNum - print "It has ",nbComp," component(s)" - - fieldValue = field.getValue(SALOME_MED.MED_FULL_INTERLACE) - fieldSupport = field.getSupport() - fieldMesh = fieldSupport.getMesh() - fieldEntity = fieldSupport.getEntity() - bool = fieldSupport.isOnAllElements() - - if bool: - print "The support of this field is on all entities ",fieldEntity," of the mesh ",fieldMesh.getName() - if fieldEntity == SALOME_MED.MED_NODE: - nbValByComp = fieldMesh.getNumberOfNodes() - else: - nbValByComp = fieldMesh.getNumberOfElements(fieldEntity,SALOME_MED.MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - else: - print "The support of this field is partially on entities ",fieldEntity," of the mesh ",fieldMesh.getName() - nbValByComp = fieldSupport.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS) - print "and its dimension (number of values by component of the field) is ",nbValByComp - - for i in range(nbComp): - compName = field.getComponentName(i+1) - compUnit = field.getComponentUnit(i+1) - print "The ",(i+1),"-th component ",compName," with the unit ",compUnit - - for i in range(nbValByComp): - print " * ",fieldValue[i*nbComp:(i+1)*nbComp] - -#============================================================================== - -def getMeshObjectFromStudy(meshName): - objNameInStudy = "/Med/MEDMESH/"+meshName - mySO = salome.myStudy.FindObjectByPath(objNameInStudy) - if (mySO == None) : - print "ERROR: ",objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MESH) - if (myObj == None) : - print "ERROR: ",objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -#============================================================================== - -def getMedObjectFromStudy(file): - objNameInStudy = "MED_OBJECT_FROM_FILE_"+file - compNameInStudy= "MED" - listOfSO = salome.myStudy.FindObjectByName(objNameInStudy,compNameInStudy) - listLength = len(listOfSO) - if (listLength == 0) : - print "ERROR: ",objNameInStudy," cannot be found in the Study under the component ",compNameInStudy - return None - elif (listLength > 1) : - print "ERROR: there are more than one instance of ",objNameInStudy," in the Study under the component ",compNameInStudy - return None - mySO = listOfSO[0] - if (mySO == None) : - print "ERROR: ",objNameInStudy," cannot be found in the Study" - return mySO - else: - anAttr = mySO.FindAttribute("AttributeIOR")[1] - obj = salome.orb.string_to_object(anAttr.Value()) - myObj = obj._narrow(SALOME_MED.MED) - if (myObj == None) : - print "ERROR: ",objNameInStudy," has been found in the Study but with the wrong type" - return myObj - -#============================================================================== - -studyCurrent = salome.myStudyName -studyCurrentId = salome.myStudyId - -print "We are working in the study ",studyCurrent," with the ID ",studyCurrentId -print "" - -fileName = "cube_hexa8_quad4.med" -#medFile = "carre_en_quad4_seg2.med" -medFile = os.path.join( filePath, fileName ) - -print "Loading of the Med Component" -print "" - -med_comp = salome.lcc.FindOrLoadComponent("FactoryServer", "MED") - -print "Read file", medFile -print "" - -import SALOME -try: - med_comp.readStructFileWithFieldType(medFile,studyCurrent) -except SALOME.SALOME_Exception, inst: - msg = "SALOME.SALOME_Exception caght, see details:" - msg+="\n******* text:\t" + inst.details.text - msg+="\n******* type:\t" + str(inst.details.type) - msg+="\n******* where:\t" + inst.details.sourceFile + ":" + \ - str(inst.details.lineNumber) - raise RuntimeError, msg - -sg.updateObjBrowser(1) - -med_obj = getMedObjectFromStudy(fileName) - -nbMeshes = med_obj.getNumberOfMeshes() - -nbFields = med_obj.getNumberOfFields() - -meshNames = med_obj.getMeshNames() - -print "" -print "The med file ",medFile," has ",nbMeshes," Meshe(s) and ",nbFields," Field(s)" -print "" - -meshName = meshNames[0] - -meshcorba = getMeshObjectFromStudy(meshName) - -nbNodes = meshcorba.getNumberOfNodes() - -spaceDim = meshcorba.getSpaceDimension() - -print "The mesh from the Study is ",meshName,".It is a ",spaceDim,"-D mesh and it has ",nbNodes," Nodes" -print "" - -for entity in [SALOME_MED.MED_NODE,SALOME_MED.MED_CELL,SALOME_MED.MED_FACE,SALOME_MED.MED_EDGE]: - nbFam = meshcorba.getNumberOfFamilies(entity) - if (entity == SALOME_MED.MED_NODE) & (nbFam > 0): - print "This mesh has",nbFam,"Node Family(ies)" - elif (entity == SALOME_MED.MED_CELL) & (nbFam > 0): - print "This mesh has",nbFam,"Cell Family(ies)" - elif (entity == SALOME_MED.MED_FACE) & (nbFam > 0): - print "This mesh has",nbFam,"Face Family(ies)" - elif (entity == SALOME_MED.MED_EDGE) & (nbFam > 0): - print "This mesh has",nbFam,"Edge Family(ies)" - - if nbFam > 0: - for j in range(nbFam): - print "" - familycorba = meshcorba.getFamily(entity,j+1) - familyName = familycorba.getName() - familyDescription = familycorba.getDescription() - familyEntity = familycorba.getEntity() - familyBool = familycorba.isOnAllElements() - print " -Name:",familyName - print " -Description:",familyDescription - print " -Entity:",familyEntity - familyIdentifier = familycorba.getIdentifier() - nbOfAtt = familycorba.getNumberOfAttributes() - print " -Identifier:",familyIdentifier - print " -Number Of Attributes:",nbOfAtt - attributesids = familycorba.getAttributesIdentifiers() - attributesvals = familycorba.getAttributesValues() - for k in range(nbOfAtt): - print " * Attributes:",attributesids[k],":",attributesvals[k],",",familycorba.getAttributeDescription(k+1) - print " -Entities list:" - if (familyBool): - print " -Is on all entities" - else: - types = familycorba.getTypes() - nbOfTypes = len(types) - print " -Number Of Types:",nbOfTypes - for k in range(nbOfTypes): - type = types[k] - nbOfElmtsOfType = familycorba.getNumberOfElements(type) - number = familycorba.getNumber(type) - print " * Type",type - print " * Number",number[0:nbOfElmtsOfType] - print "" - lengthValue = familycorba.getNumberOfElements(SALOME_MED.MED_ALL_ELEMENTS) - nbOfComp = 1 - - supportOutLocal = SUPPORTClient( familycorba ) - supportOutCorba = createCorbaSupport( supportOutLocal ) - - print "\nGenerate a Local scalar double field" - fieldScalDblLoc = createLocalFieldDouble(nbOfComp,lengthValue) - value = [ random() for k in range(lengthValue*nbOfComp) ] - fieldScalDblLoc.setValue( value ) ## the only way as field support not defined - valueIverif = fieldScalDblLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba scalar double field" - fieldScalDblLoc.setSupport( supportOutLocal ) - fieldScalDblCorba = createCorbaFieldDouble(supportOutCorba,fieldScalDblLoc) - AnalyzeField(fieldScalDblCorba) - - print "Generate a Local scalar integer field" - fieldScalIntLoc = createLocalFieldInt(nbOfComp,lengthValue) - value = [ randint(0,100) for k in range(lengthValue*nbOfComp) ] - fieldScalIntLoc.setValue( value ) ## the only way as field support not defined - valueIverif = fieldScalIntLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba scalar integer field" - fieldScalIntLoc.setSupport( supportOutLocal ) - fieldScalIntCorba = createCorbaFieldInt(supportOutCorba,fieldScalIntLoc) - AnalyzeField(fieldScalIntCorba) - - nbOfComp = spaceDim - print "\nGenerate a Local vector double field" - fieldVectDblLoc = createLocalFieldDouble(nbOfComp,lengthValue) - value = [ random() for k in range(lengthValue*nbOfComp) ] - fieldVectDblLoc.setValue(value) - valueIverif = fieldVectDblLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba vector double field" - fieldVectDblLoc.setSupport( supportOutLocal ) - fieldVectDblCorba = createCorbaFieldDouble(supportOutCorba,fieldVectDblLoc) - AnalyzeField(fieldVectDblCorba) - - print "\nGenerate a Local vector integer field" - fieldVectIntLoc = createLocalFieldInt(nbOfComp,lengthValue) - value = [ randint(0,100) for k in range(lengthValue*nbOfComp) ] - fieldVectIntLoc.setValue(value) - valueIverif = fieldVectIntLoc.getValue() - print " Set ",value - print " Get ",valueIverif - - print "\nGenerate a Corba vector integer field" - fieldVectIntLoc.setSupport( supportOutLocal ) - fieldVectIntCorba = createCorbaFieldInt(supportOutCorba,fieldVectIntLoc) - AnalyzeField(fieldVectIntCorba) - print "" -print "Fin du script Python ...." - -